Results 1 to 2 of 2
  1. #1
    dharav is offline Member
    Join Date
    Dec 2011
    Rep Power

    Question Java GUI pane and combobox?

    I have a pane with north and west column setted up, but it dosent work.But when i delete the grid2 it works somehow! Please see into it and correct what am i doing wrong.

    Java Code:
    package restaurantAssignment;
    import java.awt.BorderLayout;
    import java.awt.Button;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.GridLayout;
    import java.awt.Image;
    import java.awt.Panel;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.BoxLayout;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class gUI extends JFrame implements ActionListener
    	private static Object add;
    	public static void main(String[] args) 
    		gUI frame1 = new gUI();
    	public gUI()
    		super("Dharav's Restaurant");
    		setSize(500, 500);
    		Container contentPane = getContentPane();
    		JPanel grid = new JPanel(new GridLayout(2,2));
    	    grid.add(new JButton("KOSHER"));
    	    grid.add(new JButton("VEGETARIAN"));
    	    grid.add(new JButton("HALAL"));
    	    grid.add(new JButton("NON-VEGETARIAN"));
    	    JPanel grid2 = new JPanel();
    	    JComboBox dishes = new JComboBox();
    	    dishes.addItem("Lamb Kebab");
    	    dishes.addItem("Shish Kebab");
    	    dishes.addItem("Lamb Korma");
    	    dishes.addItem("Butter Naan");
    	    dishes.addItem("Garlic Naan");
    	public void actionPerformed(ActionEvent e)

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: Java GUI pane and combobox?

    First off, don't unnecessarily mix AWT and Swing components in the same GUI -- as implied by your import of java.awt.Button.

    Second, reduce code to the minimum when asking for free help on a forum,. That means getting rid of all unused imports, unused implementations and empty methods, and multiple blank lines.

    Third, set the top level window visible only after all components have been added.

    Moving this thread from New to Java to the appropriate section.

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Trying to add a photo to first pane, but no go
    By blkhrt in forum AWT / Swing
    Replies: 2
    Last Post: 10-23-2012, 03:49 PM
  2. I cannot find the Task Pane
    By Programmer 142 in forum JCreator
    Replies: 0
    Last Post: 11-02-2011, 07:07 PM
  3. Tabbed pane
    By sonal12 in forum AWT / Swing
    Replies: 13
    Last Post: 09-15-2010, 12:22 AM
  4. tabbed Pane .
    By programmer_007 in forum AWT / Swing
    Replies: 2
    Last Post: 09-03-2009, 08:52 PM
  5. call exe in Desktop Pane
    By smartsubroto in forum New To Java
    Replies: 4
    Last Post: 06-16-2008, 07:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts