Results 1 to 4 of 4

Thread: JCheckBox help

  1. #1
    Join Date
    Oct 2011
    Posts
    4
    Rep Power
    0

    Default JCheckBox help

    Hey all, complete noob here. basically in Netbeans GUI builder i have created several Cards with objects on. 1 of these cards contains multiple JCheckBox's. In the previous cards 'next' button, which proceeds to the card with the JCheckBox's, i read from a text file some strings which have the same names of the JCheckBox variable names. What i want it to do is if that name is present inside that text file, enable the JCheckBox of that variable name.

    tools.txt:

    calc.exe
    cmd.exe

    varibles of JCheckBox's:

    calc
    cmd

    Java Code:
    Pattern findZipPattern = Pattern.compile("([A-Za-z0-9]+).exe");
                    Matcher m = findZipPattern.matcher(tool);
    
                    while (m.find()) {
                        String appTool = m.group(1);
    
                       appTool.setEnable(True); //something along these lines
    
                    }
    thanks everyone!

    L.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: JCheckBox help

    Consider using a Map<String, JCheckBox>. This will allow you to easily obtain a reference to the JCheckBox of interest based on a text String. You can then call whatever methods on the JCheckBox that you'd like, including setEnabled(...).

  3. #3
    Join Date
    Oct 2011
    Posts
    4
    Rep Power
    0

    Default Re: JCheckBox help

    Quote Originally Posted by Fubarable View Post
    Consider using a Map<String, JCheckBox>. This will allow you to easily obtain a reference to the JCheckBox of interest based on a text String. You can then call whatever methods on the JCheckBox that you'd like, including setEnabled(...).
    do you know where i could possibly find an example of this?

    thanks.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: JCheckBox help

    Quote Originally Posted by lawrenceejgray View Post
    do you know where i could possibly find an example of this?
    An example of this specific issue? No, that's too localized a question to probably find an exact example. But you can find examples of and tutorials with using Maps on this forum and in multiple forums, and then use your own powers of logic to take use the concepts from the general examples to solve your particular problem.

Similar Threads

  1. JCheckBox
    By bczm8703 in forum JDBC
    Replies: 1
    Last Post: 10-23-2011, 05:30 PM
  2. Jcheckbox problem
    By xyknight in forum New To Java
    Replies: 10
    Last Post: 04-09-2011, 04:40 PM
  3. JCheckbox in jtable
    By anilkumar_vist in forum Advanced Java
    Replies: 3
    Last Post: 09-07-2010, 05:29 AM
  4. How to add a jcheckbox in jtable
    By lakshayghai in forum AWT / Swing
    Replies: 9
    Last Post: 04-14-2010, 11:32 PM
  5. How can I add JCheckBox to each row?
    By batya in forum AWT / Swing
    Replies: 1
    Last Post: 11-04-2009, 09:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •