Questions tagged [swing]

Swing is a user-interface toolkit in Java and is shipped with the standard Java SDK. It is contained within the package javax.swing.

Swing is a GUI toolkit that is packaged with the standard Java SDK (since 1.2). Recently it is no longer being actively enhanced and has largely been superseded by JavaFX.

General information

Specialized articles

Essential topics in Swing programming

Layout managers: Layout managers are responsible for determining the size and position of components in a Container.

Swing threading rules: Swing is single threaded and any access to Swing components should happen on the Swing thread (the Event Dispatch Thread or EDT).

  • Start with the Concurrency in Swing tutorial
  • Detect EDT violations using one of the approaches cited here
  • Use SwingWorker to perform lengthy operations in the background and update the UI on the EDT
  • Use a Swing Timer for animation
81029 questions
10
votes
3 answers

Java: How to draw a border around an undecorated JFrame?

I currently have the DropShadowBorder class (which extends the javax.swing.border.Border class) from the SwingX library, so this is an instance of a regular Border. I would like to draw this border around my undecorated JFrame. I'm currently using…
Tim Visée
  • 2,988
  • 4
  • 45
  • 55
10
votes
3 answers

How do you make key binding for a JFrame no matter what JComponent is in focus?

How do we make key bindings for a JFrame regardless of what's in focus in the frame? I already looked at this question: How do you make key bindings for a java.awt.Frame? I tried setting the input map for the root pane of the JFrame, but it doesn't…
trusktr
  • 44,284
  • 53
  • 191
  • 263
10
votes
3 answers

Is there any way to right align the text in a JCombobox

I want to have a JComboBox with right align. how can I do that? someone before said "You can set a renderer to the JComboBox which can be a JLabel having JLabel#setHorizontalAlignment(JLabel.RIGHT)" but I don't know how can I do that?
Naeem Baghi
  • 811
  • 2
  • 14
  • 29
10
votes
7 answers

which library better for faster java application swt or swing?

which library better for faster java application swt or swing?
alsadk
  • 1,165
  • 3
  • 11
  • 20
10
votes
3 answers

Can multiple accelerators be defined for a JMenuItem?

I've a problem with setAccelerator(). Right now, I have the code that works for Ctrl+X for DELETE operation. I want to set the accelerator to Shift+Delete as well for same JMenuItem. My code as follows: JMenuItem item = new…
Santhi
  • 101
  • 1
  • 3
10
votes
3 answers

JLabel - get parent panel?

Is it possible to get the name of the panel that a JLabel is added to? I added some JLabels to different JPanels, and I want to call different mouse events according to which panel the jLabels are placed upon.
Kari
  • 101
  • 1
  • 2
  • 4
10
votes
2 answers

Java rounded corners on JFrame?

I have a login JFrame for my application and i would like to make the corners of the frame rounded by a few pixles. Id like to do this without using transparency on the JFrame and having to use a background image inside a JPanel - is this possible?
Alosyius
  • 8,771
  • 26
  • 76
  • 120
10
votes
3 answers

JDesktopPane preferred size set by content

I have been trying to tame JDesktopPane to work nicely with a resizable GUI & a scroll pane, but am having some troubles doing so. It seems that unless the drag mode is outline, the desktop pane will not resize as expected (when an internal frame…
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
10
votes
2 answers

JDesktopPane resize

We have a application with two JFrames with two JDesktopPanes. We need to move an internal frame from one frame to another. The problem we have is that after we move the internalframe from first window to the second window, when we resize the fist…
Nethru
  • 103
  • 7
10
votes
1 answer

Java Key Bindings Not Working

I am trying to make key bindings in Java on a JPanel. I want a certain action to execute when I press the 'w' button. I follow the Java tutorial on making bindings, but the actionPerformed method does not execute (i.e. no text prints out). The…
user2640461
  • 215
  • 2
  • 6
10
votes
5 answers

How to change java icon in a JFrame

Ok so I've been researching this one quiet a bit. I am fairly new to java but thought that this one would be easy. Ive tried just about every way that has been answered on this site and still no luck, and usually when I look here I am able to find a…
Garrett Shaw
  • 103
  • 1
  • 1
  • 6
10
votes
2 answers

How to align JLabel to the left of the JPanel?

I want to align my JLabel to the left. String lText = "mybook"; JLabel label = new JLabel(lText); label.setBorder(new EmptyBorder(25,0,25,500)); I tried to do…
Archit Verma
  • 1,911
  • 5
  • 28
  • 46
10
votes
1 answer

How To Add A MouseListener To A Frame

I want to add a mouselistener to mt JFrame frame but when i do frame.addMouseListener(this) i get an error that i cannot use this in a static method I am making an application that detects a click of the mouse then displays it in int…
ndfkj asdkfh
  • 316
  • 1
  • 5
  • 15
10
votes
1 answer

How to make JProgressBar match Windows LaF?

I've been working for a while with JProgressBar using WindowsLookAndFeel, but I found some major differences from the native progress bar: Here is the native bar, in its regular state: While this is Java's: A sharp eye might see Java's top white…
Mordechai
  • 15,437
  • 2
  • 41
  • 82
10
votes
7 answers

How to change non-editable/generated code in netbeans

I want to change the non-editable code in Netbeans , I want to replace the javax.swing.JTextFeild with ObservingTextField for which I have a class imported into my project in order to Implement a date picker But Netbeans Does not allow me to edit…
CleanX
  • 1,158
  • 3
  • 17
  • 25
1 2 3
99
100