swingworker

How do I make my SwingWorker example work properly?

送分小仙女□ 提交于 2019-12-17 02:38:07
问题 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;

How do I simulate a buffered peripheral device with SwingWorker?

有些话、适合烂在心里 提交于 2019-12-17 02:26:08
问题 I'm using this exercise as a pedagogical tool to help me burn in some Java GUI programming concepts. What I'm looking for is a general understanding, rather than a detailed solution to one specific problem. I expect that coding this "right" will teach me a lot about how to approach future multi-threaded problems. If this is too general for this forum, possibly it belongs in Programmers? I'm simulating a card reader. It has a GUI, allowing us to load cards into the hopper and press Start and

System.in points to JtextArea and using Scanner with it causes application to hang

戏子无情 提交于 2019-12-14 03:26:48
问题 I've got a JFrame that contains a single JPanel that contains a single JTextArea. I've successfully managed to point System.out to the JTextArea, but when I try to use Scanner(System.in) to parse input from the JTextArea, it doesn't even seem to load anything. As in, when I build and run the application, nothing happens, no frame is presented. Here is my code: /** * Create the frame. */ public TerminalForm() { setTitle("Terminal"); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds

Swing Worker Modal Dialog Won't Close

*爱你&永不变心* 提交于 2019-12-14 02:14:00
问题 I have a SwingWorker thread that launches a modal dialog box (from a property change listener that listens to the StateValue of started) and the swing worker proceeds to do its work. However, it looks like the done method is not called because that is called on the EDT but the swing worker's modal dialog is blocking the EDT. So, I can't close the dialog from the EDT (or from the done method). Right now I'm just closing the dialog from the doInBackground at the end of that method, but that

java - Progress Bar - Is it possible to use setProgess() of Progress Bar outside the doInBackground() method?

拜拜、爱过 提交于 2019-12-13 16:29:30
问题 If I had a method inside the doInBackground() that belongs to other class is it possible to set setProgess() based on changes that happen in that other method of an outside class? 回答1: You state: but when I put setProgess() inside the method of another class it tells me that I need to make that method. This has nothing to do with SwingWorker and all to do with basic Java. No class can call another classes instance (non-static) methods without doing so on a valid instance of the class. For

Multithreaded GUI in the MVC model

时间秒杀一切 提交于 2019-12-13 04:56:50
问题 I have gone through a ton of postings regarding GUI in the MVC model and where to put code and in which thread. MadProgrammer and trashgod have put me in the right direction, but there are things I still don't understand. In my main class I have the following code import java.awt.EventQueue; import javax.swing.JOptionPane; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import common.InitParameters; import common.OraLogin; import common.ThresholdValues;

Correct design to prevent blackscreen issue in JFrame

两盒软妹~` 提交于 2019-12-13 04:46:28
问题 In my application I have a main frame window GUI , that launches a task in an executor service. The submitted task generates output and stores in a file on Disk . As soon as the o/p is generated GUI (observer) is informed of the o/p generated. Here the problem is I am keeping a wait loop inside the main frame and as soon as a notification is received, the main panel is repainted on the main frame. For small tasks this works fine, but as the size of the threaded task increases. The wait loop

How to make multi thread with SwingWorker?

北城以北 提交于 2019-12-13 04:26:37
问题 I saw a Topic about multi thread here : Multi-threading with Swing So I do as the answer https://stackoverflow.com/a/33908340/11445086 I implement like codes below but there's not anything movement here. I know the problem is about my doInBackGround and process implementation but I don't know how to do.I'm really new with Swing Builder so sorry if the question's silly. The program just makes many circles moving in the Panel. And each circle is a Thread that be made by Swing Worker. these're

Multi-threading with Swing

左心房为你撑大大i 提交于 2019-12-13 02:33:30
问题 I am trying to write a multi-thread program with Swing. Essentially how the program works is that when it runs it will have a robot(represented by a circle in screenshot) that is wondering around in a field. This robot should be controlled by a thread of it's own. The program has a button "Launch Robot" that will create another robot on the field(upto a max of say 10). Right now I have the basics of the program, but it all runs under one thread. I can launch as many robots as I want but they

Retrieving data from a map when using a SwingWorker

放肆的年华 提交于 2019-12-13 01:34:38
问题 I have a class that creates a GUI and has a JComboBox with an ItemListener. On an ItemEvent.Selected event I create the worker and try to read data into a map, but the contents is always empty. My guess is that this is happening due to the thread executing and leaving the ItemListener before the thread completes. I've added relevant pieces of my code and hoping you guys can help me determine where the issue is. private void updateUI(String text) { StringUtilities.invokeLater(new Runnable() {