Results 1 to 2 of 2
Thread: Java GUI pane and combobox?
- 12-06-2012, 05:35 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 28
- Rep Power
- 0
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); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setResizable(false); setVisible(true); 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"); dishes.addItem("Water"); dishes.addItem("Coke"); grid2.add(dishes); contentPane.add("North",grid); contentPane.add("West",grid2); } public void actionPerformed(ActionEvent e) { } }
- 12-06-2012, 06:53 AM #2
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.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Trying to add a photo to first pane, but no go
By blkhrt in forum AWT / SwingReplies: 2Last Post: 10-23-2012, 03:49 PM -
I cannot find the Task Pane
By Programmer 142 in forum JCreatorReplies: 0Last Post: 11-02-2011, 07:07 PM -
Tabbed pane
By sonal12 in forum AWT / SwingReplies: 13Last Post: 09-15-2010, 12:22 AM -
tabbed Pane .
By programmer_007 in forum AWT / SwingReplies: 2Last Post: 09-03-2009, 08:52 PM -
call exe in Desktop Pane
By smartsubroto in forum New To JavaReplies: 4Last Post: 06-16-2008, 07:49 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks