aquaballoon

Java: JFrame -> JPanel

Feb 28th, 2012
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. //Main class calling JPanel from JFrame
  2.  
  3. publicc class Main{
  4.     public static void main(String arg[]{
  5.  
  6.     //--the beginning of event--   
  7.     private void open_ViewActionPerformed(java.awt.event.ActionEvent evt) {                                        
  8.     EventQueue.invokeLater(new Runnable() {
  9.             public void run() {
  10.                 JFrame frame = new JFrame();
  11.                 frame.setContentPane(new View());  // <--calling the constructor of View class
  12.                 frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  13.                 frame.pack();
  14.                 frame.setVisible(true);
  15.             }
  16.         });
  17.     //--the end of event--
  18.  
  19.     }
  20. }
  21.  
  22. //View class with JPanel edited by GUI Designer
  23.  
  24. class View extends JPanel {
  25.     public View() {     // <-- the consructor of View class
  26.     initComponents();
  27.     }
  28.     private void initComponents(){  // <-- coded by GUI Designer
  29.     }      
  30. }
Advertisement
Add Comment
Please, Sign In to add comment