Results 1 to 3 of 3
  1. #1
    innovo is offline Member
    Join Date
    Jul 2015
    Posts
    84
    Rep Power
    0

    Default How to print string value from UI?

    Currently I have made a user interface to read a file, put the strings inside the file into the comboboxes and allow someone to select a value that they want and press "next".


    for my UI I have
    Java Code:
    private final CsvFileReader fileReader;
        
            
            
    
        mainWindow() throws FileNotFoundException {
            initComponents();
            fileReader = new CsvFileReader();
            jComboBox1.setModel(new DefaultComboBoxModel(fileReader.getBoxItems(BoxItems.GLASSING)));
            jComboBox2.setModel(new DefaultComboBoxModel(fileReader.getBoxItems(BoxItems.LOTNUM)));
            jComboBox3.setModel(new DefaultComboBoxModel(fileReader.getBoxItems(BoxItems.TANTALUM)));
            jComboBox4.setModel(new DefaultComboBoxModel(fileReader.getBoxItems(BoxItems.ANODE)));
            jComboBox5.setModel(new DefaultComboBoxModel(fileReader.getBoxItems(BoxItems.ANODE)));
            jComboBox6.setModel(new DefaultComboBoxModel(fileReader.getBoxItems(BoxItems.ANODE)));
            jComboBox7.setModel(new DefaultComboBoxModel(fileReader.getBoxItems(BoxItems.ANODE)));
            jComboBox8.setModel(new DefaultComboBoxModel(fileReader.getBoxItems(BoxItems.ANODE)));
            jComboBox9.setModel(new DefaultComboBoxModel(fileReader.getBoxItems(BoxItems.CATHODE)));
        }
    Each of these box items correspond to a string in the file.

    I can read what I want, now I'm trying to figure out how to write the selected values to a file. In order to do that though I need to understand how to print the values selected in the combobox.

    currently for one of the comboboxes I have
    Java Code:
     private void jComboBox4ActionPerformed(java.awt.event.ActionEvent evt) {                                           
      BoxItems.ANODE.getText(); 
      System.out.println(BoxItems.ANODE);// TODO add your handling code here:
        }

    For example, I want to select "anode 1" in a combobox.
    What I'm trying to do is use getText in order to be able to print the selected value into the console, that way I know that it's reading the string and it can be printed.
    It seems simple enough but I don't understand the syntax of how to go about doing this. Do any of you have any suggestions or examples?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

    Default Re: How to print string value from UI?

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

    Default Re: How to print string value from UI?

    Also, ditch the UI designer/code generator until you understand Java well enough to immediately replace the meaningless variable and method names it creates.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Pls help to print string in given format
    By know.how in forum New To Java
    Replies: 2
    Last Post: 08-31-2011, 01:43 PM
  2. using for-loop to print out a string
    By baumboards in forum New To Java
    Replies: 27
    Last Post: 03-17-2011, 04:47 PM
  3. Replies: 3
    Last Post: 02-03-2011, 10:19 PM
  4. Print String from an Array
    By adityasirohi in forum New To Java
    Replies: 2
    Last Post: 02-18-2010, 04:10 PM
  5. I can only print string literals
    By leeavital in forum New To Java
    Replies: 1
    Last Post: 12-11-2009, 01: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
  •