Results 1 to 2 of 2
  1. #1
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Location
    Turkey
    Posts
    380
    Blog Entries
    24
    Rep Power
    3

    Default How to Change a JLabel in a Frame when a Button is clicked?

    I have a JFrame object that has as a field:

    ArrayList<JLabel> arrayFullOfLabels = new ArrayList<JLabel>();

    I have a method:

    void setArrayFullOfLabels()
    {
    for(int i=0;i<5;i++)
    {
    arrayFullOfLabels.add(new JLabel(arrayFullOfDiceImages.get(i)));
    }
    }

    And in my constructor somewhere I call this setArrayFullOfLabels..

    When I run my JFrame, I see the JLabes just fine..

    I also have a button, When I click the button I want the JLabel to change..

    mainFrame.arrayFullOfLabels.set(2, new JLabel("WHYYY!!!"));

    But it is not working..

    Any help?

    ( The actionListener is working just fine and I have mainFrame.validate() and mainFrame.repaint() )

  2. #2
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Location
    Turkey
    Posts
    380
    Blog Entries
    24
    Rep Power
    3

    Default Re: How to Change a JLabel in a Frame when a Button is clicked?

    It's done, thanks..

Similar Threads

  1. returning a string when button clicked
    By droidus in forum AWT / Swing
    Replies: 13
    Last Post: 02-02-2012, 04:50 AM
  2. form appear after ok button clicked
    By sks in forum NetBeans
    Replies: 1
    Last Post: 06-01-2011, 09:50 AM
  3. show panel when button clicked
    By Aggror in forum New To Java
    Replies: 6
    Last Post: 10-14-2010, 05:05 PM
  4. Replies: 4
    Last Post: 02-16-2009, 04:20 PM
  5. Replies: 11
    Last Post: 02-13-2009, 01:52 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
  •