Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   How to add multiple combo boxes to a single java program (http://www.go4expert.com/forums/add-multiple-combo-boxes-single-java-t21760/)

luettke10 14Apr2010 20:43

How to add multiple combo boxes to a single java program
 
How do you add multiple combo boxes to a single java program? If you could give me the source code I could add the items I want into the dropdown list.

satyedra pal 15Apr2010 12:49

Re: How to add multiple combo boxes to a single java program
 
ComboBox in java is created by Choice class.ComboBox suggest to the user for selecting one choice string depend on user choice from the giving alternatives.
We can create ComboBox in Java by using following program.
Code:

import java.awt.*;
import java.awt.event.*;
public class comboboxdemo
{
  public static void main(String[] args)
{
    Frame frame=new Frame("Combobox");
    Label str=new Label("Here is a ComboBox:");
    Choice comb1=new Choice();
    Choice comb2=new Choice();
    frame.add(str);
    frame.add(comb1);
    frame.add(comb2);
    comb1.add("INDIA");
    comb1.add("JAPAN");
    comb1.add("USA");
    comb2.add("INDIA");
    comb2.add("JAPAN");
    comb2.add("USA");
    frame.setLayout(new FlowLayout());
    frame.setSize(300,200);
    frame.setVisible(true);
 
    }
  }


luettke10 19Apr2010 02:11

Re: How to add multiple combo boxes to a single java program
 
Thank you very much for you help but now I need to know how to change the positions of the combo boxes.

satyedra pal 19Apr2010 13:35

Re: How to add multiple combo boxes to a single java program
 
Hi luettke10,
You can set the position of the Combo Boxs by using layout manager.Layout manager is used for arranging the java component.

luettke10 23Apr2010 20:45

Re: How to add multiple combo boxes to a single java program
 
How can you add pictures to a combo box for each of the choices?

satyedra pal 26Apr2010 10:58

Re: How to add multiple combo boxes to a single java program
 
Java Swing provides more feature or set of GUI components compare to (AWT)Abstract Window Toolkit. Java Swing provides pluggable look and feel that allows applications to have a look and feel that is not related to the underlying platform.
Through java swing we can find image on button,on textBox and also the roundrect box components.SO by using java swing we can add image on the java COmbo Box with each chice.All the keyword of javaswing starts with 'J' character.


All times are GMT +5.5. The time now is 14:32.