Solved

How to update JLabel of parent JFrame?

Posted on 2002-03-08
3
458 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 75 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues undeā€¦
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

747 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now