Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to update JLabel of parent JFrame?

Posted on 2002-03-08
3
Medium Priority
?
495 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

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…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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

722 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