Trying to write a Listener on a CheckBox to change the Model of a ComboBox

I am trying to change the list that appears in a ComboBox dynamically based on if a CheckBox is selected or not. I have multiple CheckBoxes and ComboBoxes being created in a loop based on a variable assigned at creation. Every tutorial i have seen writes out a listener that explicitly defines the checkbox instance but in my case i don't acctually know. My checkboxes are in an array of checkboxes as are the comboboxes as they are being created at runtime. Any help would be much apreciated this issue has been with me for two days now.

here is a snippit of my code in how i was implementing this:
int numButton = 17; //this is for testing only, this variable is set from another class normally
// these variables are defined private elsewhere in the class
JCheckBox PlayerByeCheck[] = new JCheckBox[numButton + 1];
JCheckBox PlayerHomeCheck[] = new JCheckBox[numButton + 1];
boolean PlayerOnBye[] = new boolean[numButton + 1];
for (int i = 1; i <= numButton; i++) {
         PlayerByeCheck[i] = new JCheckBox();
     PlayerHomeCheck[i] = new JCheckBox();
     PlayerOnBye[i] = false;
// more code here for building the gui it is not important for this problem
// code to build the list starts here
for (int i = 1; i <= numButton; i++) {
     ((TableLayout)PlayerRosterPanel.getLayout()).insertRow(1, TableLayout.PREFERRED);
         PlayerByeCheck.setOpaque(false);
     PlayerByeCheck[i].addItemListener(this);
     PlayerByeCheck[i].setName("PlayerByeCheck" + i);
     PlayerRosterPanel.add(PlayerByeCheck[i], new TableLayoutConstraints(2, 1, 2, 1, TableLayoutConstraints.CENTER, TableLayoutConstraints.FULL));
//the comboox that i want to change
//---- PlayerTeamSelect1 ----
     if (PlayerOnBye[i] = true) {
          PlayerTeamSelect[i].setModel(new DefaultComboBoxModel(new String[] {
               "ARI",
               "ATL",
               "BAL",
          "BUF",
     "BYE"
          PlayerTeamSelect[i].setSelectedItem("BYE");
     } else {
          PlayerTeamSelect[i].setModel(new DefaultComboBoxModel(new String[] {
               "ARI",
               "ATL",
               "BAL",
               "BUF",
               "CAR",
          "BYE"
     PlayerTeamSelect[i].setOpaque(false);
     PlayerRosterPanel.add(PlayerTeamSelect[i], new TableLayoutConstraints(4, 1, 4, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
//more gui code here method gets closed
//Item Action Listener starts here this is where i am having the problem                         
public void itemStateChanged(ItemEvent e) {
     Object source = e.getItem();
     if (source == PlayerByeCheck[1])
     int select = e.getStateChange();
          if (select == ItemEvent.SELECTED)
          PlayerOnBye[1] = true;
PlayerRosterPanel.repaint();
//repaint the window i think can't get the listener to work to see if this is the right way to do this
//i doubt it is
I have tried several different ways to write the listener, the example in the code above is following the java swing tutorial by explicitly defining the checkbox. I have tried to write the listener as i am creating the checkbox, which doesn't seem to work or i am wrting it wrong, which is entirely possible. Once the listener sets the value i think it should repaint the screen but i am sure that that is wrong right now as well. As my hunch is the repaint will reset the checkbox to DESELCTED the default value. I will come to that issue once i figure out how to get the listener working. Ideally i want to be able to set the listener for the checkboxes regardless as to how many there are. As stated above i am generating a list of checkboxes, comboboxes and other fields based on a variable that is defined in one of my objects. If the user selects checkbox 3 than combobox 3 should be changed, and the others should not. if the user selects all the checkboxes than all the comboboxes change.
thanks for any help. Still plugging along on it trying to figure this one out.

Similar Messages

  • TS1503 Does anyone know what "other" means in the sync summary bar? I have 850mb using storage space in my iphone and can't understand what that is. I have tried to delete everything, restore to factory settings and change the icloud account. Thanks.

    Does anyone know what "other" means in the sync summary bar? I have 850mb using storage space in my iphone and can't understand what that is. I have tried to delete everything, restore to factory settings and change the icloud account. Thanks.

    Hi there AnthPy,
    You may find the troubleshooting steps in the article below helpful.
    OS X Mail: Troubleshooting sending and receiving email messages
    http://support.apple.com/kb/ts3276
    -Griff W. 

  • How do I se a checkbox to change the value of another cell?

    I am trying to create a spreadsheet for a job quote sheet. In column A I am inserting checkboxes, in column W i have the price of that particular option that coincides with that product. What I am trying to accomplish is if I select the checkbox for an option, the cost (from column W) will jump in Column Z. Then Column Z will be totaled up at bottom, giving my client a total of everything selected. Can this be done and if it can HOW?!
    Thanks in Advance!!

    James,
    Another approach that may work for you would be to have a column for quantity, rather than a checkbox.  If the quantity is greater than zero, then enter the extended price and total it at the bottom of the order list.
    In that case, you would write in Z:
    =A*W
    With no quantity, the result would be zero in Z.
    Jerry

  • Is it possible to use the status of a checkbox to change the fillcolor of a numeric field?

    I have read through most all of the threads, but found none pertaining to my specific question.  I would like to change the fillcolor of a numeric field based upon the status (on/off) of a checkbox located on a different page.  In other words, if the checkbox is checked I want the numeric field to be yellow with a solid (thin) black border.  I have tried:
    If (CheckBox1.rawValue="1")
    {this.fillcolor="R,G,B";} else
    {this.fillcolor="250,250,250"};
    I haven't gotten the correct RGB values yet for the color I am using, that is why the script has "R,G,B"
    I am pretty new at javascript and have been learning a lot from the forums, but I just can't seem to figure this one out.  Any help would be greatly appreciated.  Thanks

    Give this a go...
    // form1.page1.cb::click - (JavaScript, client)
    if (this.rawValue == 1) {
      xfa.resolveNode("form1.page1.nf.ui.#numericEdit.border.fill.color").value = "255,255,0";
      form1.page1.nf.border.edge.color.value = "0,0,0";
    else {
      xfa.resolveNode("form1.page1.nf.ui.#numericEdit.border.fill.color").value = "255,255,255";
      form1.page1.nf.border.edge.color.value = "255,255,255";
    Don't forget to make your form a dynamic form.
    Steve

  • Turning on 'write xmp files' in LR 5.4 changed the modified date on my old raw and jpg files. Can i stop this?

    On the advice of an article saying XMP sidecar files are a safer alternative to relying only on the catalog, I recently (June 16, 2014) turned on write XMP files. Now all my JPG and raw files have the same modified date of June 16, 2014, making it impossible to know which are the most recent files, etc.
    Is it possible to change this behavior to only create these files for new images - or to stop this behavior?
    I'm reverting to a backup of all my files and turning this option o ff for now.
    Thx

    I assume your raws are in DNG format? If xmp is in sidecar, it won't change raw file date.
    Anyway, saving xmp does not change any dates in Lightroom, so you should still be able to sort by edit time or capture time...
    But if you want control, you have to save manually instead of automatically.
    Two things that might help:
    1. Filter based on metadata status.
    2. robcole.com - DNGPreviewUpdater
    Rob

  • Playing music the screen freezes and if i want to make changes it will not let me.I go to restore factory settings and afterwards i am able to listen,view album covers,and change the type of music i want.Is there a better way to do this? Thx

    When playing music on my ipad the screen freezes and i am not able to view album covers or make any changes i am only able to hear what i selected.
    This is the third time it has happened since i updated to the new IOS 5.1. It never happened before.
    If i go to Summary and restore the ipad to the factory settings then i'm able to run it as normal.
    Is this a glitch in the new software,or a problem with my ipad?
    Thanks for any help

    Thanks Russ H and Ross H!
    I'm finding Multicam, combined with Compound Clips to be extrememly efficient.
    I started with 2 different video clips, along with 2 different audio clips.
    Layed out both clips side by side (visually, they are on top of each other on the timeline),and made that a single compound clip.
    Then I laid out both audio clips on top of each other on the timeline and made those a compound clip.
    So now I have
    2 original individual Video shots
    1 compound video shot of the 2 above side by side.
    2 original audio tracks
    1 compound audio track
    Next I made a multicam track, and added to it all 3 video shots (2 original + 1 compound) And I added the compound audio track. I set that audio track to be "the" track.
    It's just a little bit of setup, but really not that bad, and the ability to use the multicam feature to switch between shots, while keeping everything in sync is fantastic!
    - Jack

  • My sound check is continually popping up while listening to music and then changes the song or speeds it up

    my sound check continually pops up and changes my music and sometimes speeds up the song

    Basics from the manual are :
    restart.
    reset.
    restore.
    Try these.

  • Hi i am trying to write a program which reads from a properties file the pr

    hi,
    this is ayesha.
    I am trying to write a program wherein i will be reading the value of a property from a properties file which will be true initially. I want to loop in there till the time when the value of the property is false.
    The code is as follows:
    public static void main(String[] args) {
              ReadingAPropertiesFile propers=new ReadingAPropertiesFile();
              propers.ReadingFileRegularly("F:\\ayesha.properties");
    public String ReadingFileRegularly(String FilePath){
              Properties props = new Properties();
              String message;
              String filePath=FilePath;
              try {
    props.load(new FileInputStream(filePath));
    message = props.getProperty("ayesha");
         boolean theValue = Boolean.parseBoolean(message);
         while(theValue){
              System.out.println("trueeeeeeeeeeeeeeeeeeeeeee");
              Thread.sleep(60000);
              ReadingFileRegularly(filePath);
              catch(Exception ex){
                   ex.printStackTrace();
              String messagean="something";
              return messagean;
    The contents of ayesha.properties are :
    ayesha=true
    After 5 minutes it will be set to false so i want to loop in there till the value of ayesha=false at which time i will return
    But i dont know how to loop in there for that time:
    while(theValue) ?????????????/ what after this???????????
    Any suggestons are awaited.

    ayeshaparween wrote:
    hi,
    this is ayesha.
    I am trying to write a program wherein i will be reading the value of a property from a properties file which will be true initially. I want to loop in there till the time when the value of the property is false.
    The code is as follows:
    public static void main(String[] args) {
              ReadingAPropertiesFile propers=new ReadingAPropertiesFile();
              propers.ReadingFileRegularly("F:\\ayesha.properties");
    public String ReadingFileRegularly(String FilePath){
              Properties props = new Properties();
              String message;
              String filePath=FilePath;
              try {
    props.load(new FileInputStream(filePath));
    message = props.getProperty("ayesha");
         boolean theValue = Boolean.parseBoolean(message);
         while(theValue){
              System.out.println("trueeeeeeeeeeeeeeeeeeeeeee");
              Thread.sleep(60000);
              ReadingFileRegularly(filePath);//recursive call this is a bad idea might result in stack overflow error
              catch(Exception ex){
                   ex.printStackTrace();
              String messagean="something";
              return messagean;
    The contents of ayesha.properties are :
    ayesha=true
    After 5 minutes it will be set to false so i want to loop in there till the value of ayesha=false at which time i will return
    But i dont know how to loop in there for that time:
    while(theValue) ?????????????/ what after this???????????
    Any suggestons are awaited.I think you better rethink your design , do not use recursion, I would normally use a loop like you did but without loading the content of the file each time, I would use File.l lastModified() method and compare with previous results from this method to see if the file was modified. Then if it was modified then load the new File and check if the property value has changed.

  • Trying to write Event or Action Listener

    I believe what I am trying to write is an Event Listener (it may be the case that I want to be writing an entirely different type of class), but I don't seem to be having any success.
    I currently have two classes that I want to establish a Listener (whether it be Action or Event, I don't know) relationship between.
    One of the classes (class Container) has a container (let's say a Vector for simplicity) and throughout the program's lifetime I add elements to the container. Therefore, I have a generic addElement method in class Container. And lets say I have another class (class ContainerListener). I want class ContainerListener to know whenever class Container's method addElement is called.
    So I thought I could make them ActionListeners or something and class ContainerListener could be informed whenever class Container add's an element to its container.
    This is where I got with the Container class:
    package com.timCassidy.misc;
    import java.util.*;
    import java.awt.event.*;
    public class Container implements ActionListener{
    private Vector m_vectorOfElements;
    /** Creates new Container */
    public Container() {
    m_vectorOfElements = new Vector();
    public void addElement (String _text){
    m_vectorOfElements.addElement (_text);
    public void actionPerformed(ActionEvent e) {
    System.out.println ("this shouldn't be getting called as I haven't registered this object with any other object as a listener");
    public static void main (String [] args){
    And this is where I got with the ContainerListener class:
    package com.timCassidy.misc;
    import java.awt.event.*;
    public class ContainerListener implements ActionListener{
    /** Creates new ContainerListener */
    public ContainerListener() {
    public void actionPerformed(ActionEvent e) {
    System.out.println ("an element has been added to the container");
    public static void main (String [] args){
    ContainerListener containerListener = new ContainerListener();
    com.timCassidy.misc.Container container = new com.timCassidy.misc.Container();
    container.addActionListener (containerListener);
    container.addElement ("tim");
    This is the compiler error I get:
    com/timCassidy/misc/ContainerListener.java [21:1] cannot resolve symbol
    symbol : method addActionListener (com.timCassidy.misc.ContainerListener)
    location: class com.timCassidy.misc.Container
    container.addActionListener (containerListener);
    ^
    I assume this problem stems from the fact that my Container class doesn't implement/extend some class that has the method ActionPerformed in it???
    Can someone tell me how to fix these classes or just the Container class if that is all that is necessary.
    Thanks,
    Tim

    This seems to work, what do you think:
    package com.timCassidy.misc;
    import java.util.*;
    import java.awt.event.*;
    public class Container implements ActionListener{
    private Vector m_vectorOfElements;
    private Vector m_registeredListeners;
    /** Creates new Container */
    public Container() {
    m_vectorOfElements = new Vector();
    m_registeredListeners = new Vector();
    public void addElement (String _text){
    m_vectorOfElements.addElement (_text);
    for (int i = 0;i < m_registeredListeners.size();i++){
    ActionListener listener = (ActionListener)m_registeredListeners.elementAt(i);
    listener.actionPerformed(new ActionEvent(this,0,"blah"));
    public void addActionListener(Object _class) {
    if (_class instanceof ContainerListener){
    m_registeredListeners.addElement(_class);
    public void actionPerformed(ActionEvent e) {
    System.out.println ("this shouldn't be getting called as I haven't registered this object with any other object as a listener");
    public static void main (String [] args){

  • WIN7 x64 Home Basic, 0x80070013 when trying to write or delete files. Disk is write protected.

    Hi,
    My SD card reader is not able to write or delete and format sd cards.
    WIN7 x64 Home Basic, 0x80070013 when I trying to write or delete files. When I trying to format I can see a message that disk is write protected. 
    The card is not locked, it's work in Lenovo Idea Pad s10 without any problem, It's also work in my Pentax camera.
    I'm almost sure that the problem is software, but can't find solution.
    Could Any one help me please?
    Laptop is new, 8 days in use. 

    I have network shutdown 2.0.1 installed and the pcns process normally would be abend in 1 or 2 minute's time. What could be the problem ? Consider to upgrade the network shutdown to 2.2.1 version. Could the problem be resolved in new version ? Any precaution needs to be taken when installing the new version ?
    Terence.

  • NotSerializable error while trying to write arraylist

    I am getting a NotSerializable error while trying to write an arraylist to a file.
    Here's the part of the code causing problem
    File temp = fileOpenerAndSaver.getSelectedFile(); // fileOpenerAndSaver is a JFileChooser object which has been created and initialized and was already used to select a file with
    currentWorkingFile = new File (temp.getAbsolutePath() + ".gd");      // currentWorking file is a file object
    try
         ObjectOutput output = new ObjectOutputStream (new BufferedOutputStream(new FileOutputStream(currentWorkingFile)));
         output.writeObject(nodeList); // <-- This is the line causing problem (it is line 1475 on which exception is thrown)
         output.writeObject(edgeList);
         output.writeObject(nodesWithSelfLoop);
         output.writeObject(nextId);
         output.writeUTF(currentMessage);
         output.close();
    catch (Exception e2)
         JOptionPane.showMessageDialog (graphDrawer, "Unknown error writing.", "Error", JOptionPane.ERROR_MESSAGE);
         e2.printStackTrace();
    } As far as what nodeList is -- it's an arraylist of my own class Node which has been serialized and any object used inside the class has been serialized as well.
    Here is the declaration of nodeList:
         private ArrayList <Node> nodeList; // ArrayList to hold a list all the nodesLet me show you whats inside the node class:
    private class Node implements Serializable
         private static final long serialVersionUID = -4625153386839971250L;
         /*  edgeForThisNodeList holds all the edges that are between this node and another node
          *  nodesConnected holds all the nodes that are connected (adjacent) to this node
          *  p holds the top left corner coordinate of this node.  The centre. of this node is at (p.x + 5, p.y + 5)
          *  hasSelfLoop holds whether this node has a self loop.
          *  **NOTE**: ONLY ONE SELF LOOP IS ALLOWED FOR A NODE.
         ArrayList <Edge> edgeForThisNodeList = new ArrayList <Edge> ();
         ArrayList <Node> nodesConnected = new ArrayList <Node> ();
         Point p;
         boolean hasSelfLoop = false;
         int index = -1;
         BigInteger id;
                     ... some methods following this....
    }Here is the edge class
    private class Edge implements Serializable
         private static final long serialVersionUID = -72868914829743947L;
         Node p1, p2; // The two nodes
         Line2D line;
          * Constructor:
          * Assigns nodes provided as appropriate.
          * Also calls the addEdge method on each of the two nodes, and passes
          * "this" edge and the other node to the nodes, so that
          * this edge and the other node can be added to the
          * data of the node.
         public Edge (Node p1, Node p2)
              this.p1 = p1;
              this.p2 = p2;
              line = new Line2D.Float(p1.p.x+5,p1.p.y+5,p2.p.x+5,p2.p.y+5);
              p1.addEdge(this, p2, true);
              p2.addEdge(this, p1, false);
         }Here is the error I am getting:
    java.io.NotSerializableException: javax.swing.plaf.metal.MetalFileChooserUI
         at java.io.ObjectOutputStream.writeObject0(Unknown Source)
         at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
         at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
         at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
         at java.io.ObjectOutputStream.writeObject0(Unknown Source)
         at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
         at java.io.ObjectOutputStream.writeObject0(Unknown Source)
         at java.io.ObjectOutputStream.writeObject(Unknown Source)
         at MyPanel.save(MyPanel.java:1475)
         at GraphDrawer.actionPerformed(GraphDrawer.java:243)
         I inentionally did not write the whole error stack because it was way too long and I ran out of characters. But line 1475 is where I do the writeObject call. I also goet some weird not serialized exceptions before on some other classes that are not being written to the file or are not part of the object that I am writing. I serialized those classes and now it's this unknown object that's causing problems.
    Edit: The problem may be due to the JFileChooser I am using to select the file as it is a non-serializable object. But I am not trying to write it to the file and in fact am just writing the arrayLists and BigInteger as objects to the file.
    Edited by: Cricket_struck on Dec 21, 2009 1:25 PM
    Edited by: Cricket_struck on Dec 21, 2009 1:32 PM
    Edited by: Cricket_struck on Dec 21, 2009 2:16 PM

    java.io.NotSerializableException: javax.swing.plaf.metal.MetalFileChooserUIThat's a Swing component and it is clearly related to the JFileChooser.
    I also get some weird not serialized exceptions before on some other classes that are not being written to the file or are not part of the object that I am writing.That's a contradiction in terms. If you get NotSerialzableException it means the objects are being written. So they are reachable from the objects you're writing.
    Edit: The problem may be due to the JFileChooser I am using to select the file as it is a non-serializable object.JFileChooser implements Serializable, but you're right, you shouldn't try to serialize it. But clearly this is the current problem. Somewhere you have a reference to it reachable via the object(s) you are serializing.
    I suspect that Node and Edge inner classes and that you aren't aware that inner classes contain a hidden reference to their containing class. The solution for serializaition purposes is to make them static nested classes, or outer classes.

  • TS1277 iTunes is unable to run. I tried to run iTunes and a message comes up that says "the iTunes library.itl file is locked, on a locked disk, or you do not have write permission for this file." what is the solution to unlock it ?!

    iTunes is unable to run. I tried to run iTunes and a message comes up that says "the iTunes library.itl file is locked, on a locked disk, or you do not have write permission for this file." what is the solution to unlock it ?!

    I have tried both suggestions, unfortunately neither fixed this for me. Hoping there's another possible fix. Thanks in advance. 
    Empty/corrupt iTunes library after upgrade/crash and/or Repair security permissions for iTunes for Windows.

  • I try to export my Imovie and I always get the error code"Unable to prepare project for publishing...File already open with write permission"  it even does it when I am just trying to export to my external hard drive to save the file

    I try to export my Imovie and I always get the error code"Unable to prepare project for publishing...File already open with write permission"  it even does it when I am just trying to export to my external hard drive to save the file

    Thanks!!! I had same error (with -49) and the mac had an external hard drive attached.. and it was doing a backup.  Stopped, disconnected and the project exported!

  • I switched my keyboard to french and now it won't change back to english. Quite the hassle when trying to write in english. Why would it be stuck?

    I switched my keyboard to french and now it won't change back to english. Quite the hassle when trying to write in english. Why would it be stuck?

    When the keyboard pops up, tab the Globe icon, and select the English keyboard.

  • My imac is not recognizing any external dvd writer drive. I have imac with Core i7 and Mac OS 10.6.8. I have tried external dvd writers from Samsung and Amazon Essentials but the computer does not recognize any of them. Which Dvd writer is compatible?

    My imac is not recognizing any external dvd writer drive. I have imac with Core i7 and Mac OS 10.6.8. I have tried external dvd writers from Samsung and Amazon Essentials but the computer does not recognize any of them. Which Dvd writer is compatible?

    I have an external firewire burner; it never shows on the desktop unless I insert a CD or DVD - that icon will then show (if I have my preferences set to show those on the desktop). Hae you checked in Disk Utility (Applications > Utilities) to see if it is listed under drives?

Maybe you are looking for