Results 1 to 3 of 3
  1. #1
    LennyKosmos is offline Member
    Join Date
    Sep 2010
    Posts
    28
    Rep Power
    0

    Default combobox doesnt show!

    for 4 hours ive tried to get this combobox to show up on the screen...and it simply doesn't work, i only managed to make it show in the menu-bar but not in the actual box..


    Java Code:
    import java.awt.*;	
    import java.awt.event.*;
    import javax.swing.*;
    
    	public class Order extends JFrame{
    		private JMenuBar huvudmeny;
    		private JMenu Profiler, Meny;
    		private JMenuItem LäggTillKund, TagBortKund;
    		private JComboBox box;
    		private String[] Kunder = {"1", "2", "3", "4", "5", "6"};
    		private JPanel P, P2, P3;
    		
    		public Order(){
    			super("Huvudmeny");
    			huvudmeny = new JMenuBar();
    			Profiler = new JMenu("Profiler");
    			Meny = new JMenu("Meny");
    			LäggTillKund = new JMenuItem("Lägg till kund");
    			TagBortKund = new JMenuItem("Tag bort kund");
    			
    			
    			LäggTillKund.addActionListener(new Lyssnare());
    			TagBortKund.addActionListener(new Lyssnare2());
    			Profiler.add(LäggTillKund);
    			Profiler.add(TagBortKund);
    			
    [B]
    			box = new JComboBox(Kunder);
    			JPanel P3 = new JPanel(new BorderLayout());
    			P3.add(box);
    
    			setJMenuBar(huvudmeny);
    			huvudmeny.add(Meny);
    			Meny.add(Profiler);
    			setSize(300, 300);
    			setDefaultCloseOperation(EXIT_ON_CLOSE);
    			setLocationRelativeTo(null);
    			setVisible(true);[/B]
    			}
    		public class Lyssnare implements ActionListener{
    			public void actionPerformed(ActionEvent e){
    				Kund X = new Kund();
    				X.SkapaFil();
    				X.LäggTillKund();
    				X.Stäng();
    				
    				X.Öppnafil();
    				X.LäsFil();
    				//JFrame nyruta = new JFrame();
    				//nyruta.setVisible(true);		
    				}
    			}
    		public class Lyssnare2 implements ActionListener{
    			public void actionPerformed(ActionEvent e){
    				JFrame nyruta2 = new JFrame();
    				nyruta2.setVisible(true);	
    				nyruta2.setSize(150, 150);
    				nyruta2.setLocationRelativeTo(null);
    				
    		}
    	}
    		
    
    		public static void main (String[] args){
    			new Order();
    		
    
    		}
    		
    	}

  2. #2
    gmarut is offline Member
    Join Date
    Oct 2010
    Posts
    6
    Rep Power
    0

    Default

    You made a new JPanel that now contains the checkbox but never added the JPanel to the Frame...

    Add the code in your constructor:

    getContentPane().add(P3);

  3. #3
    LennyKosmos is offline Member
    Join Date
    Sep 2010
    Posts
    28
    Rep Power
    0

    Default

    Quote Originally Posted by gmarut View Post
    You made a new JPanel that now contains the checkbox but never added the JPanel to the Frame...

    Add the code in your constructor:

    getContentPane().add(P3);
    thanks mate! it was as simple as that ^^

Similar Threads

  1. Replies: 7
    Last Post: 09-28-2010, 01:17 AM
  2. doesnt show exact size
    By clydedoris in forum NetBeans
    Replies: 3
    Last Post: 07-13-2010, 07:59 AM
  3. Replies: 3
    Last Post: 05-27-2010, 11:54 AM
  4. JTable doesnt show columun names!
    By phil128 in forum AWT / Swing
    Replies: 3
    Last Post: 03-08-2009, 11:39 PM
  5. netbeans 6.0 not show commpunent or show blank page
    By fahimaamir in forum NetBeans
    Replies: 1
    Last Post: 01-26-2008, 07:20 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
  •