Reputation: 1
I am writing a GUI program whose main class extends JFrame
implements ActionListener
. There are a number of elements on the GUI including some custom Widgets that extend JPanel
. The main Window has two instances of one of the Widgets, but only the first one refreshes properly after new data is loaded (the app can load data from a file and fill the ca. 25 fields of the GUI). The second instance of the custom Widget does not react (does not change values) after it has been previously used once. I am sorry there is no way to extract a small code snippet that would reproduce the problem, but I have used the paramString() method of JPanel
(etc).
The first time the widget is used (and everything is OK), I get this: ,197,73,862x82,invalid,layout=javax.swing.GroupLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.border.BevelBorder@2ef5774e,flags=9,maximumSize=,minimumSize=,preferredSize=
The second time the widget is used (and it is not reactive), I get this:
,0,0,0x0,invalid,layout=javax.swing.GroupLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.border.BevelBorder@552d7308,flags=9,maximumSize=,minimumSize=,preferredSize=
I have additionally tried to revalidate() both the widget and its parent, but to no avail, this.myWidget.isValid()
returns false (whereas the same method from other components in my application returns true).
Any ideas?
thanks, Peter
Upvotes: 0
Views: 499
Reputation: 178
I suppose when the widget returns
197,73,862x82,invalid,layout=javax.swing.GroupLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.border.BevelBorder@2ef5774e,flags=9,maximumSize=,minimumSize=,preferredSize=
the first numbers are x=197, y=73, width=862, height=82
. This is just a guess but on the second time you get
,0,0,0x0,invalid,layout=javax.swing.GroupLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.border.BevelBorder@552d7308,flags=9,maximumSize=,minimumSize=,preferredSize=
Which would mean x=0, y=0, width=0, height=0
then i can suggest you to try to manually set the size of your widget an 0x0 size is not a valid size.
Additionnally, i suggest that you change the call of revalidate()
to repaint()
for your Widget because revalidate()
may not repaint the widget itself but only its sub-components
Upvotes: 0