swingworker

Repeat SwingWorker

落爺英雄遲暮 提交于 2019-12-13 01:29:09
问题 I want to build a JFrame able to run a background task every time a JButton was clicked.currently i am using a swing worker and it wont allow the task to be executed more than once. How can I enable repetition task for SwingWorker with JButton click. public class ScanFileFrame extends JFrame{ JButton btnTicking; JLabel label1; ScanFileFrame(){ JFrame jframe = new JFrame(); jframe.setLayout(new FlowLayout()); btnTicking = new JButton("Start Scanning Files"); label1 = new JLabel("No File

Calling super.approveSelection() within a SwingWorker

跟風遠走 提交于 2019-12-12 21:19:55
问题 I have a customized JFileChooser Its approveSelection() method is slightly modified: public void approveSelection() { File file = getSelectedFile(); changeGui(); final Object a = makeALongCalcualtion(file); if (a != null) { super.approveSelection(); SwingWorker<Document, Void> open = new SwingWorker<Document, Void>() { @Override protected Document doInBackground() throws Exception { return createADocument(a); } @Override protected void done() { try { if(get() != null) { changeGui(); } else {

Dialog isn't responsive while SwingWorker works in the background

别等时光非礼了梦想. 提交于 2019-12-12 20:20:17
问题 Basically I got a JFrame with a main method as entry point. In this main method the program has to download some images. To inform the user that the program is going to start any minute I want to display a simple dialog. If I set the dialog to modal. I got to close it after starting the program to trigger the download. If I set it to non-modal it displays the dialog for the time of the download, but it's not repsonsive. The dialog doesn't even paint my JLabel saying "Please wait..." anymore.

Why my GUI won't update even tho repaint() is being called?

独自空忆成欢 提交于 2019-12-12 10:18:57
问题 I am having some difficulties using swing workers, timers, and I am actually a little confused. As far as my understanding goes, I have to put on a timer to set-up recurring tasks that have to be called by the EDT. I'm trying to make a program that shows graphically a sorting alghoritm (like this : https://www.youtube.com/watch?v=kPRA0W1kECg ) I just don't understand why the GUI won't refresh. I am quite sure the repaint method is being called since I put a sysout showing me the ordered

DefaultTreeCellRenderer() execute periodically

一世执手 提交于 2019-12-12 04:54:06
问题 I write some program for monitoring processes on unix server. The main part of my code is looking like this: Class FeedMonitor { //............. private volatile boolean monitor = true; private volatile String feedShRez; private volatile DefaultMutableTreeNode envNode; //............. public void prepareGUI() { //.............. // SwingWorker worker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { sh = new Shell(env); System.out.println("Swing

Java Swing ProgressBar update while computing

房东的猫 提交于 2019-12-12 03:45:32
问题 There are some example for similar question (Progress Bar Java) and (Java uploading percentage progressbar thread) but didn't understand how to make it work for my code. My main has 2 panels one over the other (one of which is a tabbedPane with 2 tabs) public class MainIRH { public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override public void run() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException |

I am stuck with a compilation error in Swing Worker?

瘦欲@ 提交于 2019-12-12 03:43:56
问题 I wrote a class that extends SwingWorker. I wrote overriden functions: doInBackground, done, and process, but for some reason I am getting compilation error: The method process(List) of type BillImportAnalyzerGUI.Task must override or implement a supertype method Here is my class: private class Task extends SwingWorker<Void, Void> { @Override public Void doInBackground() { try { generateReport(BillImportId.getText()); } catch (InterruptedException e) { } catch (Exception e) { } publish();

Problems in using SwingWorker class for reading a file and implementing a JProgressBar

被刻印的时光 ゝ 提交于 2019-12-12 03:26:44
问题 Note: This question may look like a repetition of several question posted on the forum, but I am really stuck on this problem from quite some time and I am not able to solve this issue using the solutions posted for similar questions. I have posted my code here and need help to proceed further So, here is my issue: I am writing a Java GUI application which loads a file before performing any processing. There is a waiting time on an average of about 10-15 seconds during which the file is

Java Threading - Swing app

余生颓废 提交于 2019-12-12 02:33:41
问题 I'm trying to learn how to thread a class (specifically a method in a class) and I've come across Thread() and SwingWorker() . This is a swing application. Which should I choose and why? Also, is there some generic way to add implementation for threading to existing methods? Thanks 回答1: SwingWorker is mainly for executing background processes in Java Swing means UI based application , like on pressing a Button in a UI , you want some long process to happen in Background. Thread is normally

SwingWorker - Passing parameters and returning an ArrayList<Object>

左心房为你撑大大i 提交于 2019-12-12 01:44:49
问题 NOTE: SSCCE at the end of this question I'm new to SwingWorker so please bear with me. I'm using a GUI and when the user presses a button it executes some methods I've in another class. This class just has methods inside and I need those methods to run on their own thread. The thing is, those methods need to be passed arguments and they will also return something needed to other methods. Something like this: public class MyClass { public ArrayList<Train> proccessTrain(int endTime, int