I have a class that extends JFrame, and two zeppellos on it have a sitemap JPNL and another content display panel Packs on / P>
Based on the changes made to the content display panel, I need to change the labels text in Jeppel to dynamically change the status bar. To achieve this, I have created a separate category for the Statusbar panel with the following code.
public class StatusBar JPanel {JLabel status; / ** StatusBar * / public creates a new instance of StatusBar () {super (); Status = New JLABEL ("Ready and Running"); This.add (status); } @ Override Public Voice Paint Coment (Graphics G) {SuperPaintConન્ટ (G); G.drawString (status.getText (), 10,10); } Public Zero Set Message (String Message) {status.setText ("Status:" + Message); Repaint (); }} I created an object in this class and added it to JFrame. The panel is added, but when I call the message () method set in the after-frame implementation, the message is not being repeated again, i.e. the status panel does not refresh the status message. How can I solve this issue?
PS: For every change in the situation, I just want to refresh the status panel every time, because the above code is there any way to do this?
You do not need paintComponent call ... do this Should: public class status bar JPNL [jlabal status; Public Status Bar () {this.SsetLayout (New Flow Layout (Flow Layout. LEFT, 5, 0)); Status = New JLABEL ("Ready and Running"); This.add (status); } Public Zero Set Message (String Message) {status.setText ("Status:" + Message); }} Or you can actually use just one square which extends the JLabel ; Public class StatusBar Expands JLabel {Public StatusBar () {SetMessage ("Ready and Run"); } Public Zero Set Message (String Message) {setText (Message); }}
Comments
Post a Comment