GUI 2 « Thread « Java Swing Q&A





1. Swing & Thread problem    coderanch.com

Hello, I've got a question. My application, which is a GUI application using Swing has a bug. I think it involves threads. My application schedules opening a software on my HD.(using RunTime class) Now, the program is starting to load (vuze) and get 'stuck' while loading, and it continues only when I click on my application on a different tab. (i ...

2. threads for GUI and command-line    coderanch.com

I have a command-line program and I'm trying to give it a GUI gradually. So, what I have now is a point in the program where the command line is waiting for user input, and at the same time, there is a button on the GUI that is supposed to do something when pushed. I experimented a little, pushing the button, ...

3. finding non-daemon threads    coderanch.com

Hello, I am currently having a problem with java.exe processes hanging around after my swing app has been closed. I assume that I have some non-daemon threads hanging around that are preventing my app from shuting down. What is the best way to debug this? I.E. hwo do I tell what threads are hanging around and maybe where they were created? ...

4. How to activate threads in Swings.    coderanch.com

as this is your stated problem > how can i call a method using thread which hve to run till da prgm exit. forget your program for the moment, and just write a sample program, jframe with a Jbutton and actionlistener to do your thread stuff (can be just a System.out.println) have a go, and if you can't work it out, ...

5. when to use threads in swing applications?    coderanch.com

thanks for the reply, so every event(action,item,mouse,key) has to be handled in a separate thread.... i had developed swing application using netbeans IDE, and i haven't considered to handle the event associated with swing components in a separate thread.... Is there any further steps, i have to consider for improving the performance and quick response of the swing applicaion...

6. Getting "SWTException: Invalid thread access"    coderanch.com

Main class public void mainscreen() { GridLayout gl = new GridLayout(); gl.numColumns = 2; s.setLayout(gl); Color c = d.getSystemColor(SWT.COLOR_WHITE); s.setBackground(c); sideBar(); workSpace(); s.setMaximized(true); s.open(); while (!s.isDisposed()) { if(!d.readAndDispatch()) d.sleep(); } d.dispose(); } public void sideBar(){ Composite sideBar = new Composite(s,SWT.NONE); GridLayout sideBarLayout = new GridLayout(); GridData sideData = new GridData(GridData.FILL_VERTICAL); sideData.widthHint = 200; sideData.verticalIndent = -8; // sideData.horizontalSpan = 2; sideBar.setLayoutData(sideData); ...

7. Client/Server GUI hanging up - Brocard's Problem - Running multiple client threads    coderanch.com

I've created a server and client class along with a GUI which tests out Brown numbers (solutions to Brocard's problem, n! + 1 = m^2). I am testing every value of n starting at 1 up to and beyond 10^9. I connect to the server but when I press the client thread 'Start Client" button the program begins the computations but ...

8. Excprion throw running Swing application using thread    coderanch.com

I'm developing swing application using netbeans 6.5. one of my form this error happen. Inside showCutomerData method there is a table and i assign values for table fields, and erros happen after after calling therad, it calls showCutomerData method and below show code(without thread no exception) /// table public void showCutomerData(int states) { try { CustomerQuery custQue1 = new CustomerQuery(); ResultSet ...

9. Update GUI components from another thread.    coderanch.com

It has been a while since I last had the chance to do anything with Swing or AWT, so I am a little bit rusty to say the least, so be kind and bare with me. I have a program that I wrote a while back that I would like to replace the console output with a simple GUI. The original ...





10. Thread PaintComponent    coderanch.com

