3 Replies Latest reply: Oct 17, 2007 8:46 AM by 807592 RSS

    hi how to display several messages on a panel

    807587
      hi i m just a newbie in gui

      now im just tried to use JLabel to display messages..

      but i don't know how to display multiple messages,,

      in my program, when each time my JButton is clicked, new panel is

      pop up, so i press a button five times, five panels pops up...

      but i want to display several messages continously in one panel..

      how do you do it..thx..
        • 1. Re: hi how to display several messages on a panel
          807587
          there is a method called setText(java.lang.String) in JLabel which sets the text on the Label that will solve your problem
          • 2. Re: hi how to display several messages on a panel
            camickr
            Use a JTextArea and append a new line of text every time the button is pressed.
            • 3. Re: hi how to display several messages on a panel
              807592
              I got this and I can set the text property of a label or textbox, etc.
              Now, I need to set the text property of panel A from panel B. When I try this, I get an error message. I tried to set the property directly, and I also created a method in panel A and called it from panel B.

              The message is "non-static method setjTextArea1(java.lang.String) cannot be referenced from a static context".

              This kind of thing is very easy in VB.
              Thanks for your help!

              Here is sample code:

              package shul;
              public class DummyClass {  // this is panel B
              public DummyClass() { } //constructor
              public void dummy(){
              new Menu().setjTextArea1("Now in DB Method");
              //non-static method setjTextArea1(java.lang.String) cannot be referenced from a static context
              }
              }