Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 11 of 11

Thread: HELP WITH COMBO!

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    4
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation HELP WITH COMBO!

    2 drop down box and 1 text field connected.
    The text field should be an optional; meaning, if first 2 drop down is selected, my page will still proceed even text field is empty.
    Last edited by bajeanius; July 24th, 2012 at 04:06 AM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: HELP WITH COMBO!

    I might be the only one, but honestly don't have a clue what you are asking. You are better off actually asking a question and describing the problem. Better yet, read the link in my signature entitled "Getting Help"

    Thread moved from http://www.javaprogrammingforums.com...introductions/

  3. #3
    Junior Member Krumpir's Avatar
    Join Date
    Jul 2012
    Location
    Cape Town, South Africa
    Posts
    9
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: HELP WITH COMBO!

    If you want to check whether something is selected in the combobox you can use:
    if(combobox1.getSelectedIndex() == -1) {
     // Nothing has been selected in the combo box
    }
    Check out my site -> tssolutions.net16.net

  4. #4
    Junior Member
    Join Date
    Jul 2012
    Posts
    4
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: HELP WITH COMBO!

    Quote Originally Posted by copeg View Post
    I might be the only one, but honestly don't have a clue what you are asking. You are better off actually asking a question and describing the problem. Better yet, read the link in my signature entitled "Getting Help"

    Thread moved from Member Introductions
    Okay, I need to create a webpage for querying data. Page will have a table for user to select their choice, let's say 2 drop down box then 1 optional textbox.
    Name 2 drop down box as A and B, and textbox as C.
    When user select nothing, A should be enabled, B and C should be disabled.
    When user select something in A, B response and show only certain or corresponding choices while C is still disabled.
    When user has selected something in A and B, C will then be enabled, but it is still a optional textbox, meaning user may not need to enter anything but page will still proceed to the next.
    But if C is entered with a number, program should grab that number and work with that then show the result at the next page.

    Is this understand-able? =/ Lol. Well, there's a picture below, I hope you will understand it better then.
    Anyway, thanks for replying..
    Capture.JPG

  5. #5
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: HELP WITH COMBO!

    You will have to somehow determine when an item in A has been selected.
    Then determine which item it was in A.
    Based on that, decide what to throw into B.
    Then follow your basic shampoo instructions.

  6. #6
    Junior Member
    Join Date
    Jul 2012
    Posts
    4
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: HELP WITH COMBO!

    Quote Originally Posted by jps View Post
    You will have to somehow determine when an item in A has been selected.
    Then determine which item it was in A.
    Based on that, decide what to throw into B.
    Then follow your basic shampoo instructions.
    Yeah, I have tried many ways on make the two drop down box work, in fact, I can only get those two working but not the textbox.
    Meaning when both selected, whether or not I enter values in textbox, it will never pick up the values in textbox and proceed to next page.

  7. #7
    Junior Member
    Join Date
    Jul 2012
    Posts
    4
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: HELP WITH COMBO!

    Quote Originally Posted by Krumpir View Post
    If you want to check whether something is selected in the combobox you can use:
    if(combobox1.getSelectedIndex() == -1) {
     // Nothing has been selected in the combo box
    }
    Thanks for the reply. But to be frank, it doesn't work on my program. =/ Any better idea?

  8. #8
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: HELP WITH COMBO!

    Quote Originally Posted by bajeanius View Post
    ... I can only get those two working but not the textbox....
    Don't be shy.... show us whatcha got....

    come on now, pull back the covers and show us that code

  9. #9
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: HELP WITH COMBO!

    Quote Originally Posted by bajeanius View Post
    Okay, I need to create a webpage for querying data. Page will have a table for user to select their choice, let's say 2 drop down box then 1 optional textbox
    My point above regarding being descriptive still applies - in fact, from what you've described it sounds like you are looking for a solution that uses javascript...this is a java forum, and javascript != java.

  10. #10
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default Re: HELP WITH COMBO!

    bejeanius,
    the combo boxes should be attached to an actionListener like this
    public class Boxes extends JDialog  implements ActionListener { 
                ...
        	    box1 = new JComboBox(("1!2!3!4").split("!"));
        	    box1.addActionListener(this);
                ...
        	    box2 = new JComboBox(("A!B!C!D!E").split("!"));
        	    box2.addActionListener(this);
                ...
                // disable box2 and texfield tf
                ...
         public void actionPerformed(ActionEvent e) {
        	    String ev = e.toString();
        	    if (ev.charAt(0) >= '9'){
                       //enable box2
                } else {
                       // enable textfield tf 
                }
        }
        ...
    is that what you mind?

  11. #11
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default Re: HELP WITH COMBO!

    Bajeanius
    Sorry for trouble finger with your nick and with the post button
    The term ev.charAt(0) is incorrect. It's as following
         public void actionPerformed(ActionEvent e) {
        	    String ev = e.toString();
                char ch = ev.charAt(ev.indexOf("selectedItemReminder=")+22);
        	    if (ch >= '9'){
                       //enable box2
                } else {
                       // enable textfield tf 
                }

Similar Threads

  1. ClassCastException with Enum Combo Box
    By Diplo in forum What's Wrong With My Code?
    Replies: 4
    Last Post: July 26th, 2011, 01:22 PM
  2. Adding another related combo box ?
    By shad3d in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 19th, 2011, 01:53 PM
  3. Combo/TextField Help
    By GRossi0511 in forum AWT / Java Swing
    Replies: 2
    Last Post: October 26th, 2009, 08:15 PM
  4. Loading contents of a Database into a Combo box
    By tyolu in forum JDBC & Databases
    Replies: 3
    Last Post: June 22nd, 2009, 08:14 AM

Tags for this Thread