Questions tagged [swingutilities]
121 questions
92
votes
3 answers
Java Mouse Event Right Click
On my three button mouse MouseEvent.BUTTON2= Middle Click and MouseEvent.BUTTON3 = Right Click.
Is this the case on a two button mouse?
Thanks

DD.
- 21,498
- 52
- 157
- 246
86
votes
4 answers
Java/Swing: Obtain Window/JFrame from inside a JPanel
How can I get the JFrame in which a JPanel is living?
My current solution is to ask the panel for it's parent (and so on) until I find a Window:
Container parent = this; // this is a JPanel
do {
parent = parent.getParent();
} while (!(parent…

scravy
- 11,904
- 14
- 72
- 127
23
votes
4 answers
Why to use SwingUtilities.invokeLater in main method?
After years of Java programming I always used to create my main() methods like this :
public static void main(String[] args)
{
runProgram();
}
But recently I studied some codes from the Web and saw this sometimes instead of the usual main()…

Rob
- 15,732
- 22
- 69
- 107
15
votes
3 answers
What is SwingUtilities.invokeLater
Possible Duplicate:
What does SwingUtilities.invokeLater do?
SwingUtilities.invokeLater
I have seen this little piece of code hundreds of times:
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
…

11684
- 7,356
- 12
- 48
- 71
10
votes
0 answers
Java 9 replacement for SwingUtilities3.setDelegateRepaintManager
While trying to port swing code to be compliant with the Java module system I got stuck trying to replace SwingUtilities3.setDelegateRepaintManager.
I have a component, which when any of its children requests a repaint then I need to transform the…

weisj
- 932
- 6
- 19
10
votes
2 answers
Java - Difference between SwingWorker and SwingUtilities.invokeLater()
SwingWorker is used for the following purposes:
For running long-running tasks in a different thread so as to prevent the GUI from being unresponsive
For updating GUI with the results produced by the long-running task at the end of the task through…

Amit
- 33,847
- 91
- 226
- 299
7
votes
1 answer
Best practice to start a swing application
What is the best practice way to start a java swing application? Maybe there is another way to do it.
I want to know if i have to use the SwingUtilities class to start the application (secound possibility) or not (first possibility).
public class…

Charmin
- 711
- 20
- 30
6
votes
1 answer
Change Font at runtime
Please is there another way how to change Font at runtime as using FontUIResource, for the whole AWT/Swing GUI, without any knowledge / interest about if there are local variables and type of JComponents
import java.awt.*;
import…

mKorbel
- 109,525
- 20
- 134
- 319
6
votes
7 answers
SwingUtilites: how to return values from another thread in Java?
I am trying to make an application in Java.
To make Swing work correctly, I did this:
public static void main(String[] array){
String outerInput;
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run() {
// I want…

Ashish Negi
- 5,193
- 8
- 51
- 95
6
votes
3 answers
EventQueue.invokeLater vrs SwingUtilities.invokeLater
Can someone highlight on the differences between these two and the instances both are required?!
I have an application which uses both intercheably, but want to know if one is better than the other. Obviously they both accept Runnable object, and so…

Bitmap
- 12,402
- 16
- 64
- 91
5
votes
2 answers
How to fix "(java:22494): Gdk-WARNING..."
I am writing a javafx program and I need the panel to update at a constant rate. Right now it is set to update every second. But I got this error, which is usually (but not always) followed by a glitch in the panel when the whole scene becomes…

JeremiahDuane
- 374
- 4
- 15
5
votes
2 answers
Access the JScrollpane in which the JTable is contained
I have a JTable inside a JScrollpane. I do not have access to the JScrollpane variable. But I have access to the JTable. Now how can I access the JScrollpane using the JTable.
For Example -> mytable.getAncestor(...) or something?

Deval Khandelwal
- 3,458
- 1
- 27
- 38
5
votes
6 answers
Why should I use a separate thread to show a GUI in JAVA
This simple issue confuses me. You can display a JAVA GUI application by setting the frames' setVisible property true. But in almost all the examples I found on internet they use a separate thread to do the same thing.
They do something like…

Anubis
- 6,995
- 14
- 56
- 87
4
votes
1 answer
Java Swing main JFrame: why does SwingUtilities.getAncestorOfClass return null?
I intend to implement a Swing application which keeps all its JComponents within the main application window JFrame. It seems like clunky procedural code to give all my JPanel constructors a parameter referring to the JFrame. So some research…

Arvanem
- 1,043
- 12
- 22
4
votes
2 answers
JTextArea in other JFrame display realtime console output
I have a "ConsoleFrame" which should display my console output in real-time to a JTextArea.
I redirected the output streams:
private void redirectSystemStreams() {
OutputStream out = new OutputStream() {
@Override
public void…

Christian 'fuzi' Orgler
- 1,682
- 8
- 27
- 51