How to use drop down menu in JTables

Hi, i'm trying to add an drop down menu to my jtable so that people can select a set number of texts from an enum type. How can this be accomplished?
My current Code: /**
* Bill Huang
* Started: Nov 07, 2007
* Dossier
package packageSolo;
import javax.swing.*;
import java.awt.*;
public class SpreadSheetGUI extends JPanel{
     private void debug(int x){
          //System.out.println(x);
     protected static Object[][] data;
     protected static int classroomAmount = 0;
     protected static JTable jtable;
     protected static String[] columnNames = { "Class Room Number", "Period One", "Period Two", "Period Three", "Period Four" };
     public SpreadSheetGUI(){
          super(new GridLayout(1,0));
          String input;
          int flag2 = 0;
          int flag4 = 0;
          int flag5 = 0;
          int flag8 = 0;
          input = JOptionPane
                    .showInputDialog("How many classrooms are there?");
           * see if the user wantes to quit at this point
          if (input == null) {
               debug(4);
               int exitint = 0;
               exitint = JOptionPane.showConfirmDialog(null,
                         "Do you want to exit?", "Exit?",
                         JOptionPane.OK_CANCEL_OPTION);
               if (exitint == 0) {
                    try {
                         System.exit(1);
                    } catch (SecurityException eb) {
                         System.out.println("exit");
          while (flag4 == 0) {
                * this while loop with flag2 is for checking if the thing is of int
                * class
               while (flag2 == 0) {
                     * try to get a integer, check for a bad input class
                    try {
                          * parse, and if success set flag2 to 1 and break out this
                          * while loop
                         classroomAmount = Integer.parseInt(input);
                         flag2 = 1;
                         debug(2);
                    } catch (NumberFormatException ec) {
                         debug(3);
                          * ops user input was not a integer class
                         JOptionPane
                                   .showMessageDialog(null,
                                             "Enter a positive integer only",
                                             "Number Format is Wrong",
                                             JOptionPane.ERROR_MESSAGE);
                         input = JOptionPane
                                   .showInputDialog("How many months are there?");
                          * see if the user wantes to quit at this point
                         if (input == null) {
                              debug(4);
                              int exitint = 0;
                              exitint = JOptionPane.showConfirmDialog(null,
                                        "Do you want to exit?", "Exit?",
                                        JOptionPane.OK_CANCEL_OPTION);
                              if (exitint == 0) {
                                   try {
                                        System.exit(1);
                                   } catch (SecurityException eb) {
                                        System.out.println("exit");
                * this while loop sees if the integer is smaller than 0 so the
                * array cannot be a real one
               while (flag5 == 0) {
                    // numamountint = Integer.parseInt(numamount);
                    if (classroomAmount < 0 || classroomAmount > 12) {
                         debug(5);
                         JOptionPane
                                   .showMessageDialog(null,
                                             "Enter a positive integer that is smaller than 12",
                                             "Number Format/Size is Wrong",
                                             JOptionPane.ERROR_MESSAGE);
                         input = JOptionPane
                                   .showInputDialog("How many months are there?");
                         if (input == null) {
                              int exitint = 0;
                              exitint = JOptionPane.showConfirmDialog(null,
                                        "Do you want to exit?", "Exit?",
                                        JOptionPane.OK_CANCEL_OPTION);
                              if (exitint == 0) {
                                   try {
                                        System.exit(1);
                                   } catch (SecurityException eb) {
                                        System.out.println("exit");
                          * this while loop check for number format again
                         while (flag8 == 0) {
                              try {
                                   debug(6);
                                   classroomAmount = Integer.parseInt(input);
                                   flag8 = 1;
                              } catch (NumberFormatException ec) {
                                   debug(7);
                                   JOptionPane.showMessageDialog(null,
                                             "Enter a positive integer only",
                                             "Number Format is Wrong",
                                             JOptionPane.ERROR_MESSAGE);
                                   input = JOptionPane
                                             .showInputDialog("How many months are there?");
                                   if (input == null) {
                                        int exitint = 0;
                                        exitint = JOptionPane.showConfirmDialog(null,
                                                  "Do you want to exit?", "Exit?",
                                                  JOptionPane.OK_CANCEL_OPTION);
                                        if (exitint == 0) {
                                             try {
                                                  System.exit(1);
                                             } catch (SecurityException eb) {
                                                  System.out.println("exit");
                    } else {
                          * here the input is greater than 0 so it sets flag5 and 4
                          * then break out of the while loops
                         debug(8);
                         flag5 = 1;
                         flag4 = 1;
          data = new String[classroomAmount][5];
          jtable = new JTable(data, columnNames);
          jtable.setPreferredScrollableViewportSize(new Dimension(800, 600));
          JScrollPane scrollPane = new JScrollPane(jtable);
          this.add(scrollPane);
          this.show();
}

        Object[] possibilities = {"1", "2", "3"};
        input = (String) JOptionPane.showInputDialog(null,
                "Please choose the number of classrooms:",
                "How many classrooms are there?",
                JOptionPane.PLAIN_MESSAGE,
                null, possibilities, "1");Edited by: Andre_Uhres on Nov 8, 2007 8:22 AM
I thought you need a combo for JTable row set. Seems I misunderstood.
See next posting.

Similar Messages

  • How to create Drop down menu in the selection screen

    Hi all,
    How to create Drop down menu in the selection screen.
    Fast answer will be highly rewarded
    Regards
    Bikas

    hi ,
    TYPE-POOLS : vrm.
    TABLES:vbak,vbap.
    DATA : v(80) TYPE c.
    DATA: wa_vbak TYPE vbak,
          it_vbak TYPE vbak OCCURS 0 WITH HEADER LINE,
          wa_vbap TYPE vbap,
          it_vbap TYPE vbap OCCURS 0 WITH HEADER LINE.
      DATA: l_name TYPE vrm_id,
            li_list TYPE vrm_values ,
            v_count  TYPE i,
            l_value LIKE LINE OF li_list.
    PARAMETERS: p_test(20) AS LISTBOX VISIBLE LENGTH 60 MODIF ID DAT.
    INITIALIZATION.
    AT SELECTION-SCREEN OUTPUT.
      PERFORM get_data.
      LOOP AT it_vbak.
        l_value-key =  it_vbak-vbeln .
        l_value-text = it_vbak-vbeln .
        APPEND l_value TO li_list.
      ENDLOOP.
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          id              = 'P_TEST'
          values          = li_list
        EXCEPTIONS
          id_illegal_name = 1
          OTHERS          = 2.
    AT SELECTION-SCREEN ON P_TEST.
      clear : li_list , li_list[].
      SELECT vbeln
             matnr
             meins
             FROM vbap
             INTO CORRESPONDING FIELDS OF TABLE it_vbap
             WHERE vbeln = p_test.
    START-OF-SELECTION.
      SELECT vbeln
             matnr
             meins
             FROM vbap
             INTO CORRESPONDING FIELDS OF TABLE it_vbap
             WHERE vbeln = p_test.
      LOOP AT it_vbap.
        WRITE :/ it_vbap-vbeln, it_vbap-matnr,it_vbap-meins.
      ENDLOOP.
    *&      Form  get_Data
          text
    -->  p1        text
    <--  p2        text
    FORM get_data .
      SELECT  vbeln
              FROM vbak
              INTO  CORRESPONDING FIELDS OF TABLE it_vbak.
    ENDFORM.                    " get_Data
    regards,
    venkat.

  • How To Create Drop Down Menu With Tab

    hi
    How To create Drop Down Menu with tab in Header of application like website Horizontal Dropdown Menu In html.
    Thanks
    Manoj
    Edited by: Manoj Kaushik on Dec 30, 2009 4:16 AM

    Try the Apex forum {forum:id=137} someone there may have an answer.
    Which version, that could be important, XE out-of-the-box has apex 2.1 if it hasn't been upgraded to 3.x

  • How to export drop down menu to DW??

    Hi all,
    I am have just created a drop down menu in Fireworks and
    wanted to export it to my website to update the menu.
    Now, I have saved the button files in my rootfolder. When I
    go there from DW/ Insert Image objects/ rollover button (its a
    rollover), I see the following files that I created from Fireworks:
    registration-nor.gif
    then I have a whole lot of
    registration-over_f6.gif
    (corresponding to the amount of frames I have in my roll over
    button)
    I also got
    mm_css_menu.js
    and
    registration-over.htm
    and
    registration-over.css
    Now, the above is a whole bunch of different files, and I
    cant seem to figure out how to put them in the right place or
    swhich file to choose for where, in order to get my drop down menu
    to work>
    Please help me, and tips would be highly appreciated!
    Cheers!
    Text
    Text
    Text

    You really want help? Don't use these menus. They are pretty
    poorly
    implemented and will be a bear to maintain. There are much
    better ways -
    some free and some commercial:
    Check the uberlink and MacFly tutorials at PVII
    http://www.projectseven.com/)
    and the Navbar tutorial/articles at Thierry's place
    http://tjkdesign.com/articles/dropdown/)
    Or this one (more recent article):
    http://tjkdesign.com/articles/Pure_CSS_Dropdown_Menus.asp)
    Or to get it done fast, go here -
    http://www.projectseven.com/tutorials/navigation/auto_hide/index.htm
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Horst1881" <[email protected]> wrote in
    message
    news:ek1242$s6p$[email protected]..
    > Hi all,
    > I am have just created a drop down menu in Fireworks and
    wanted to export
    > it
    > to my website to update the menu.
    >
    > Now, I have saved the button files in my rootfolder.
    When I go there from
    > DW/
    > Insert Image objects/ rollover button (its a rollover),
    I see the
    > following
    > files that I created from Fireworks:
    >
    > registration-nor.gif
    > then I have a whole lot of
    > registration-over_f6.gif
    > (corresponding to the amount of frames I have in my roll
    over button)
    >
    > I also got
    > mm_css_menu.js
    >
    > and
    > registration-over.htm
    >
    > and
    > registration-over.css
    >
    > Now, the above is a whole bunch of different files, and
    I cant seem to
    > figure
    > out how to put them in the right place or swhich file to
    choose for where,
    > in
    > order to get my drop down menu to work>
    >
    > Please help me, and tips would be highly appreciated!
    >
    > Cheers!
    >
    >
    >
    Text
    Text
    Text
    >

  • How to automate Drop Down menu in OpenScript

    Hello Team,
    Can someone help me in automating a drop down menu? The following is what I'm trying to achieve
    For iteration 1 the first value from the drop down menu should be selected, continue rest of the task as per the initial record
    for iteration 2 the second value from the drop down menu should be selected.. and so on till all the values in the drop down are selected.
    I guess we should use for loop? I tried most of the option as per the user guide but unfortunately I wasn't able to crack it :( can some one tell me what to do from the Tree view of the openscript? Alex (guru) can you please throw some light on this :)
    N.B: I was able to make a field data driven!
    Thanks

    Hello,
    Thanks for your reply, please find the drop down box record script. From the below you can see first I selected Accounting from the drop down & then later i selected Administration..similarly if i want to select all the values from the drop down what do i need to do? Do i add a for loop? if yes where do i add them from the Tree view & how. I somehow can't understand the user guide. Or maybe Im not thinking right! Kindly help. I have figured out how to run data driven test from an input file, however in this case I can't possibly add all the values from the drop down in an input file also that approach isn't healthy!
                   web
                             .selectBox(
                                       5,
                                       "/web:window[@index='0' or @title='SEEK - Australia&apos;s no. 1 jobs, employment, career and recruitment site - Microsoft Internet Explorer']/web:document[@index='0']/web:form[@id='layout' or @name='layout' or @index='0']/web:select[(@id='catindustry' or @name='catindustry' or @index='0') and multiple mod 'False']")
                             .selectOptionByText("Accounting");
                             .selectBox(
                                       16,
                                       "/web:window[@index='0' or @title='SEEK - Australia&apos;s no. 1 jobs, employment, career and recruitment site - Microsoft Internet Explorer']/web:document[@index='0']/web:form[@id='layout' or @name='layout' or @index='0']/web:select[(@id='catindustry' or @name='catindustry' or @index='0') and multiple mod 'False']")
                             .selectOptionByText("Administration");

  • How to put drop down menu over iframe?

    I created drop down menu in A-Master with height 100 pixels.
    On a page which uses A-Master template I've put youtube video, example:
    <iframe width="1000" height="500" src="//www.youtube.com/embed/8eDuupJ9Uus" frameborder="0" allowfullscreen></iframe>
    and when I export HTML, Iframe video is over dropdown menu so I can't see this menu, iframe is on top of it, how can I place dropdown menu on top of this iframe?
    Tried to search whole internet with no good results, I have only found other people has same problem.
    ...and I have tried this "wmode="transparent" too:
    <iframe width="560" height="349"src="http://www.youtube.com/embed/rLVCjnEGrqQ?wmode=transparent"frameborder="0" allowfullscreen wmode="transparent"></iframe>
    was no good

    Your menu layer should be on top of everything!
    Regards,
    Frank

  • How to configure drop down menu in custom list

    Hi,
    I want to create custom list with 3 options. Active, Proposal and Completed. How can I create drop down menu like this (look at picture). 

    Hi,
    According to your post, my understanding is that you wanted to configure drop down menu in custom list.
    I suggest to modify the view to group by Preposition Status.
    You can follow the steps as below:
    Create list, add choice column named Preposition Status.
    Add items.
    Modify the view as below:
    Then the result is as below:
    Thank you for your understanding.
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • How to create drop down menu in my report

    hi all
    i have a list of options which i have to display as a drop down menu
    pls guide me to do
    thanks in advance

    hi,
    u want like this?
    parameters: p_mode as listbox visible length 10.
    parameters: p_mode1 as listbox visible length 10.
    AT SELECTION-SCREEN OUTPUT.
      PERFORM fill_dropdown_list USING 'p_mode'(001).
      PERFORM fill_dropdown_list1 USING 'p_mode1'(007).
    FORM fill_dropdown_list USING value(f_parameter).
      TYPE-POOLS: vrm. " For parameter drop down lists
      DATA:  name  TYPE vrm_id,
               list  TYPE vrm_values,
               value LIKE LINE OF list.
      name = f_parameter.
      value-key = 'C'.
      value-text = 'Fist'.
      APPEND value TO list.
      value-key = 'F'.
      value-text = 'Second'.
      APPEND value TO list.
      value-key = 'H'.
      value-text = 'Third'.
      APPEND value TO list.
      value-key = 'D'.
      value-text = 'Forth'.
      APPEND value TO list.
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          id     = name
          values = list.
    ENDFORM.                       " fill_dropdown_list
    FORM fill_dropdown_list1 USING value(f_parameter).
      TYPE-POOLS: vrm. " For parameter drop down lists
      DATA:  name  TYPE vrm_id,
               list  TYPE vrm_values,
               value LIKE LINE OF list.
      name = f_parameter.
      value-key = 'C'.
      value-text = 'Fist'.
      APPEND value TO list.
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          id     = name
          values = list.
    ENDFORM.                       " fill_dropdown_list

  • How to have drop down menu in which we cant continue until selection is made

    Hi All,
    I have a case in which I have 4 drop down menu, and a continue button, I want to make sure that a user cant continue until selection is been made on all the four or atleast from some of the drop down menu. how can I do that.
    Solved!
    Go to Solution.
    Attachments:
    selection.vi ‏20 KB

    I believe what Norbert was suggesting is something like this:
    With this code the "Continue button will be disabled and greyed untill a value change event has been registered on each of the four I32 controls.  Note also that its always OK to Cancel (and the windows X is active so you won't anger your users)  The caller should decide what to do if Canceled? is TRUE.
    Modify as desired!  the Attachment is saved back to 2012
    You can safely delete the case structure.... 
    Its a hold over from my VIT 
    Jeff
    Attachments:
    Simple UI (Events) 1.vi.vi ‏31 KB

  • Can't use drop-down menu

    the OS of my laptop is windows 8. the drop-down menu does not stay open. my anti-malware program cannot open.

    '''[https://support.mozilla.org/en-US/kb/troubleshoot-firefox-issues-using-safe-mode Start Firefox in Safe Mode]''' {web link}
    While you are in safe mode;
    Press the '''Alt''' or '''F10''' key to bring up the tool bar.
    Followed by;
    Windows; '''Tools > Options'''
    Linux; '''Edit > Preferences'''
    Mac; ''application name'' '''> Preferences'''
    Then '''Advanced > General.'''
    Look for and turn off '''Use Hardware Acceleration'''.
    Poke around safe web sites. Are there any problems?
    Then restart.

  • How to change drop down menu size

    Hello,
    I have a drop down menu, by default, i can only see one value from the drop down list, i want to see all of them(4 values). Where to put size =4?
    I am using APEX 4.
    Thanks for your help.
    Jen

    Jen Hu wrote:
    Hello,
    I have a drop down menu, by default, i can only see one value from the drop down list, i want to see all of them(4 values). Where to put size =4?
    I am using APEX 4.
    Thanks for your help.
    JenDon't open duplicate threads! try the solution posted in the other thread {message:id=10907927} and close the threads.

  • How to get drop down menu

    hai plz help me
    how to dovelop a drop down menu for a field in selection screen

    Hi
    Hope it will help you.
    Pls reward if help.
    REPORT zwa_test2.
    TYPE-POOLS : vrm.
    tables: bkpf.
    DATA : values TYPE vrm_values.
    DATA : wa LIKE LINE OF values.
    PARAMETERS : list_box(10) TYPE c AS LISTBOX VISIBLE LENGTH 10.
    PARAMETERS: dd type bkpf-BSTAT user-command abc.
    select-options: a for bkpf-bukrs MODIF ID buk.
    select-options: b for bkpf-belnr MODIF ID SEL.
    at selection-screen output.
      If list_box = 2.
        loop at screen.
          if screen-group1 = 'SEL'.
            screen-input = 0.
            modify screen.
          endif.
         endloop.
       endif.
    INITIALIZATION.
      wa-key = '1'.
      wa-text = 'Orange'.
      APPEND wa TO values.
      wa-key = '2'.
      wa-text = 'Red'.
      APPEND wa TO values.
      wa-key = '3'.
      wa-text = 'Blue'.
      APPEND wa TO values.
      wa-key = '4'.
      wa-text = 'Gray'.
      APPEND wa TO values.
      CALL FUNCTION 'VRM_SET_VALUES'
           EXPORTING
                id              = 'LIST_BOX'
                values          = values
           EXCEPTIONS
                id_illegal_name = 1
                OTHERS          = 2.
    Ref Program:  DEMO_DROPDOWN_LIST_BOX
    Link: Need a drop down for a selection screen

  • How to make drop down menu

    Hi,
    Iam just wondering if somebody can tell me how to make drop down menus....or direct me to a URL so that i can get some sample code for how to make drop down menus like this:
    + drop down
    abc
    + first
    + second
    - third
       third-des
       third-des2
    i would really appreciate it.
    thanks all.
    -sangita

    Hi,
    something is working .....thanks.
    I have created a java class file as shown below and i did able to run it.........:)
    here is my code:
    package AppMirror;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MenuLookDemo {
        public JMenuBar createMenuBar() {
            JMenuBar menuBar;
            JMenu menu;
            JMenuItem menuItem;
            //Create the menu bar.
            menuBar = new JMenuBar();
            //Build the first menu.
            menu = new JMenu("Menu Label");
            menuBar.add(menu);
            //a group of JMenuItems
            menuItem = new JMenuItem("Item Label");
            //menuItem.addActionListener(actionListener);
            menu.add(menuItem);
            return menuBar;
        public static void main(String[] args) {
            //Create and set up the window.
            JFrame frame = new JFrame("MenuLookDemo");
            //Create/set menu bar and content pane.
            MenuLookDemo demo = new MenuLookDemo();
            frame.setJMenuBar(demo.createMenuBar());
            //Display the window.
            frame.setSize(450, 260);
            frame.setVisible(true);
    but when i see the applet, it doesn't look the one i wanted to see......
    this shows the top menu bar ....but not the + drop-down.
    any ideas ???
    sorry, i don't know anything about swings, applets.....

  • Cannot use drop down menue of app store screen becoming blank

    having problem to access drop down menue of app store i mean options under app store when selected the screen goes blank

    same here...everything else works though (i.e. music, books, movies, tv shows, etc.)
    However, if I search for a particular app by using the search field, the results show and I can then click on the result and access the app that way.
    It's been like this for the past 2 days.    

  • Use drop-down menu to control plot visibility

    Hello everyone,
    I have simple data reading program that loads and parses a text file containing tab-delimited data. Currently, they are parsed and plotted in 7 separate graphs. I am trying to reduce this to 3 graphs where the user can select from a drop-down menu what they would like to be displayed. 
    Eg. Graph 1 would have choices data A, B and C; Graph 2 would have data D, E, F and etc
    The user would select on the drop-down box data A on graph 1 and data F on graph 2. 
    Is there an easy way to this? I have read some ideas about plot visibility.
    Thanks
    Thomas

    Each plot on a chart has its own Plot Visible property. One easy solution is to graph all the data, then set the visibility property for each line based on the selection from the drop-down menu. To set visibility for an individual plot, first set the Active Plot property to the plot that you want, then set the Visible property. You can do this in a single property node; make sure that the Active Plot property is at the top (property nodes execute in top-to-bottom order, and can be mixed read and write).

Maybe you are looking for

  • Oracle 8.1.7.4 / Redhat 7.3 : tablespace creation never ends

    Hi, We're running Oracle 8.1.7.4 on Redhat 7.3. System memory is 256 MB (2x128). After increasing memory to 1Go (2x512) we're facing a strange problem. Tablespaces re-creation hangs, we first drop and then create tablespaces reusing datafiles : DROP

  • Entry view posting key not defaulting to General ledger view

    Hello guys, I did a downpayment to my vendors account with assignment to asset under construction and noticed that the posting key of the bank accounts line did not default to the GL view.So instead of a credit to the bank i have a debit to the bank

  • Can I Use The iPhoto4 "Picture Browser" Without Copying The Photos?

    I use Photoshop Elements 2 for serious editing. However, I find the Browser rather pathetic (small and slow) compared with iPhoto4's. iPhoto's picture viewer is really excellent, enabling me to view albums at any size virtually instantly. Unfortunate

  • New iMac - How to make my friends go WOW

    Ok here's my question.. I would like to show off my new Leopard iMac 24 inch To my skeptical friends .... '' and make them go Wow '' What do you suggest for this Apple newbie..? Thanks

  • Color Viewer Not Working

    I just signed up to Creative Cloud. Long time user of After Effects and Premiere Pro. With Creative Cloud, I decided to learn SpeedGrade. I purchased a sub with Lynda.com. The problem that I have - only with Speedgrade  CC and NOT with After Effects