Solved

How to update JLabel of parent JFrame?

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse argument 14 61
Way to decrease size of apk file 9 67
type mismatch (Object[] to double[] 4 24
What's wrong with this code? 4 23
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

773 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