81,359 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
2
answers
88
views
Confused about swing asynchronous update
Can I do something like this? Or will the asynchronous nature of swing updates make it possible for this to be a bug? In other words, can I rely on the selected index being updated before I read it, ...
0
votes
1
answer
78
views
Initializing non-showing JComponent lazily
Suppose you have a JTabbedPane. One of its tabs is populated expensively (e.g. with data loaded from a DB). The tab is not initially selected so its content is not showing immediately.
How do you ...
Best practices
0
votes
15
replies
87
views
Filling JTable with initialized columns
Suppose you have a JTable (which may or may not have any rows) with already added columns of a custom type.
JTable table = new JTable(); // actually, a custom JTable type, but it's not the ...
1
vote
1
answer
84
views
Making Custom Tab Look in Swing With JTabbedPane
I have tried making my own tab UI and I can never quite get it to work. This code below is the main class that makes the app and the tab panel. I am trying to make it so I can change what the selected ...
Best practices
0
votes
11
replies
50
views
Table layout adjusting insides of components
I want to display and configure multiple objects of the same class at the same time, while keeping up the good looks of a table. So: one line per entity, with multiple GUI elements per line for the ...
1
vote
3
answers
156
views
Elements appearing in the up position
I noticed this kinda of event some weeks ago, but I ignored, now it's making me curious. the last element that I add always end up in the up position of the screen, no matter how much I try to alter ...
0
votes
1
answer
127
views
JTextArea.setEditable(true) is not working
I have a JTextArea called premiseText. It is initialized with a default value and is setEditable(false). When I want User to change that value, I have a JButton called editPremise that, in that button'...
1
vote
1
answer
120
views
Scrolling to JTree node vertically only
Our JTree subtype automatically scrolls to its selected node. It's implemented essentially as follows:
@Override
public void setSelectionPath(TreePath path) {
...
0
votes
0
answers
112
views
Resize JFrame when moving to new screen
I have two monitors with different resolutions. I would like for a JFrame to dynamically resize when dragged to a different monitor.
When dragging to a new frame, the label will update, but the frame ...
Advice
3
votes
3
replies
77
views
Swing tutorial: InputVerifier setup
Below you find the example code for an InputVerifier from the swing tutorial, slightly modified to compile error-free under java 25.
The code creates an InputVerifer (class MyVerifier), which is set ...
0
votes
2
answers
160
views
Java Swing Invisible Image
Context:
I'm trying to make an app with java swing, however when trying to add a background to the Login Page, the image does not show up. It is there and moves other JComponents when adding a layout ...
0
votes
1
answer
106
views
Intercepting user toggle button clicks
Can you intercept JToggleButton clicks, making the selected property change conditional? If you add ItemListener or ActionListener, you can't veto the change, it's already happened. Switching the ...
0
votes
1
answer
61
views
Invisible caret shoves text to the left, obscuring text
I have a non-editable JFormattedTextField. It's enabled.
Once the user focuses the field (by clicking it or traversing focus with Tab), the caret is repositioned.
While the caret is invisible, it ...
16
votes
1
answer
349
views
How do I avoid left padding in menu items after upgrading from Java 21 to Java 25?
The problem started appearing after upgrading from Java 21 to 25.
With Java 21, my menus looked like this :
With Java 25, a gutter started appearing :
I've created minimal portable example to ...
0
votes
1
answer
101
views
Updating JFormattedTextField content on new value
JFormattedTextField, surprisingly, does not automatically update the field text content upon value commit — unless I refocus the component (focus something else and then click the field again). One ...