Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 24-11-2009
Member
 
Join Date: Nov 2009
Posts: 446
Close Combo Box in java

Hi
Now I have a hands on experience of java. I have a problem in my java problem. I need to know how to close the ComboBox after the project is been selected. It opens the class openo that is perfect but the combobox is open in the new frame. I have posted my code below. Just go through it.
Code:
public opencb() {
    String[] proname = { "2004", "2003", "2005" };
     JComboBox pro = new JComboBox(proname);
     pro.setSelectedIndex(2);
     pro.addActionListener(this);
     add(pro, BorderLayout.PAGE_START);
     setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
}
public void actionPerformed(ActionEvent e) {
       JComboBox cb = (JComboBox)e.getSource();
       String proname = (String)cb.getSelectedItem();
       if (proname.equals("2004")) {
        openOrder.OpenOrder();
        frame.setVisible(false); 
        frame.dispose(); 
       }
    }
void comboFrame()  {
    frame.setPreferredSize(new Dimension(200,100));
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocationRelativeTo(null);
    JComponent newContentPane = new opencb();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);
}
Reply With Quote
  #2  
Old 24-11-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: Close Combo Box in java

Hello
I think swing utilities can be helpful here. Using them is very easy and the program will be small. The swing utility I am talking about is SwingUtilities.invokeLater. This should definitely help you.
Code:
SwingUtilities.invokeLater(new Runnable() {
	public void run() {
		openo.openo();
	}
});
If any more queries do post back.
Reply With Quote
  #3  
Old 24-11-2009
Member
 
Join Date: Nov 2009
Posts: 446
Re: Close Combo Box in java

Hi
I said that I need to close the combo box, but really sorry that is not the exact problem. Sorry that I have not explained you in a proper way. I want my program to work something like this, when i open a new project from the main class the combo box should be called so that I can select the project from the list. My problem is when I select a project a new frame is appeared in from of me but the combo box is still in the back ground.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Close Combo Box in java"
Thread Thread Starter Forum Replies Last Post
Best plan between BB Home Combo ULD 750 and BBG FN Combo 500 of BSNL TECHi India BroadBand 4 29-06-2013 11:03 AM
Which plan is good BSNL plan from BBG FN Combo 600 or BB Home Combo UL 750? SupaBoy India BroadBand 8 01-12-2011 08:58 PM
Reliance 649 combo VS Airtel 699 combo Anish-Mumbai India BroadBand 5 05-05-2010 09:45 AM
Disabling the Close Button on a JFrame in Java technika Software Development 5 24-02-2010 10:51 PM
How to Use Combo Boxes in Java? MarceloQuad Software Development 5 11-02-2010 03:23 AM


All times are GMT +5.5. The time now is 04:46 AM.