Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to update JLabel of parent JFrame?

Posted on 2002-03-08
3
Medium Priority
?
500 Views
Last Modified: 2007-12-19

I have a JFrame which I call MainDesktop and to which I add a desktopPane for holding JInternalFrames.

desktop = new JDesktopPane();
msgLabel = new JLabel(" ", JLabel.LEFT);

container = this.getContentPane();
container.add(desktop, BorderLayout.CENTER);
container.add(msgLabel, BorderLayout.SOUTH);

One of these JInternalFrames is a LoginFrame. When someone enters an invalid userid/password, I want to display a message in msgLabel of the parent frame MainDesktop. How do I update the label?

TIA
SK Bali





0
Comment
Question by:SKBali
3 Comments
 
LVL 2

Accepted Solution

by:
mzimmer74 earned 300 total points
ID: 6851248
Well, if you pass a reference of MainDesktop to your LoginFrame you can call a method in MainDesktop from LoginFrame (say, setLabelText(String text)) that merely calls msgLabel.setText(text).  I think that'll do what you want.
0
 

Expert Comment

by:maggari
ID: 6854710
If both the frames are local to a class, make the msgLabel global or else if both frames are separate classes themselves, then do what mzimmer74 suggested. This should help.
0
 

Author Comment

by:SKBali
ID: 6857342
Thanks for your help.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question