I have a Frame class (extends JInternalFrame). Inside the class, I create a JPanel and initialize setVisisble(false). After the user clicks on buttom in the frame and does some processing, I call the method inside JPanel to update one of its labels. Then I do setVisible(true)on JPanel.
setVisisble(false)
setVisible(true)
However, JPanel does not βupdateβ correctly after I call setText()on one of its labels. After processing and setting JPanel to visible (and I confirmed that there is correct data, etc.), JPanel is still in its initialized form.
setText()
In other words, what do I need to make the call setText()in JPanel inside the frame refresh the panel?
Basically I am wondering: if you update the label text inside the swing component that is nested inside the JFrame, should the update be visible? What needs to be done to update if not?
Try the following:
myPanel.invalidate()
If this does not work, try sending the code.
why do you even create JPanel ahead of time? why not create it again, with the right text, for the first time?
and every time you change the shortcut, you may need to re-check the panel; those.:
myPanel.validate()
What is this additional panel for? perhaps you should use a dialog; or just adding a JPanel to an existing frame.
. , - , ( ). , , , , , , .
, , , - - - :
JLabels JPanel, setBounds(), x, y, height width. setBounds() , JPanel. , height, width ( getMinimumHeight() .., , ). , , 0. , , setText(), , , 0 ( , !).
JLabels
JPanel
setBounds()
x
y
height
width
height, width
getMinimumHeight()
... setBounds() , setText() ( ).
. , .
- JInternalFrame? , , . , .
, , setText(), , JPanel?
To make changes to your objects in memory fully and correctly applied to the graphical interface, you need to call the validate () and repaint () methods of the corresponding objects. validate () pretends to be a commit operation for recent changes. That way, if you change the label text, you wonβt be able to see the change, even if you call repaint ().
Source: https://habr.com/ru/post/1753601/More articles:Robot.delay (int) vs Thread.sleep (long) - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1753597/my-website-refuses-to-serve-png-files&usg=ALkJrhirUMrB9qKv_JDi-avjTubOrMsYIAhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1753598/debugging-an-exception-that-only-happens-to-exe-but-not-from-ide&usg=ALkJrhjsvCXnkyp4ZGw4kW5BP7bX-af0uwHow to catch exe alarms from the command line - c ++https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1753600/how-do-you-think-reddit-handles-reindexing-their-posts-to-keep-the-accurately-in-order&usg=ALkJrhg9mypgb0GCG0xvT7RkYnFhxiFovgLisp list contains program - common-lispHow to implement corporate search - oracleJMeter test plan entry problem - jmeterNHibernate - set sampling mode on grandchildren's objects - nhibernateCan I call canvas.drawWindow () from the onload handler? - javascriptAll Articles