Solved

How to update JLabel of parent JFrame?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Protect jar file - windows app 2 39
How to parse custom JSON to POJO java 4 56
Java / Linux and Regular Expressions 11 71
factorial example 4 35
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
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…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

895 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

13 Experts available now in Live!

Get 1:1 Help Now