JRadioButton setSelected problem

Hi,
I am trying to change the status of my JRadio buttons to false, but they do not get updated. One of them still remains selected.
Any ideas?
radioButton1.setSelected(false);
radioButton2.setSelected(false);

devboris wrote:
I am trying to change the status of my JRadio buttons to false, but they do not get updated. One of them still remains selected.
Any ideas?
radioButton1.setSelected(false);
radioButton2.setSelected(false);
This should be posted in the Swing forum, not the Java 2D forum.
Regardless, if you are using Java 1.6, then I recommend that you call clearSelection on the ButtonGroup object. If you are not using Java 1.6, then you can always add to your button group another invisible jradiobutton and set its selected property to true.

Similar Messages

  • JRadioButton.setSelected( false ) ?

    First of all, I just read the thread "Secret source of answers to your problems...." and want to assure anyone reading this that I have been looking at the Java API all morning and I'm ready to rip this Java textbook into shreds.
    I have a homework assignment and while I am not asking anyone to do my homework for me, I have run up against a brick wall. I have two sets of JRadioButtons (using two ButtonGroups). I also have two JButtons - one of which I want to use to clear the form, including clearing the JRadioButton selections.
    According to the API - I should be able to set a radio button's "selected" to false. But it isn't working for me.
    Here is the snippet of code I am using in my ActionListener event handler for the Clear button. All of it works except for the setSelected method call:
    if ( event.getSource() == clearButton )
        tempField.setText( "" );            // clear text field
        inCelButton.setSelected( false );  // clear radio button
        inFahButton.setSelected( false );  // selections
        inKelButton.setSelected( false );  // inButton Group
        inCelButton.setVisible( true );    // set radio buttons
        inFahButton.setVisible( true );    // to visible
        inKelButton.setVisible( true );
        outCelButton.setSelected( false ); // clear radio button
        outFahButton.setSelected( false ); // selections
        outKelButton.setSelected( false ); // outButton Group
        outCelButton.setVisible( true );   // set radio buttons
        outFahButton.setVisible( true );   // to visible
        outKelButton.setVisible( true );
        results="";                        // clear results string
        resultsLabel.setText("");          // clear results label
    }TIA
    Sheryl McKenna

    It's not necessarily true that you have to have a button selected. It only works this way when you use a buttongroup. The buttongroup insists that one button be selected when all others are off. This is the API information (Which it sounds like you are already familiar with)
    "Initially, all buttons in the group are unselected. Once any button is selected, one button is always selected in the group. There is no way to turn a button programmatically to "off", in order to clear the button group. To give the appearance of "none selected", add an invisible radio button to the group and then programmatically select that button to turn off all the displayed radio buttons. For example, a normal button with the label "none" could be wired to select the invisible radio button."
    I just wrote a simple app to test this and it worked fine for me. The button group ensures you can't select multiple buttons. After you select one, all others are automatically de-selected. If you are really set on using a group of buttons, without the buttonGroup then I would add a panel, set the layout to null and then just add the buttons. Netbeans is a great way to test your UI without writing a lot of code and see the end results quickly. It's free and it's available at:
    http://www.netbeans.org.

  • JRadioButton.setSelected(false) doesn't work?

    Hey there. I usually answer questions in this forum but this time I have a question myself. I'm trying to de-select JRadioButtons in a ButtonGroup but it's not working. I've searched the forum but didn't find anything. Here's the very simple code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class ButtonTest extends JFrame {
      JRadioButton rb1 = new JRadioButton("button1", true);
      JRadioButton rb2 = new JRadioButton("button2");
      ButtonGroup bgroup = new ButtonGroup();
      JButton b = new JButton("clear");
      ButtonTest() {
        b.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            clearbuttons();
        bgroup.add(rb1);
        bgroup.add(rb2);
        Container c = getContentPane();
        c.setLayout(new GridLayout(2,2));
        c.add(rb1);
        c.add(rb2);
        c.add(b);
        addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
      void clearbuttons() {
        Component [] components = getContentPane().getComponents();
        for (int i = 0; i < components.length; i++) {
          Component c = components[ i ];
    System.out.println(c);
          if (c instanceof JRadioButton) {
            JRadioButton rb = (JRadioButton) c;
            rb.setSelected(false);  // once.
            bgroup.setSelected(rb.getModel(), false);  // twice.
    System.out.println("\ncalled setSelected\n");
      public static void main (String[]a) {
        ButtonTest b = new ButtonTest();
        b.setSize(200,100);
        b.setVisible(true);
    }Anybody know why the selected button remains selected?

    The ButtonGroup ensures that one JRadioButton is always selected, at least after the first one is initially selected. The workaround to fix this is to add an additional "dummy" JRadioButton to the ButtonGroup, and have your code select it when you want to deselect the rest of the buttons. The dummy JRadioButton doesn't need to be added to the GUI or displayed, or anything.

  • Checkboxgroup setSelected() problem

    Hi,
    I have a number items read from a .txt file into a checkboxGroup. I have problem in selecting some of them automatically. Please help me in setSelected() function code:
    //get selected automatically
             try {                   
                 int numOfLines2 = 0;
                int count2=0;
                String theLine2 = null;
                FileReader fr4 = new FileReader("C:/CreatorProjects/Npad_PAIRS_NLP.prs");
                BufferedReader br4 = new BufferedReader(fr4);
                while ((theLine2 = br4.readLine()) != null) {
                    numOfLines2++;
                fr4.close();          // close the file.
                br4.close();          // close the buffer
                FileReader fr5 = new FileReader("C:/CreatorProjects/Npad_PAIRS_NLP.prs");
                BufferedReader br5 = new BufferedReader(fr5);
                listPatientdata = new com.sun.rave.web.ui.model.Option[numOfLines2];
                while ((theLine2 = br5.readLine()) != null || count2 <= numOfLines2) {
                    listPatientdata[count2] = new Option(theLine2, theLine2);
                    if(count2<=ptftrs)      //ptftrs is predefined integer
                        checkboxGroup1.setSelected(theLine2);
                    count2++;
                } catch(Exception e) {
                e.printStackTrace();    
       }I have no problem in using the code if I want all boxes unselected initially.
    thanks in advance.
    dr.am.mohan rao

    while ((theLine2 = br5.readLine()) != null || count2 <= numOfLines2) {
    listPatientdata[count2] = new Option(theLine2, theLine2);
    if(count2<=ptftrs)      //ptftrs is predefined integer
    checkboxGroup1.setSelected(theLine2);
    count2++;         
    } catch(Exception e) {
    e.printStackTrace();     My guess is to call setSelected after adding all options to check box group. Try something like:
    String valueToSelect = null;
    while((theLine2 = br5.readLine()) != null || count <= numOfLines2) {
    listPatientdata[count2] = new Option(theLine2, theLine2);
    if(count2 <= ptftrs)
    valueToSelect = theLine2;
    count2++;
    checkboxGroup1.setSelected(valueToSelect);best regards
    Grzegorz

  • A JRadioButton Listener problem!

    Here is a situation, Trying to create a JRadioButton Listener for kinda multiple choice Quiz. Questions and answers are written to the respective RadioButtons from a text file.
    So once a button is selected, it should check if the selected button is the correct answer(getCorrectAnswer() returns the correct answer)to the particular question, if it is then it updates a score JTextField and also status JTextField otherwise just the status JTextField.
    Below is the RadioButtonListener doesn't do what it is suppose to do i.e no effect on score & status JTextField.
    Any suggestions to why or where I am going wrong?
    //Listener for RADIOBUTTONS
    class RadioButtonListener implements ItemListener
    public void itemStateChanged(ItemEvent e)
    for (int i=0; i<v.size(); i++)
    QAs A = (QAs) v.elementAt(i);
    if (e.getSource() == checkbox1)
    if (checkbox1.equals(A.getCorrectAnswer()))
    statusText.setText("Correct!");
    scoreText.setText(score + " ");
    score++;
    else
    statusText.setText("Incorrect");
    else if(e.getSource() == checkbox2)
    if (checkbox2.equals(A.getCorrectAnswer()))
    statusText.setText("Correct!");
    scoreText.setText(score + " ");
    score++;
    else
    statusText.setText("Incorrect");
    else if(e.getSource() == checkbox3)
    if (checkbox3.equals(A.getCorrectAnswer()))
    statusText.setText("Correct!");
    scoreText.setText(score + " ");
    score++;
    else
    statusText.setText("Incorrect");
    } // END OF FOR LOOP
    } // END OF itemStateChanged METHOD
    } // END OF RadioButtonListener CLASS

    you may try this:
    public void itemStateChanged(ItemEvent e) {
        if (e.getStateChange() == ItemEvent.SELECTED) {
            //do something
        } else {
            //do something
    }

  • Need help on JRadioButton

    Hi,
    I'd like to change the state of a JRadioButton by code and I don't know how to do. I've watched the API for JRadioButton and there's no method like a jrb.setState( true ), or something like that.
    I don't really understand if I have to use the getAccessibleContext to set a property, and if I have to I don't know how, so would you please help me a bit ???
    Thanks in advance !!!

    try this method:jRadioButton.setSelected(false); // or true cheers,
    kelysar

  • Problem with setSelection and components

    Hi! I have a problem with setSelection function when there is
    any component on the stage or in the library. Just look on the
    sample
    here The first
    button sets focus and sets selection, the second one removes focus.
    It works good, but add any component to break it. Is there any
    other way to unset focus? Maybe this is the problem... Any help?
    BTW Sorry for my english :)

    Selection.setFocus(component) removes current
    selection

  • Problem with JRadioButtons....

    hi,
    we were dealing with a grup of buttons added on a JFrame,
    the problem is,when i choose any of the buttons and click the Submit button,the action is supposed to open a file and write the numeber of times its pressed.i wass using hthe ItemListener() for the RadioButtons and ActionListener for the Submit button,and here is the code.....
    private JRadioButton bg[]=new JRadioButton[bgOptions];
    private String bglabels[]={"A","B","c","d"};
    private JButton Submit=new JButton("SUBMIT");
    private JPanel lpanel=new JPanel();
    lpanel.add(Submit);
    Submit.addActionListener(this);
    public void initBGgroup()
    bgpanel.setBackground(Color.white);
    bgpanel.setLayout(new BoxLayout(bgpanel,BoxLayout.Y_AXIS));
              for (int k = 0;k < 5;k++)
         bg[k]=new JRadioButton(bglabels[k]);
    bg[k].addItemListener(this);
              bgpanel.add(bg[k]);
              optGroup2.add(bg[k]);
              bgpanel.setBorder(BorderFactory.createTitledBorder("ButtonGroup"));
    public void itemStateChanged(ItemEvent e)
    if(e.getStateChange()==ItemEvent.SELECTED)
    JRadioButton b = (JRadioButton)e.getSource();
    try{
    String ss=b.getText();
    System.out.println(ss);
    if (ss=="A")
    DataOutputStream aps=new DataOutputStream(new FileOutputStream("ap"));
    DataInputStream aps1=new DataInputStream(new FileInputStream("ap"));
    Integer ap12=new Integer(aps1.readInt());
    System.out.println(ap12);
         int ap1=ap12.intValue();
    int apto=ap1+1;
    System.out.println(apto);
    aps.writeInt(apto);
    aps.close();
         aps1.close();
    else if (ss=="B")
    DataOutputStream ans=new DataOutputStream(new FileOutputStream("an"));
    DataInputStream ans1=new DataInputStream(new FileInputStream("an"));
    Integer an12=new Integer(ans1.readInt());
         int an1=an12.intValue();
    int anto=an1+1;
    ans.writeInt(anto);
    ans.close();
         ans1.close();
    else if (ss=="C")
              DataOutputStream bps=new DataOutputStream(new FileOutputStream("bp"));
              DataInputStream bps1=new DataInputStream(new FileInputStream("bp"));
    Integer bp12=new Integer(bps1.readInt());
    int bp1=bp12.intValue();
    int bpto=bp1+1;
    bps.writeInt(bpto);
    bps.close();
         bps1.close();
    else if (ss=="D")
         DataOutputStream bns=new DataOutputStream(new FileOutputStream("bn"));
    DataInputStream bns1=new DataInputStream(new FileInputStream("bn"));
    Integer bn12=new Integer(bns1.readInt());
    int bn1=bn12.intValue();
    int bnto=bn1+1;
    bns.writeInt(bnto);
    bns.close();
         bns1.close();
    catch(Exception e1)
    e1.printStackTrace();
    public void actionPerformed(ActionEvent e)
    Object obj=e.getSource();
    if (obj==Submit)
    //apf,anf,bpf,bnf are the textfileds in which the totals r displayed
    read1("ap",apf);
    read1("an",anf);
    read1("bp",bpf);
    read1("bn",bnf);
    public void read1(String st2,JTextField st3)
    try{
    DataInputStream tfdis = new DataInputStream(new FileInputStream(st2));
    int atot=tfdis.readInt();
    Integer alltot = new Integer(atot);
    String display = alltot.toString();
    st3.setText(display);
    is thsi the way to handle,i was getting problem with butoon when i click them...please advice...

    Thanks for the Sugestion..but the problem is with the ItemListener
    it is giving errors at runtime,without going to the submit button
    when i select a button...don't know why?i even changed the ss=="a" to (ss.equals(a))but no luck....

  • JRadioButton Problem

    I'm having a problem using JRadioButtons.
    I can get the background color to change, but is there anyway for the circle part of the radio button to remain solid.
    I.e. if I set the background of the radio button to blue, how do I keep the color of the circle to white, or something other than the background of the button.

    setBorderPainted(boolean b)
    Sets the borderPainted property.
    I Think U can Try This

  • JRadioButton problem...could you help me please?!?

    I've an array of JRadioButton tha are created in a "for struct" but when I try to add an ActionListener the compiler don't like that!!
    here is when I create JRadio button:
    for (cnt = 0; cnt < items; cnt++) {
    cmdID = (int)rMsg.getCIdAt(cnt);
    System.out.println(cmdID);
    radio[cnt] = new JRadioButton(cmdID + ": " + rMsg.getCNameAt(cnt), false);
    radio[cnt].setBackground(new java.awt.Color (250, 250, 200));
    radio[cnt].addActionListener(this); // here comes the problem
    And this is what the compiler sent out:
    ui/ShowMachine.java:95: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (ui.ShowMachine)
    radio[cnt].addActionListener(this);

    I'm sorry the source code was not completed (copy and paste error... ;o) )
    this is the right source:
    radio = new JRadioButton[items];
    ButtonGroup group = new ButtonGroup();
    JPanel ButtonPanel = new JPanel();
    for (cnt = 0; cnt < items; cnt++) {
    cmdID = (int)rMsg.getCIdAt(cnt);
    System.out.println(cmdID);
    radio[cnt] = new JRadioButton(cmdID + ": " + rMsg.getCNameAt(cnt), false);
    radio[cnt].setBackground(new java.awt.Color (250, 250, 200));
    radio[cnt].addActionListener(this); // here comes the problem
    group.add(radio[cnt]);
    ButtonPanel.add(radio[cnt]);
    Compilation ERROR it's reported in my first message!
    thank's for the help
    bye
    ric

  • Problem with JRadioButton

    I have got on a JPanel 2 JRadioButtons link in a ButtonGroup.
    I have also a JTextField.
    Problem: when i have the focus on my JTextField i want
    1. my JRadioButtons to be setEnable(false)->OK!
    2. and i don't want to keep the selection of JButtonRadios.( i dopn't want to keep a selection , i just want something without selection)
    Can you help me please.

    A ButtonGroup is done to have one and only one button select. So You can't do what you want whithout a trick. I sugest you to make a class whtich extends AbstractButton and does nothing. Add it in the group, and select it. I know it's not a very good solution, but it's the one I see for the moment. I looking for another solution.

  • Problem for JRadioButton

    Hi :
    In my applet, I created 3 image radio buttons, using syntex like this:
    JRadioButton Ybutton = new JRadioButton(new ImageIcon(getImage,("./gif/yaxis.gif")));
    than added these 3 buttons into a ButtonGroup. The applet runs without problems in JBuilder testbed. However, if I run it though IE, the push-down effect is gone!
    it act just like a button. I was expecting that if I push one button down, the other will pops up, which is what I saw in Jbuilder environement.
    Any suggestion??
    thank you!
    ls

    Hi :
    In my applet, I created 3 image radio buttons, using syntex like this:
    JRadioButton Ybutton = new JRadioButton(new ImageIcon(getImage,("./gif/yaxis.gif")));
    than added these 3 buttons into a ButtonGroup. The applet runs without problems in JBuilder testbed. However, if I run it though IE, the push-down effect is gone!
    it act just like a button. I was expecting that if I push one button down, the other will pops up, which is what I saw in Jbuilder environement.
    Any suggestion??
    thank you!
    ls

  • JRadioButton Event Handling Problem

    I'm having trouble getting my JRadioButtons to work. They appear and function, but when I click them, they don't do what they should. I used e.getActionCommand() to get the string name of the JRadioButton, and I used e.getSource() to compare it to the name of the radiobutton, which is the same as the text of the button. I read in one of the tutorials that a JRadioButton fires an action event and an item event. Should I use an item event? I'm trying to perform certain actions based on which button is selected. This code sets the string radioname to the name of the button selected, which I later use to perform other actions. I get major errors when I try changing things, because I don't really know how the buttons work. Thanks.
    private JRadioButton d0,d1,d2,d3,d4,d5,d6,d7,d8,d9;
    public void actionPerformed(ActionEvent e)
    if (e.getSource() == "d0" || e.getSource() == "d1"                || e.getSource() == "d2" || e.getSource() == "d3"                || e.getSource() == "d4" || e.getSource() == "d5"                || e.getSource() == "d6" || e.getSource() == "d7"                || e.getSource() == "d8" || e.getSource() == "d9")
         radioname = e.getActionCommand();
              System.out.println(radioname);
              System.out.println("radio event fired");
    }

    I tried that, but that gives me a bunch of error messages, mostly from java.awt about dispatch events and dispatch threads when I click one of the buttons. Does it have something to do with the ButtonGroup the JRadioButtons are in? This is the end of the errors, which is all I can view.
    at javax.swing.JToggleButton$ToggleButtonModel.setPressed(JToggleButton.
    java:268)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
    istener.java:216)
    at java.awt.Component.processMouseEvent(Component.java:3715)
    at java.awt.Component.processEvent(Component.java:3544)
    at java.awt.Container.processEvent(Container.java:1164)
    at java.awt.Component.dispatchEventImpl(Component.java:2593)
    at java.awt.Container.dispatchEventImpl(Container.java:1213)
    at java.awt.Component.dispatchEvent(Component.java:2497)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
    at java.awt.Container.dispatchEventImpl(Container.java:1200)
    at java.awt.Component.dispatchEvent(Component.java:2497)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:339)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
    read.java:131)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
    ad.java:98)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)

  • JTable JradioButton problems

    Hello everybody!
    Can you give me an example how to create JTable with some radiobuttons in cell (e.g. 4 in every cell)?
    and my second question is : is it possible to create jtable with cells containing another jtable? if answer to this (second) question is "yes" please can you tell me how to do it?
    Thank you for all replies!
    Regards !
    mw

    You where given an answer in your previous posting. The answer was to search the forum. You where even given the keywords to use. You have waited a day for an answer when you could have had the answer in a couple of minutes if you bothered to do a quick search of the forum first.

  • Can some one help me with this problem with my frame???

    i have gt a veri strange problem with my program,that is teh graphic changes only when i resize the the frame,if i dun resize,it will remain the same.However what i intended is that when i click on the radio button,it will change immediately to the respective pages.A simple version of my code is below,can someone helpl me solve it??(there is 3 different class)
    import java.awt.event.*;
    import javax.swing.*;
    public class MainPg extends JFrame implements ActionListener{
         private javax.swing.JPanel jContentPane = null;
         private javax.swing.JPanel buttons = null;
         private javax.swing.JRadioButton one = null;
         private javax.swing.JRadioButton two = null;
         private javax.swing.JPanel change = null;
         public MainPg() {
              super();
              initialize();
         private void initialize() {
              this.setSize(300, 200);
              this.setContentPane(getJContentPane());
              this.setName("mainClass");
              this.setVisible(true);
         private javax.swing.JPanel getJContentPane() {
              if (jContentPane == null) {
                   jContentPane = new javax.swing.JPanel();
                   jContentPane.setLayout(new java.awt.BorderLayout());
                   jContentPane.add(getButtons(), java.awt.BorderLayout.WEST);
                   jContentPane.add(getChange(), java.awt.BorderLayout.CENTER);
              return jContentPane;
         private javax.swing.JPanel getButtons() {
              if(buttons == null) {
                   buttons = new javax.swing.JPanel();
                   java.awt.GridLayout layGridLayout1 = new java.awt.GridLayout();
                   layGridLayout1.setRows(2);
                   layGridLayout1.setColumns(1);
                   ButtonGroup group=new ButtonGroup();
                   group.add(getOne());
                   group.add(getTwo());
                   buttons.setLayout(layGridLayout1);
                   buttons.add(getOne(), null);
                   buttons.add(getTwo(), null);
              return buttons;
         private javax.swing.JRadioButton getOne() {
              if(one == null) {
                   one = new javax.swing.JRadioButton();
                   one.setText("One");
                   one.setSelected(true);
                   one.addActionListener(this);
                   one.setActionCommand("one");
              return one;
         private javax.swing.JRadioButton getTwo() {
              if(two == null) {
                   two = new javax.swing.JRadioButton();
                   two.setText("Two");
                   two.addActionListener(this);
                   two.setActionCommand("two");
              return two;
         private javax.swing.JPanel getChange() {
              if(change == null) {
                   change = new javax.swing.JPanel();
              change.add(new One());
              return change;
         public static void main(String[] args){
              new MainPg();
         public void actionPerformed(ActionEvent e) {
              change.removeAll();
              if("one".equals(e.getActionCommand())){
                   change.add(new One());
              else{
                   change.add(new Two());
              change.repaint();
    import javax.swing.*;
    public class One extends JPanel {
         private javax.swing.JPanel jPanel = null;
         private javax.swing.JLabel jLabel = null;
         private javax.swing.JPanel jPanel1 = null;
         private javax.swing.JLabel jLabel1 = null;
         private javax.swing.JLabel jLabel2 = null;
         public One() {
              super();
              initialize();
         * This method initializes this
         * @return void
         private void initialize() {
              this.setLayout(new java.awt.BorderLayout());
              this.add(getJPanel(), java.awt.BorderLayout.NORTH);
              this.add(getJPanel1(), java.awt.BorderLayout.WEST);
              this.setSize(300, 200);
         * This method initializes jPanel
         * @return javax.swing.JPanel
         private javax.swing.JPanel getJPanel() {
              if(jPanel == null) {
                   jPanel = new javax.swing.JPanel();
                   jPanel.add(getJLabel(), null);
              return jPanel;
         * This method initializes jLabel
         * @return javax.swing.JLabel
         private javax.swing.JLabel getJLabel() {
              if(jLabel == null) {
                   jLabel = new javax.swing.JLabel();
                   jLabel.setText("one");
              return jLabel;
         * This method initializes jPanel1
         * @return javax.swing.JPanel
         private javax.swing.JPanel getJPanel1() {
              if(jPanel1 == null) {
                   jPanel1 = new javax.swing.JPanel();
                   java.awt.GridLayout layGridLayout2 = new java.awt.GridLayout();
                   layGridLayout2.setRows(2);
                   layGridLayout2.setColumns(1);
                   jPanel1.setLayout(layGridLayout2);
                   jPanel1.add(getJLabel2(), null);
                   jPanel1.add(getJLabel1(), null);
              return jPanel1;
         * This method initializes jLabel1
         * @return javax.swing.JLabel
         private javax.swing.JLabel getJLabel1() {
              if(jLabel1 == null) {
                   jLabel1 = new javax.swing.JLabel();
                   jLabel1.setText("one");
              return jLabel1;
         * This method initializes jLabel2
         * @return javax.swing.JLabel
         private javax.swing.JLabel getJLabel2() {
              if(jLabel2 == null) {
                   jLabel2 = new javax.swing.JLabel();
                   jLabel2.setText("one");
              return jLabel2;
    import javax.swing.*;
    public class Two extends JPanel {
         private javax.swing.JLabel jLabel = null;
         public Two() {
              super();
              initialize();
         * This method initializes this
         * @return void
         private void initialize() {
              this.setLayout(new java.awt.FlowLayout());
              this.add(getJLabel(), null);
              this.setSize(300, 200);
         * This method initializes jLabel
         * @return javax.swing.JLabel
         private javax.swing.JLabel getJLabel() {
              if(jLabel == null) {
                   jLabel = new javax.swing.JLabel();
                   jLabel.setText("two");
              return jLabel;
    }

    //change.repaint();
    change.revalidate();

Maybe you are looking for

  • Adobe Creative Cloud does not register all of my Adobe programs.

    Adobe Creative Cloud properly shows my Adobe Photoshop CS6 as registered.  However, it does not show my Adobe Acrobat XI Pro, or my Adobe Photoshop Lightroom 4.4 as registered.  How can I get these programs to be properly registerd as "MY APPS" in Ad

  • Multiple OC4J containers on OAS 10.1.2

    We've had problems with sporadic lockup/failure of our OAS 10g (v10.1.2.0.2) app server. We suspect it is something to do with a particular application that serves as a kind of menu to other apps. It uses a lot of ADF controls and is highly abstracte

  • RoboHelp 8 for AIR - Comment Feature

    I'm currently using RH7. I noticed in the marketing blitz for RH8 it mentions that the RH packager for AIR allows user comments to be posted within your help project. I'm trying to understand if this means: a. User makes comment on their C drive for

  • ITunes won't let me watch videos.

    I have imported a film, from disk, on to my Mac. It says that it is an MPEG4 and the file extension is .mp4. However, when I try and drag it into iTunes, nothing happens and the videos I already had on there won't play. I recently upgraded to a newer

  • Permanent deletion

    i like the idea of time machine. but once in a while i want to get delete something without backing it up. how do i permanently delete one or more files (adult films, financial statements, adult films) but still have time machine back up the rest of