java - Confusion between whether a code should be executed by EDT (Event Dispatch Thread) or not? -
I developed a swing GUI containing 12 JPanel
s. Initially, all the jpnil
s code was written in the main JFrame
class code. As a result, the code became too long (10, 000 + line).
Now I want to reflect the code to divide the code into 13 squares (12 squared each one each)
But I have some confusion Which is as follows:
- Initially those 12
jpgNL
s was set to "card"zpnil
and "card"The layout of the zipinal
was set tocard layout
so that those 12JPNL
s only 1zpnil
based on that button Shown Now when I have separated those 12jepnil
s fromMainJForm
and have implemented each of them in my class, then I have Looks like I need to instantify thisJPanel
first when a user clicks on the button, will it be better to do this heavy work on the EDT (Event Dispute Thread)? If not, what Get it in theswingworker
thread To make an example of epilean will work and a referee will pass
You can set up your panel in the same way as they were all in a class. So if the previous implementation has created all the objects on frame institute, you can instantiate your 12 panel objects in such a way. If this is done as soon as the panel button is clicked, do so.
Where the code has been placed, it should not have any effect on the situation, when executed in this case, there has been no problem at least until before (the button When switching the panel when pressed) ui
Of course, you can first create the panel that is initially shown and then use a swingwalker to others so that the first one is shown immediately. Could and others soon Minister is to be provided, such as clicks buttons instantiate immediately, first. Just make sure you keep in mind to make calls, which currently show UTI (like adding an instant panel to the frame) in the EDT.
Comments
Post a Comment