Displaying file results in combo box

i have read a list of numbers from a file by using vector, and the results are displayed. However i wish to somehow display the results in a jcombo box or equivalent in the main super class, please help, thanks.

BufferedReader in = new BufferedReader(new FileReader("id.doc"));
         while (true) {
              String File = in.readLine();
          if (File == null)
                  break;
                 StringTokenizer parser = new StringTokenizer(File, " ");
           nxtname = parser.nextToken();
           System.out.println(nextt);This reads my id's from file, however I want to display the results into a jcombo box in my main super class, what would the code be to do this?
Thanks

Similar Messages

  • Can I Display a Selection or Combo box using MIDP

    Hey All,
    How can I display a Selection or Combo box in My Form Using MIDlet. Please send a Way to do this. Thanks in Advance.

    Hi
    use 'List' for displaying menu..
    check the api for 'javax.microedition.lcdui.List' class
    regards
    williams

  • Displaying text in a combo box.

    Hi, i was wondering if anyone could help me finish an application i am working on. I have two forms, one inputs dat to a text file and another retrieves it. i want to display the text in a combo box and then click an event in the combo box and a description
    of the event will appear in a text  box, also if i select a date on the second form the events in the combo box change for that date if there is events for it. the first form is working fine , i was looking for help with the second one please. my code
    so far is:
    namespace TicketInformation
       public partial class TicketInformationForm : Form
          public TicketInformationForm()
             InitializeComponent();
          //creating the community events list.
          List<Community_Event> CommnunityEvents;
          //create the Create Event list method.
          private void CreateEventList()
             CommnunityEvents = new List<Community_Event>();
             // call the extract Data method.
             ExtractData();
             //Clear any events from the combo box before proceeding.
             eventComboBox.Items.Clear();
             //for each event item in the Commuity event list,add it to the eventComboBox.
             foreach (Community_Event item in CommnunityEvents)
                eventComboBox.Items.Add(item.Description);
             //if the events count is greater then 0, display the following
             if (CommnunityEvents.Count > 0)
                //if there are no events for the date selected display the following
                eventComboBox.Text = " -Events- ";
                descriptionTextBox.Text = "Pick an event";
             }//end if
             else
                //if there are no events for the date selected display the following
                eventComboBox.Text = " No Events ";
                descriptionTextBox.Text = "No events today.";
             }//end else
          //Creating the Method ExtractData
          private void ExtractData()
             CommnunityEvents.Clear();
             // load the data from the file
             List<Community_Event> tempList = new List<Community_Event>();
             //string[] fileLines = File.ReadLines(@"C:\Users\IAN\Documents\calendar.txt");
             foreach(string line in File.ReadLines("calendar.txt"))
                string[] items = line.Split(",".ToCharArray());
                if (items.Length >= 5)
                   Community_Event newEvent = new Community_Event();
                   newEvent.Day = Convert.ToInt32(items[0]);//Converting the Integer to a string.
                   newEvent.Time = items[1];
                   newEvent.Price = Convert.ToDecimal(items[2]);//Converting the decimal to a string.
                   newEvent.Event = items[3];
                   newEvent.Description = items[4];
                   //add the new events to the Comminity Events list.
                   CommnunityEvents.Add(newEvent);
             CommnunityEvents = (from ev in tempList
                                          where ev.Day == 1
                                          select ev).ToList();
          private void dateMonthCalendar_DateChanged(object sender, DateRangeEventArgs e)
             //calling the create event list method to display any events in the eventscombo box.
             CreateEventList();
          private void eventComboBox_SelectedIndexChanged(object sender, EventArgs e)
          private void descriptionTextBox_TextChanged(object sender, EventArgs e)
          private void TicketInformationForm_Load(object sender, EventArgs e)
             //calling the create event list to open the form with today's events displayed if any.
             CreateEventList();
     public class Community_Event
          //Declare a DayValue property of type int
          private int DayValue;//day of the event
          public int Day// Name of the Property
             get
                return DayValue;
             set
                DayValue = value;
          //Declare a TimeValue property of type string
          private string timeValue;//time of the event
          public string Time// Name of the Property
             get
                return timeValue;
             set
                timeValue = value;
          //Declare a priceValue property of type Decimal
          private decimal priceValue;//price of the event
          public decimal Price// Name of the Property
             get
                return priceValue;
             set
                priceValue = value;
          //Declare a eventNameValue property of type string
          private string eventNameValue;//name of the event
          public string Event// Name of the Property
             get
                return eventNameValue;
             set
                eventNameValue = value;
          //Declare a DescriptionValue of type string
          private string DescriptionValue;//description of the event
          public string Description// Name of the Property
             get
                return DescriptionValue;
             set
                DescriptionValue = value;
    Thanks
    D

    Hi Dylan2412,
    According to your description, you'd like to pass the ComboBox.Text to the second form's TextBox.
    In Form1:
    private void button1_Click(object sender, EventArgs e)
    Form2 f2 = new Form2(this.comboBox1.Text); //pass the comboBox1.Text
    f2.Show();
    In Form2:
    public Form2(string s) //get the string;
    InitializeComponent();
    this.textBox1.Text = s;
    You could get the comBoBox refer to this sample above.
    If you have any other concern regarding this issue, please feel free to let me know.
    Best regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to get the values from xml file to java combo box

    Hi frens,
    I am new to java and xml programming,
    Now, i want to have a code of getting the tag values from the xml file
    into the swing combo box of java front end.
    How can we do that?
    any help of code or tutorial or an ebook is a great help for me.
    Thank you,
    Karthik.
    Edited by: Karthik84 on Aug 27, 2008 1:49 AM
    Edited by: Karthik84 on Aug 27, 2008 11:29 PM

    look at this link
    http://www.stylusstudio.com/docs/v2006/d_help30.html
    I read sometime back that castor has a tool to do
    conversion. You might have a look into casto as well.

  • Display Record Based on Combo Box Selection

    Hi
    Using Flash Builder 4.6.
    I have a combo box that lists names stored in a mysql database. Once the user selects a name from the combo box, I would like to have the complete record display on a form.  Can you please point me in the right direction to accomplish this task?
    Thanks

    Hi
    Using Flash Builder 4.6.
    I have a combo box that lists names stored in a mysql database. Once the user selects a name from the combo box, I would like to have the complete record display on a form.  Can you please point me in the right direction to accomplish this task?
    Thanks

  • How to programatically display text in combo box?

    Is there a way to programatically display text in a combo box.  I would like to display the word "Select" in the combo box each time my program starts.  As it is now, my combo box displays the last string that was selected the last time the program ran.
    Thanks in advance.
    Solved!
    Go to Solution.

    Actually, after actually reading your post...
    Jim
    You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice

  • I need help adding a blank line to a Combo Box

    I am recieving data from a database and displaying that in a
    combo box with coldfusion/flash. The problem is I cannot figure out
    how to add a blank line in flash so there is not a selected value
    by default. If I do this:
    DataGlue.bindFormatStrings(box1, getProcessIFC_re.result,
    "#label#", "#data#");
    Then there is a value by default...the first record in the
    query is selected. I tried this:
    box1.addItemAt(0, {data:"0", label:""});
    box1.selectedIndex = 0;
    That works but put an "undefined "label as the top and
    selected value.
    So how can I add a blank value or other value of my choice
    that is not labeled "undefined"?
    Thanks for any help

    the 'usual supects' offer pic-in-pic plug-ins for iM4 ...
    imovieplugins.com
    geethree.com
    stupendous-software.com ...
    or, use goo' ol' QTpro to apply watermarks and bugs... here's an illustrated how-to on my site:
    http://karsten.schluter.googlepages.com/watermark
    .. iM08 offers a simple 'on top' feature, when importing tiff/png file with tranparency/alpha channels..
    or, consider the Big Toy, *FinalCut Express.*. which offers zillions of effects..

  • How to compare value of two Combo Box

    I've two Combo Box(cbFirst & cbSecond). I want to compare the value that has been selected by the user and based on the result, output is displayed. In both Combo Box I've provided the value.
    Here is my code:
    var a:Number;
    var b:Number;
    function First(evt:Event):void{
        a = evt.target.value;
        trace(a);   
    cbFirst.addEventListener(Event.CHANGE, First);
    function Second(evt:Event):void{
        b = evt.target.value;
        trace(b);
    cbSecond.addEventListener(Event.CHANGE, Second);
    If (a > b){
         trace("a is greater")
    else
         trace(b is greater);
    The trace statement inside the functions are working fine and the correct value of a & b is printed. But the comparison in the if statement doesn't seem to work. Could you please help me out.

    there's a typo.  fix it or remove it:
    var a:Number;
    var b:Number;
    function First(evt:Event):void{
        a = evt.target.value;
    trace(a);
       compareF();
    cbFirst.addEventListener(Event.CHANGE, First);
    function Second(evt:Event):void{
        b = evt.target.value;
        trace(b);
    compareF()
    cbSecond.addEventListener(Event.CHANGE, Second);
    function compareF(){
    If (a > b){
         trace("a is greater")
    else
         trace(b is greater);

  • How can I make the combo box turn to the value of black.

    When the show button is pressed (and not before), a filled black square should be
    displayed in the display area. The combo box (or drop down list) that enables the user to choose the colour of
    the displayed shape and the altering should take effect immediately.When the show button is pressed,
    the image should immediately revert to the black square, the combo box should show the value that
    correspond to the black.
    Now ,the problem is: after I pressed show button, the image is reverted to the black square,but I don't know
    how can I make the combo box turn to the value of black.
    Any help or hint?Thanks a lot!
    coding 1.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class test extends JFrame {
         private JPanel buttonPanel;
         private DrawPanel myPanel;
         private JButton showButton;
         private JComboBox colorComboBox;
    private boolean isShow;
         private int shape;
         private boolean isFill=true;
    private String colorNames[] = {"black", "blue", "cyan", "darkGray", "gray",
    "green", "lightgray", "magenta", "orange",
    "pink", "red", "white", "yellow"}; // color names list in ComboBox
    private Color colors[] = {Color.black, Color.blue, Color.cyan, Color.darkGray,
                              Color.gray, Color.green, Color.lightGray, Color.magenta,
                              Color.orange, Color.pink, Color.red, Color.white, Color.yellow};
         public test() {
         super("Draw Shapes");
         // creat custom drawing panel
    myPanel = new DrawPanel(); // instantiate a DrawPanel object
    myPanel.setBackground(Color.white);
         // set up showButton
    // register an event handler for showButton's ActionEvent
    showButton = new JButton ("show");
         showButton.addActionListener(
              // anonymous inner class to handle showButton events
         new ActionListener() {
                   // draw a black filled square shape after clicking showButton
         public void actionPerformed (ActionEvent event) {
                             // call DrawPanel method setShowStatus and pass an parameter
              // to decide if show the shape
         myPanel.setShowStatus(true);
                   isShow = myPanel.getShowStatus();
                                            shape = DrawPanel.SQUARE;
                        // call DrawPanel method setShape to indicate shape to draw
                                            myPanel.setShape(shape);
                        // call DrawPanel method setFill to indicate to draw a filled shape
                                            myPanel.setFill(true);
                        // call DrawPanel method draw
                                            myPanel.draw();
                             myPanel.setFill(true);
                             myPanel.setForeground(Color.black);
                   }// end anonymous inner class
         );// end call to addActionListener
    // set up colorComboBox
    // register event handlers for colorComboBox's ItemEvent
    colorComboBox = new JComboBox(colorNames);
    colorComboBox.setMaximumRowCount(5);
    colorComboBox.addItemListener(
         // anonymous inner class to handle colorComboBox events
         new ItemListener() {
         // select shape's color
         public void itemStateChanged(ItemEvent event) {
         if(event.getStateChange() == ItemEvent.SELECTED)
         // call DrawPanel method setForeground
         // and pass an element value of colors array
         myPanel.setForeground(colors[colorComboBox.getSelectedIndex()]);
    myPanel.draw();
    }// end anonymous inner class
    ); // end call to addItemListener
    // set up panel containing buttons
         buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(4, 1, 0, 50));
         buttonPanel.add(showButton);
    buttonPanel.add(colorComboBox);
    JPanel radioButtonPanel = new JPanel();
    radioButtonPanel.setLayout(new GridLayout(2, 1, 0, 20));
    Container container = getContentPane();
    container.setLayout(new BorderLayout(10,10));
    container.add(myPanel, BorderLayout.CENTER);
         container.add(buttonPanel, BorderLayout.EAST);
    setSize(500, 400);
         setVisible(true);
         public static void main(String args[]) {
         test application = new test();
         application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    coding 2
    import java.awt.*;
    import javax.swing.*;
    public class DrawPanel extends JPanel {
         public final static int CIRCLE = 1, SQUARE = 2;
         private int shape;
         private boolean fill;
         private boolean showStatus;
    private int shapeSize = 100;
    private Color foreground;
         // draw a specified shape
    public void paintComponent (Graphics g){
              super.paintComponent(g);
              // find center
    int x=(getSize().width-shapeSize)/2;
              int y=(getSize().height-shapeSize)/2;
              if (shape == CIRCLE) {
         if (fill == true){
         g.setColor(foreground);
              g.fillOval(x, y, shapeSize, shapeSize);
    else{
                   g.setColor(foreground);
    g.drawOval(x, y, shapeSize, shapeSize);
              else if (shape == SQUARE){
         if (fill == true){
         g.setColor(foreground);
                        g.fillRect(x, y, shapeSize, shapeSize);
    else{
                        g.setColor(foreground);
    g.drawRect(x, y, shapeSize, shapeSize);
    // set showStatus value
    public void setShowStatus (boolean s) {
              showStatus = s;
         // return showstatus value
    public boolean getShowStatus () {
              return showStatus;
         // set fill value
    public void setFill(boolean isFill) {
              fill = isFill;
         // set shape value
    public void setShape(int shapeToDraw) {
              shape = shapeToDraw;
    // set shapeSize value
    public void setShapeSize(int newShapeSize) {
              shapeSize = newShapeSize;
    // set foreground value
    public void setForeground(Color newColor) {
              foreground = newColor;
         // repaint DrawPanel
    public void draw (){
              if(showStatus == true)
              repaint();

    Hello,
    does setSelectedIndex(int anIndex)
    do what you need?
    See Java Doc for JComboBox.

  • How to fetch records from the database into a combo box?

    Hi:
    I&acute;m really new with ABLBPM and I&acute;m trying to fetch records from the database to display them into a combo box as valid values for a presentation but I&acute;m using a dynamic method with this code:
    <em>for each row in SELECT campo1, campo2 from TABLE</em>
    <em>do</em>
    <em>solicitudes[] = [row.campo1, row.campo2]</em>
    <em>end</em>
    <em>return solicitudes
    </em>And the debugger says that SQL instructions can be used only in fuctions and procedures that are executed on the server.
    Do you know another way to do it?
    P.D. Sorry for my terrible english
    Greetings

    Hi Steve,
    Thank you, your idea is perfect, but when I try to run the screenflow where the combo should be filled I get this error:
    fuego.lang.ComponentExecutionException: No se ha podido ejecutar correctamente la tarea.
    Motivo: 'java.lang.NullPointerException'.
         at fuego.web.execution.InteractiveExecution.setExecutionError(InteractiveExecution.java:307)
         at fuego.web.execution.InteractiveExecution.process(InteractiveExecution.java:166)
         at fuego.web.execution.impl.WebInteractiveExecution.process(WebInteractiveExecution.java:54)
         at fuego.webdebugger.servlet.DebuggerServlet.redirect(DebuggerServlet.java:136)
         at fuego.webdebugger.servlet.DebuggerServlet.doPost(DebuggerServlet.java:85)
         at fuego.webdebugger.servlet.DebuggerServlet.doGet(DebuggerServlet.java:66)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
         at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
         at fuego.web.execution.servlet.ServletExternalContext.forwardInternal(ServletExternalContext.java:197)
         at fuego.web.execution.servlet.ServletExternalContext.processAction(ServletExternalContext.java:110)
         at fuego.webdebugger.servlet.DebuggerExecution.dispatchComponentExecution(DebuggerExecution.java:64)
         at fuego.web.execution.InteractiveExecution.invokePrepare(InteractiveExecution.java:351)
         at fuego.web.execution.InteractiveExecution.process(InteractiveExecution.java:192)
         at fuego.web.execution.impl.WebInteractiveExecution.process(WebInteractiveExecution.java:54)
         at fuego.web.execution.InteractiveExecution.process(InteractiveExecution.java:223)
         at fuego.webdebugger.servlet.DebuggerServlet.doDebug(DebuggerServlet.java:148)
         at fuego.webdebugger.servlet.DebuggerServlet.doPost(DebuggerServlet.java:82)
         at fuego.webdebugger.servlet.DebuggerServlet.doGet(DebuggerServlet.java:66)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    Any ideas??
    Thanks and greetings

  • How to set current year,month as default value in combo box

    hi,  im newbie of xcelsius user
    i realize  that hv a issue that display combo box base on year & month
    let said
    <b><u>step 1</u></b>
    I create excel data like this
    <b><u>year___ </u>  </b>    |     <u><b>month_   </b></u> |     <u><b>Product</b></u> |     <u><b>revenue</b></u>
    02-04-09 |     02-04-09 |       a |     $4,154
    03-04-09 |     03-04-09 |       b |     $6,813
    04-05-09 |     04-05-09 |       a |     $9,875
    05-06-09 |     05-06-09 |       b |     $6,813
    06-04-10 |     06-04-10 |       a |     $6,813
    07-04-10 |     07-04-10 |       b |     $9,875
    08-06-10 |     08-06-10 |       a |     $9,875
    22-06-10 |     22-06-10 |       b |     $6,813
    <u><b>Step2</b></u>
    Then i go format cell to format/custom date to year & month
    Eg1: Year u2013>  02-04-09  convert to u2018YYYYu2019 (2009)
    Eg2: Month u2013>  02-04-09  convert to u2018mmmmu2019 (April)
    So output like this
    <u><b>year</b></u> |     <u><b>month</b></u> |     <u><b>Product</b></u> |     <u><b>revenue </b></u>
    2009 |     April |     a |     $4,154
    2009 |     April |     b |     $6,813
    2009 |     May |     a |     $9,875
    2009 |     June |     b |     $6,813
    2010 |     April |     a |     $6,813
    2010 |     April |     b |      $9,875
    2010 |     June |     a |     $9,875
    2010 |     June |     b |     $6,813
    But the problem is when i insert to combo box,use u201Cfilter Row u201D, i excpectation will display only 2009,2010
    But Actual display the Year  in combo box is duplicated :'(
    so any solution ? and then only how to set current year & month as default value  :'(
    thanks,
    regards
    s1
    Edited by: Leong Pui Kee on Feb 25, 2011 5:25 AM
    Edited by: Leong Pui Kee on Feb 25, 2011 5:36 AM

    hi,
    your created  data
    step 1
    I create excel data like this
    year___ | month_ | Product | revenue
    02-04-09 | 02-04-09 | a | $4,154
    03-04-09 | 03-04-09 | b | $6,813
    04-05-09 | 04-05-09 | a | $9,875
    05-06-09 | 05-06-09 | b | $6,813
    06-04-10 | 06-04-10 | a | $6,813
    07-04-10 | 07-04-10 | b | $9,875
    08-06-10 | 08-06-10 | a | $9,875
    22-06-10 | 22-06-10 | b | $6,813
    In this, year and month both are same data, make the diffent data like year  2009, 2010  And month Jan, Feb, March, ...Etc 
    and also one more check you formulas on month and year, select correct source data, destination data  for compoonent..
    OR
    from above, to create a date column and convert  date-->year, date--> month and Explore it.
    All the best,
    Praveen

  • Using IO to create a Combo Box

    Hello,
    I have failed to find any examples on how to do the following, and have not yet figured out how to do it msyelf.
    I want to add the entire contents of a file containg a list of people's personal numbers and their names to a combo box that is then added to the frame.
    Here is the code: -
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import java.util.*;
    public class IOCombo extends JFrame
    implements ActionListener {
    public JButton b1;
    public JPanel panel, panel_top, panel_office;
    public JFrame frame;
    public JLabel officeLabel, personLabel, buttonWorkedLabel;
    String OfficeChosen;
    String[] Office = {"London", "Paris", "NYC"};
    String[] OfficeList;
    int[] personalNumber;
    public IOCombo() {
    frame = new JFrame("IOCombo Test");
    panel_top = new JPanel();
    panel_office = new JPanel();
    panel = new JPanel();
    officeLabel = new JLabel("The Office is in ");
    personLabel = new JLabel(".");
    buttonWorkedLabel = new JLabel(".");
    // Exit when the window is closed.
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    b1 = new JButton("Office");
    b1.setVerticalTextPosition(AbstractButton.CENTER);
    b1.setHorizontalTextPosition(AbstractButton.LEFT);
    b1.setMnemonic(KeyEvent.VK_O);
    //Listen for actions
    b1.addActionListener(this);
    //tooltips for buttons
    b1.setToolTipText("Choose an Office and a person and then click to edit that Office's Person.");
    JComboBox office = new JComboBox(Office);
    office.setSelectedIndex(0);
         office.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         JComboBox cb = (JComboBox)e.getSource();
         OfficeChosen = (String)cb.getSelectedItem();
    try
    whichOffice(OfficeChosen);
    catch(IOException ex)
    //set layout of all panels and add them to frame.
    panel_office.add(officeLabel);
    panel_office.add(office);
    panel_office.add(personLabel);
    panel_top.setLayout(new FlowLayout());
    panel_top.add(b1);
    panel_top.add(buttonWorkedLabel);
         panel.setLayout(new GridLayout(3,0));
    panel.add(panel_office);
    panel.add(panel_top);
    frame.getContentPane().add(panel);
    frame.pack();
    frame.setVisible(true);
    public void actionPerformed(ActionEvent e) {
    String buttonPressed = e.getActionCommand();
    if (buttonPressed.equals("Office"))
    /**This is just a test, removed the Dialog class to
    manipulate the office*/
    buttonWorkedLabel.setText("Worked");
    else {
    /** How do I set-up the combo box using the Office Person chosen from the
    file and allocate it to the frame?*/
    public void whichOffice(String OfficeChos)throws IOException{
    officeLabel.setText("The Office chosen is: " + OfficeChos);
    String s, name ="";
    int personalNum;
    BufferedReader fr = null;
    fr = new BufferedReader(new FileReader (OfficeChos+".txt"));
    while ((s=fr.readLine()) != null)
    StringTokenizer st = new StringTokenizer (s," ");
    personalNum = Integer.parseInt(st.nextToken());
    st.nextToken();
    name = st.nextToken() + " " + st.nextToken();
    personLabel.setText(personalNum + " " + name);
    /** This method only works if the file contains person
    how should I change this to read everyone in?
    I want to add the entire contents of personal number and name
    of the file to a combo box that is then added to the frame.
    public static void main(String[] args) {
    IOCombo iocombo = new IOCombo();
    The file I have set-up currently that works is called "London.txt" and it contains: -
    1 = John Smith
    Cheers in advance,
    Richard.

    Hi,
    Sorry I cannot get the code you provided to work, not sure if its your code or the ways I have tried to implement it. Please can you check into it and if it works give the completed code.
    Reprovided code with formating :-)
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import java.util.*;
    public class IOCombo extends JFrame
                            implements ActionListener {
        public JButton b1;
        public JPanel panel, panel_top, panel_office;
        public JFrame frame;
        public JLabel officeLabel, personLabel, buttonWorkedLabel;
        String OfficeChosen;
        String[] Office = {"London", "Paris", "NYC"};
        String[] OfficeList;
        int[] personalNumber;
        public IOCombo() {
            frame = new JFrame("IOCombo Test");
            panel_top = new JPanel();
            panel_office = new JPanel();
            panel = new JPanel();    
            officeLabel = new JLabel("The Office is in ");
            personLabel = new JLabel(".");
            buttonWorkedLabel = new JLabel(".");
    // Exit when the window is closed.
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            b1 = new JButton("Office");
            b1.setVerticalTextPosition(AbstractButton.CENTER);
            b1.setHorizontalTextPosition(AbstractButton.LEFT);
            b1.setMnemonic(KeyEvent.VK_O);
    //Listen for actions
            b1.addActionListener(this);
    //tooltips for buttons
            b1.setToolTipText("Choose an Office and a person and then click to edit that Office's Person.");
            JComboBox office = new JComboBox(Office);
            office.setSelectedIndex(0);
         office.addActionListener(new ActionListener() {
                 public void actionPerformed(ActionEvent e) {
                         JComboBox cb = (JComboBox)e.getSource();
                         OfficeChosen = (String)cb.getSelectedItem();
                            try
                                whichOffice(OfficeChosen);
                            catch(IOException ex)
    //set layout of all panels and add them to frame.
            panel_office.add(officeLabel);
            panel_office.add(office);
            panel_office.add(personLabel);
            panel_top.setLayout(new FlowLayout());
            panel_top.add(b1);
            panel_top.add(buttonWorkedLabel);
         panel.setLayout(new GridLayout(3,0));
            panel.add(panel_office);
            panel.add(panel_top);
            frame.getContentPane().add(panel);
            frame.pack();
            frame.setVisible(true);
        public void actionPerformed(ActionEvent e) {
            String buttonPressed = e.getActionCommand();
            if (buttonPressed.equals("Office"))
                    /**This is just a test, removed the Dialog class to
                     manipulate the office*/
                    buttonWorkedLabel.setText("Worked");
            else {
                /** How do I set-up the combo box using the Office Person chosen from the
                 file and allocate it to the frame?*/
        public void whichOffice(String OfficeChos)throws IOException{
            officeLabel.setText("The Office chosen is: " + OfficeChos);
            String s, name ="";
            int personalNum;
            BufferedReader fr = null;
            fr = new BufferedReader(new FileReader ("c:\\java\\kjc\\set\\"+OfficeChos+".txt"));
            while ((s=fr.readLine()) != null)
                    StringTokenizer st = new StringTokenizer (s," ");
                    personalNum = Integer.parseInt(st.nextToken());
                    st.nextToken();
                    name = st.nextToken() + "  " + st.nextToken();
                    personLabel.setText(personalNum + " " + name);
                    /** This method only works if the file contains person
                     how should I change this to read everyone in?
                     I want to add the entire contents of personal number and name
                     of the file to a combo box that is then added to the frame.
        public static void main(String[] args) {
            IOCombo iocombo = new IOCombo();
    }Cheers,
    Richard

  • Prob in retaining spaces in Combo Box, PLEASE HELP ASAP!!

    Hi
    In the application that I am working on, I have developed a screen wherein I populate the names of some schemes from the database, in a combo box (<Select><option></option></Select>).
    A particular scheme in the database has a multiple-word name with double spaces between the two words, or rather between the last of the two words and the brackets.
    e.g. Help CRY (Child Relief & You).
    Now, when this name is fetched fro the database, the double spaces between the CRY and ( are retained but when I display them in the combo box, i.e. between the <option> tags, somehow the double spaces disappear.
    Further on, in my servlet, I retrieve the same scheme name from the combo box and try to fetch some other entries from the database. At that point, since one of the spaces has disappeared, there is no database match found for the scheme name selected and I'm unable to proceed. This problem arises in the case of any number of spaces between the words while populating the combo box. It however works fine when I remove the double spaces and retain a single space between the words.
    Please let me know ASAP if combo boxes eat up such spaces and convert any number of spaces into a single space as a property or is something wrong with the JSP I have here. If this problem can never be resolved as a rule, then please tell me so that I can force the data providers to make sure they filter out such double spaces before sending the data to our databases.
    I'll be very grateful if your can help me out asap as we have to put up the site at the earliest possible date.
    Thanks a lot,
    Soumya

    why not you try to set the option value, like this:
    <option value="Help CRY (Child Relief & You)">words you wan display</option>
    Think if the display is not right it will not affect you from extracting the value.
    Regards,
    Jas

  • Combo Box  - Font on Closed

    Hi
    I changed the font using
    _global.styles.ComboBox.fontFamily = "AAA";
    where ASU is an embedded font
    The font displays correctly when the combo box is open but
    closed it still show the default _sans
    Anyone help on changing the display font when closed?
    Many thanks
    Mark

    Try this:
    import mx.styles.CSSStyleDeclaration;
    _global.styles.ComboBox = new CSSStyleDeclaration();
    _global.styles.ComboBox.setStyle("fontFamily","AAA");
    Tim

  • Error when populating combo box

    I tried to display my data in combo box from my access table but my combo box is empty. Here's my code:
    <% String temp="";     
         Connection conn = null;
         try
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              conn = DriverManager.getConnection("jdbc:odbc:admin_management");
              Statement stmt = conn.createStatement();
              ResultSet rs = stmt.executeQuery("SELECT Virtual_host_name FROM Server_Info");
    %>
    <select name="Server_available">
    <%
    while (rs.next()) {
    temp= rs.getString("Virtual_host_name"); %>
    <%System.out.println("<OPTION VALUE=" + temp + ">" + temp + "\n");%>
    <%}%>
    </select>
    <!-- HEADER STARTS HERE--->
    <%
         catch(SQLException e)
              //out.println("SQLException: " + e.getMessage() + "<BR>");
              while((e = e.getNextException()) != null)
              out.println(e.getMessage() + "<BR>");
         catch(ClassNotFoundException e)
              out.println("ClassNotFoundException: " + e.getMessage() + "<BR>");
         finally
              if(conn != null)
         try
              conn.close();
         catch (Exception ignored) {}
    %>
    Please help me asap. thanks!!

    Instead of "System.out.println" try using "out.println"

Maybe you are looking for

  • Can't see USB hd connected to airport extreme w/ iPad

    Plugged external hd in airport extreme but can not see using IPad .I have downloaded app for airport & can find airport but does not show hard drive. How can I access files on external hard drive?

  • I have not bought only one program only

    I have not bought only one program only It SSH Gath message from you it was reported that I bought three programs and this is not true This is the body of the message Or maybe pressed Balkhtae Can canceling Greetings, Billed To: Tamer Salama EGY Orde

  • Planning App Web Server changed.

    Hello gurús! I´m in a big issue. In my org, we have 3 physical servers with 3 servers installed: Essbase, Shared Services and Planning. The problem is that we cloned that servers to virtual machines to duplicate these servers. We want to reconfigure

  • New Demo Extension Pack available on OTN

    Forms Product Management are please to announce we have released a new Forms Demo extension pack. This included three demos to compliment the existing Forms demo suite. Go to http://otn.oracle.com/products/forms and click on the link in the news sect

  • Problem downloading additional softwares

    Hi everybody, When I try to download SAP Add-in for Crystal Reports 2011 the following message appears: Same problem with any other additional software or user. Does anyone know why? Thanks!