Thread: GUI magic

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Location
    Kiev, Ukrain
    Posts
    88
    Rep Power
    2

    GUI magic


    I just posted 1 question on GUI and here comes another 1.
    I'm trying to create simple menubar and table for data handling.
    But when i'm declaring my table, the screen clears up. If i comenting creation of the table - the screen is ok .


    Here is the code :
    main:
    Code:
    import java.awt.*;
    import javax.swing.*;
    
    class root{
    	
    	public static void main(String[] args){
    		
    		//frame parameters
    		JFrame mainFrame = new JFrame("Journal B");
    		mainFrame.setVisible(true);
    		mainFrame.setSize(1000,600);
    		
    		//content objects
    		MMenu menu = new MMenu();
    		MTable tab = new MTable();
    		
    		//components addition
    		mainFrame.add(menu,BorderLayout.NORTH);
    		mainFrame.add(tab,BorderLayout.SOUTH);
    		
    		
    		
    	}
    	
    }
    Menu:
    Code:
    import javax.swing.*;
    import javax.swing.*;
    
    
    class MMenu extends JMenuBar{
    	
    	JMenuItem openItem = new JMenuItem("Open");
    	JMenu openMenu = new JMenu("File");;
    	
    	public MMenu(){		
    		
    
    		openMenu.add(openItem);
    		add(openMenu);
    	}
    }
    Table:
    Code:
    import javax.swing.*;
    
    //result table 
    class MTable extends JTable{
    
    	public MTable(){
    		
    		setSize(950, 400);
    	}
    
    }
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Location
    Kiev, Ukrain
    Posts
    88
    Rep Power
    2
    Guys i have a new magic for you:
    i just clicking a lot of buttons and doing ctrl+V & ctrl+Z

    the code remains the same but i have no output in my frame at all!!!!! but if i press ctrl+s three times i can see my menu. if two - i'm not . I"M REALLLY REALLLY SHOCKED !!!!!
    I'm using :
    Eclipse SDK

    Version: 3.7.2
    Build id: M20120208-0800

    with a normal pc . I just don't know what ghost is ****ing my computer at the moment. Please can u help me?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    26
    Rep Power
    0
    use the GridLayout layout = new GridLayout(x,y) where x and y are int values ( to get the appropriate result play with the int values ).to learn more on layout management see oracle documentation (try googling)
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Location
    Kiev, Ukrain
    Posts
    88
    Rep Power
    2
    I'm watching oracle 2nd day in a row. But how can you explain that my programm differs in output if i add coment , like: //parameters.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    26
    Rep Power
    0
    if we comment on a line,like frame.addJMenuBar(menubar); the compiler totally skips that line and treat them as a single white space.comments are only useful for understanding the meaning what the lines do.thus comments are eleminated during compile time.Was my first answer helpful to you.i have not spent much time for compiling your code

IMN logo majestic logo threadwatch logo seochat tools logo