4,909 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
3
answers
154
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 ...
4
votes
0
answers
187
views
How do I get rid of these artifacts on my JButton? And/or, what am I doing wrong here?
Here is a minimal, reproducible example. I am using Java 24 with the --enable-preview flag activated. I am on Windows 11.
import module java.desktop;
void main() {
SwingUtilities.invokeLater( () -&...
-1
votes
3
answers
112
views
Swing: How to center a button near the bottom of a JFrame without using setBounds()?
I’m working on a Java Swing application and would like to place a button so that it is horizontally centered and vertically positioned near the bottom of the window — similar to how a typical "Submit" ...
-1
votes
1
answer
81
views
I'm making a Guess a Number Game in Java Swing and I'm having problems the JButton [duplicate]
The program technically works, but I keep getting the error:
"Cannot invoke "javax.swing.JButton.addActionListener(java.awt.event.ActionListener)" because "this.check" is null&...
1
vote
1
answer
70
views
JComponent Child doesn't draw after overriding Parent paintComponent function
I have a JButton in which I overrided the paintComponent(Graphics) function
with a child JLabel (I realize this sounds stupid, I promise it's not)
I have mouseEntered(MouseEvent) & mouseExited(...
1
vote
0
answers
21
views
How to get a JButton to work properly in a static method
I am creating a GUI that asks the user to enter an account balance then click a confirm button. After the button is clicked, it is supposed to display the confirmed balance in the confirmed balance ...
0
votes
1
answer
62
views
Unable to deselect a JButton once it has been clicked
So I am writing a program which has several layers of menus using a JFrame with JButtons but once the user clicks a button that button ends up stuck as selected and I cannot update it. Any help please?...
0
votes
1
answer
87
views
How does JButton call the actionPerformed method?
I was trying to understand exactly how a JButton object works.
I created the below SampleFrame object that extends JFrame.
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
...
0
votes
0
answers
97
views
How to acquire JButton's enabled state at runtime from another class
I have multiple forms containing multiple textFields and a save JButton each. When I create each of these fields, i pass the form's save button to the associated InputVerifiers which are supposed to
...
0
votes
0
answers
41
views
JPanel and Grid Layout modification
I have been trying to modify the contents of a gridlayouts in a panel i created(Java by the way Ecliplse), but no method ive tried is working this is the code:
// Planning to add about 6 more buttons ...
0
votes
2
answers
81
views
Java GridBagLayout does not fully display the JButtons
I have a JPanel with one JLabel, two JButtons and a GridBagLayout as the layout manager. The problem that I now have is that when I add all the components to the panel (using the GridBagConstraints of ...
0
votes
2
answers
95
views
Can I use BoxLayout on a JLayeredPane to space items on each layer individually?
I am creating Uno as my final project in my CompSci class.
The cards in playerHandPanel are made of JButtons. The buttons should be displayed sequentially in the order they were dealt, but also ...
0
votes
1
answer
70
views
If Statements not changing with different outputs in a Java Text Field
So I'm pretty new to the whole Java UI thing and I just came across a problem where the output of one of my if statements ( the ones with that suggest adding numbers, special chars etc., the password ...
0
votes
1
answer
66
views
Making my JLayeredPane background transparent in Java
I would like to stack 3 different 15 ×ばつ 15 grids filled with JButtons on top of each other where one of them should be visible and the others transparent, but the JButtons should still function and ...
-1
votes
1
answer
74
views
Jbutton should open a JList and then append JtextArea but nothing happens when I press it?
public static JButton scene() {
JButton scene = new JButton("Scene");
ImageIcon sceneIcon = new ImageIcon("src/Images/scene.png");
scene.setIcon(sceneIcon);
...