Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Filling the frame

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Filling the frame

    Hi,

    I can't seem to understand how to fill the frame within my window.

    I understand how to create menus, items, ActionListener and all that stuff, but I'm at a loss when trying to make use of the frame itself. Exemples I fall upon are all about creating a window and its frame, without any menu, and I can't seem to use both those things.


    Here's my basic code, if someone would be so nice as to point out how to make use of my frame, it would be greatly appreciated. I plan to use a JSplitPane, filled with textpanes, but i'm sure I'll be able to figure it out on my own once I know how to use the frame for a simple TextFrame.

    import javax.swing.*;
    import java.awt.event.*;
     
     
     
     
     
    public class LaFenetre extends JFrame implements ActionListener
     
    {
     
    	static final long serialVersionUID = 0L;
     
    	//Event declarations
    	static final String File_Quit = "Quit";
     
     
     
    	//Constructor
    	public LaFenetre()
    	{
    		super ("CheckTradeOrders");
     
    		// Application closes when window is shut.
    	    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    	    // Initialize window
    	    Initialize();
    	}
     
    	private void Initialize()
    	{
    		//MenuBar creation
    		JMenuBar menuBar;
    		menuBar = new JMenuBar();
    		//Menus creation
    		JMenu menuFile; 
     
    		//File Menu creation
    		menuFile = new JMenu("File");
    		menuFile.setMnemonic(KeyEvent.VK_F);
    		menuFile.getAccessibleContext().setAccessibleDescription("File menu");
    		menuBar.add(menuFile);
    		//Quit command creation
    		JMenuItem mnItemQuit = new JMenuItem(File_Quit);
    		mnItemQuit.setMnemonic(KeyEvent.VK_Q);
    		mnItemQuit.getAccessibleContext().setAccessibleDescription("Quit program");
    		mnItemQuit.addActionListener(this); 
    		menuFile.add(mnItemQuit);
     
     
     
    		// adding menu bar to window
    		setJMenuBar(menuBar);
    		setSize(800,600);    
     
     
     
    	}
     
     
    	// Event handler
    	public void actionPerformed(ActionEvent evt) 
    	{
    	     String action = evt.getActionCommand();
    	     if (action==File_Quit)
    	     {
    	    	 System.exit(0);
    	     }
     
    	}
     
     
    	static public void main(String[] args) 
    	{
    	     JFrame f = new LaFenetre();
    	     f.setVisible(true);
     
     
     
     
     
    	}
     
     
     
    }

    Thanks


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Filling the frame

    how to fill the frame within my window
    The common way is to use a layout manager, create some container objects and add you components to those containers and add those containers to your JFrame. There must be thousands of code examples around.

  3. #3
    Junior Member
    Join Date
    Jul 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Filling the frame

    Thanks for the fast answer, I decided to opt for netbean IDE, I guess this will save me a lot of time.

Similar Threads

  1. Filling Arrays
    By av8 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 25th, 2011, 11:41 PM
  2. filling an array with strings
    By exose in forum Collections and Generics
    Replies: 3
    Last Post: February 18th, 2011, 09:44 AM
  3. [SOLVED] Filling in alternating colors of a "BullsEye"
    By forte in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 22nd, 2010, 06:05 PM
  4. Chessboard filling issue
    By olemagro in forum AWT / Java Swing
    Replies: 7
    Last Post: January 23rd, 2010, 07:07 PM
  5. Filling an Array?
    By Bascotie in forum Collections and Generics
    Replies: 5
    Last Post: October 14th, 2009, 06:27 PM