swingworker

Pause and Resume SwingWorker.doInBackground()

只谈情不闲聊 提交于 2019-12-18 05:22:28
问题 I have a basic Swing UI with a single button marked "Play." When the button is pressed the label changes to "Pause". When the button is pressed now it changes to say "Resume." On "Play" I am instantiating and executing a SwingWorker. What I would like is to be able to pause this thread (NOT cancel it) and resume it according to the button presses described above. However, I'd prefer not to resort to Thread.sleep() in doInBackground(). That seems a bit hackish. Is there any way for the thread

How to return value from SwingWorker class and use in other class and enable MenuItem when process is done?

蓝咒 提交于 2019-12-17 22:59:38
问题 I am using SwingWorker class to make a process run in another thread. What I want is, once this thread has finished processing, it should return a String and also it should enable a JMenuItem . I am using the done() method in the SwingWorker class to enable the JMenuItem but I receive a NullPinterException . The doInBackground() method returns a String which I want to access in the main GUI class - GUIMain.java , present in the same package. How should I do that? I saw many examples which

getting the cancel event of Java ProgressMonitor

一个人想着一个人 提交于 2019-12-17 20:49:33
问题 I have a ProgressMonitor pm and a SwingWorker sw . I want to cancel the SwingWorker when I press the cancel -button on pm . I guess this shouldnt be too hard, and I read some tutorials about SwingWorker and ProgressMonitor, but I can't get this to work. final ProgressMonitor pm = new ProgressMonitor(frame, "checking", "...", 0, 100); final SwingWorker sw = new SwingWorker() { protected Object doInBackground() throws Exception { doSomethingAndUpdateProgress(); } }; sw.addPropertyChangeListener

Why does SwingWorker stop unexpectedly?

那年仲夏 提交于 2019-12-17 16:56:17
问题 I wanted to try out some ideas using SwingWorker since I haven't used it too much. Instead, I ran into an issue and I can't figure out what's wrong. Here's a short SSCCE that demonstrates this problem (I know people here like SSCCEs): import javax.swing.SwingUtilities; import javax.swing.SwingWorker; public class SwingWorkerTest { public static void main (String[] args) { SwingUtilities.invokeLater (new Runnable () { @Override public void run () { new MySwingWorker (500).execute (); new

Multiple graphs in multiple figures using jFreeChart

ぐ巨炮叔叔 提交于 2019-12-17 09:59:47
问题 I am trying to use jFreechart to generate two figures each of which with 12 graphs (being referred as series in jFreeChart ). However some of the graphs get simply skipped! I know I have synchronization issue here and tried to used the method the user @trashgod provided me here however I failed. I know the way I use swingworker is wrong ! I dont know how to fix it Each figure should contain 10 graphs which are parallel horizontal straight lines. As you see in the attached image some of the

SwingWorker does not update JProgressBar without Thread.sleep() in custom dialog panel

☆樱花仙子☆ 提交于 2019-12-17 07:53:10
问题 I have a SwingWorker class which loads a text file and slices it to chunks for further processing. This is the SwingWorker class: public class ConverterWorker extends SwingWorker<String, String> { private final File f; private final JLabel label; public ConverterWorker(File f, JLabel label) { this.f = f; this.label = label; } @Override protected String doInBackground() throws Exception { NMTMain.convertableData = getDataSets(f); if(!NMTMain.convertableData.isEmpty()) { return "Done"; } else {

GUI running at 30 fps?

ぐ巨炮叔叔 提交于 2019-12-17 05:14:12
问题 While testing some real-time simulation code which uses a Swingworker I noticed my GUI always seems to run at 30 fps, no more, no less. I update the GUI everytime the user interacts with the application (like a mouse move) or when the process() method of the Swingworker is called. The Swingworker doesn't do anything right now, it just grabs the mouse location from the GUI and sends it back as a clone through the publish() and process() methods (I'm just doing this to see what I can and can't

GUI running at 30 fps?

余生长醉 提交于 2019-12-17 05:13:17
问题 While testing some real-time simulation code which uses a Swingworker I noticed my GUI always seems to run at 30 fps, no more, no less. I update the GUI everytime the user interacts with the application (like a mouse move) or when the process() method of the Swingworker is called. The Swingworker doesn't do anything right now, it just grabs the mouse location from the GUI and sends it back as a clone through the publish() and process() methods (I'm just doing this to see what I can and can't

SwingWorker in Java [closed]

故事扮演 提交于 2019-12-17 02:51:37
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I have a problem. I have a JFrame . It will create a JDialog . When button on JDialog is pressed it should be disposed and an email

How do I make my SwingWorker example work properly?

梦想的初衷 提交于 2019-12-17 02:38:09
问题 I've made my own SwingWorker example to get familiar with how it works. What I'm wanting to do is the following: When the button is clicked I want a progress bar appear until the task is done I want to simply remove the progress bar and add a string to the dialog. When the button is clicked, the progress bar comes up but never goes away. (never removes the progress bar after 10 seconds and never places the label up) Here is an SSCCE: package swingtesting; import java.awt.event.ActionEvent;