I have the method PaintComponent that I want to invoke every second, to update my drawn image. When I put repaint() in my run method it doesn't invoke the paintComponent(). The run method is being executed but it doesn't call the paintComponent(); @Override public void paintComponent(Graphics g) { System.out.println("Class: LoadImage, Method: Paintcomponent"); g.drawImage(img, 0, 0, null); g.setColor(Color.GREEN); //Omzetten van snelheid naar ...

11. observers and threads    coderanch.com

hi. i just want to ask for ideas. i have swing components that observe via Observer while i have a class that does the publishing by calling the setControlName() method when i use threads, i publish messages but my problem is that the public void update(Observable o, Object arg) method does not get called by all threads. i tried to place ...

12. What causes deadlock in GUI?    coderanch.com

i have been reading this book called Begining Java2 by Ivor Horton - Wrox publication. in the chapter for event handling the author says because events are processed in a separate thread from the main thread, you must not modify or query the GUI for an application from the main thread once the GUI has been displayed or is ready to ...

13. swing and threads    coderanch.com

hi, need help in pointing to the right direction. writting a swing app using netbeans. the apps starts a single runnable thread (thread 1) and retrieves some URL and updates the (DefaultTableModel)jTable1.getModel().addRow() just fine. i moved retrieval of the URL into another Runnable class (static class getURL implementes Runnable_. i'm able to run multiple concurrent threads from "thread 1". however, i'm ...

14. Registering Thread in RCP    coderanch.com

Hi freinds, I am bulding RCP application in which i need to run a class in prallel thread to my RCP aapllication,as soon as i start the new thread RCP aaplication endups in exception "Invalid Thread Access" could anybody please tell me how to register a thread in RCP so that my thread will run in parallely.

15. thread problem    coderanch.com

16. Reduce CPU usage for a thread    coderanch.com

I use a thread that does nothing much except call "repaint()" method. it's something like this : while(true) { Thread.sleep(10); x++; repaint(); } Its CPU usage is very high, about 25%. I need to reduce that as it is causing trouble in other applications running on the machine. How do i do that?





17. Multithreading    coderanch.com

i did this as an example, refering to it!!! so i want an idea on the multitreading screen saver that extends JPanel import javax.swing.JPanel; import java.awt.Graphics; import java.util.concurrent.Executors; import java.util.concurrent.ExecutorService; public class BallsPanel extends JPanel implements Runnable { private Ball balls[] = new Ball[2]; ExecutorService threadExecutor = Executors.newFixedThreadPool(2); public BallsPanel() { } public void start(int i, int x, int y, int ...

18. General Threading!    coderanch.com

Hey there guys! I am working with swing for the first time( yes it has been an ongoing couple of weeks of "first-time") and i am in the process of speeding up my program. From what i read online, threading is a great way to do this! The GUI i have created has a few buttons that execute database queries, and ...

19. Runnable Thread to update GUI components    coderanch.com

Hi, I have a GUI with some fields and they get updated when I start a class that implements Runnable. I'm being forced to send the components in the class constructor in order for them to be used on the Runnable Thread side. For instance lets say I have a Jlabel that is a counter and that in my Runnable class ...

20. Thread got stuck?    coderanch.com

21. Gui and Thread    coderanch.com

Hi, I have a GUI which has a progress bar which is setInderterminate(true), and this is called from the base class. The base class also calls a thread which executes a process and waits for it to finish. The base class goes into a while loop untill the gui with the progress bar closes. I believe this shouldn't happen. Here is ...

22. Framework for GUI with computationally intensive threads    coderanch.com

Hi, I'm looking for suggestions for a framework GUI with computationally intensive threads. Practically, the GUI should have a button that starts one manager thread. That manager thread will start a number (about 20 to 40) of worker threads that are computationally intensive and each thread runs for about an hour. The worker threads should report progress / messages back to ...

23. Threads in applications    coderanch.com

To not block the user interface. Let's say you create your own web browser. When a link is clicked, the contents of the linked page must be retrieved. This may take a long time, especially if the server the page is on is having problems. If you retrieve the contents from the event dispatcher thread your entire user interface will not ...

24. Painting with threads using paint/repaint() and run()    coderanch.com

I want to paint a big amount of data in a thread with some delay in betwenn. I want to be able to stop and start the painting. As using graphics you have to draw with the paint() method. The examples I saw used a repaint() mehtod in the run method of the tread. It should be possible too, to enter ...

25. My GUI newbie thread    java-forums.org

okey, one thread per question. btw, I think I will ditch the idea about that spinning loading thing(its to confusing, I get back into it later). Instead, I am trying to create a JDialog that is semi-modal. Example, I when my program is encrypting a file, there should be a modal JDialog(without any buttons) that should say "Please wait, program working...". ...

26. Threading A GUI question    forums.oracle.com

27. GUI, need help with threading    forums.oracle.com

You must never lock the GUI up by doing a long activity, you are right that you need a thread to do that. what you also need is to do all GUI activity on the Event Dispatch Thread, so you will need to use the SwingUtilities.invokeLater method. Or look int the SwingWorker class.

28. Swing/Threads, changing the GUI    forums.oracle.com

} public void run() { // does stuff here that sets the isGood var } public bool getIsGood() { return this.isGood; } } //GUI public class Visualizer { private static Listener listener; public Visualizer(Listener listener){ this.listener = listener; javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } private static JFrame frame; private static JLabel status; public static void createAndShowGUI() ...

29. Passing info from thread back to GUI    forums.oracle.com

Wait, you get the null pointer exception (or at least, you will, if it turns out that another one is currently coming up first) because you're dereferencing rentalShopWindow without ever setting it to a new RentalShopWindow object. BTW, where does contract get the values returned by getNRentalItems and getRentalItem? Does the constructor implicitly create those values? Also I can't help wondering ...

30. GUI's, Threads, and Return Values    forums.oracle.com

Think about what you are doing. You are creating a thread in order to create the gui at the same time the thread is interacting with the user. Then you are asking the main program to wait for a return value before continuing on. Did you really expect both of those to work great together? I am not sure I understand ...

31. How to setup threads in my GUI    forums.oracle.com

Hi, ok so I wasnt using timers before. The problem is now how do I properly setup the timers. I tried putting a timer in which would call paintComponent on the object that needs to be drawn. My code is setup as follows There is a method that does some processessing and continuously manipulates an object (say A) which loops for ...

32. GUI updating from I/O thread    forums.oracle.com

Hello, Can anyone recommend an appropriate method of signalling/messaging the GUI/event thread when all socket I/O is being handled in a separate thread? Is there a specific class or design pattern for this (I would presume) common problem? I needs a means of providing updates to a 2D display when "messages of interest" are received in the I/O thread. I was ...

33. help with gui (maybe threading issue)    forums.oracle.com

You are definitely going to need use a thread. You might also want to check out Timer and TimerTask (still requires a thread) You also might want to search google for my KeyboardCommands.java class. It makes it so you don't have to be focused on your panel to use the keyboard Edited by: tjacobs01 on May 26, 2008 12:04 PM

34. Threading a GUI    forums.oracle.com

I was wondering if anybody could help me with threading a gui. I am attempting to write a program that calls upon another class that performs an invinite loop, but sleeps for a given time. Well the problem is when I invoke that class My Gui becomes unresponsive which clearly indicates that I need to Thread my GUI, but I have ...

35. Help Code In (GUI and Threads )    forums.oracle.com

36. Why are threads being created for each component in a GUI program?    forums.oracle.com

and the output from that code is this: thread count at beginning of main: 1 thread count after making 3 buttons: 4 thread count after constructing JFrame: 4 thread count after making JFrame visible: 5 thread count at end of main: 5 So I was wondering if anyone could explain why new threads are created, or give me a link to ...

37. GUI and refresh Thread    forums.oracle.com