All Questions
Tagged with components swing
284 questions
-1
votes
1
answer
49
views
paintComponent invoked many times
I'm creating a shooting game. When the bullet (which is a JLabel) passes through the enemy (which is a JPanel) then the paintComponent() method gets invoked until the bullet has passed through the ...
0
votes
1
answer
119
views
How to get Java Swing Components to display on a JPanel within a JFrame, so you can add and remove them afterwards?
I have this custom component:
import java.awt.*;
import javax.swing.*;
public class Comp extends JComponent{
int x;
int y;
String name;
public Comp(int px, ...
0
votes
1
answer
25
views
Get the variable associated with a JPanel component from a component array
Say I have a JPanel with buttons (and other things) as components and I make an array of those components as such:
JPanel panel = new JPanel();
JButton btn1 = new JButton();
JButton btn2 = new ...
0
votes
0
answers
34
views
Custom popup don't always get focus
I try to basically implement my own combobox for Swing, because JComboBox has some behavior that doesn't suit my requirements and what I need to override is private, so...
Anyway, I tried making a ...
0
votes
1
answer
49
views
Dynamically adding components to JFrame
I'm looking for a way to dynamically add a Component inside a JFrame after it has been set visible.
Specifically, I'm making a request to a database and based on the length of the result, I want to ...
0
votes
0
answers
34
views
Java how to have 2 components without layout?
I have my Java project (link down there) and i want to add two custom components. I have tried adding them to panels, adding them to panels with layout, but nothing worked. I don't want layouts, since ...
0
votes
1
answer
69
views
Weird issue updating a JLabel on JSlider change
Huy guys, I have a weird problem.
I'm kinda new to swing and java applications.
I'm trying to make a custom UI jslider that changes a jlabel text when you move the thumb.
My problem is: when I use the ...
0
votes
1
answer
481
views
How to add auto-resize components?
I'm wondering how I can add (what LayoutManager should I use) to make the app automatically adjust the components to the current size when full screen mode is enabled or even when the frame is ...
0
votes
2
answers
862
views
How to stop components adapting to the size of a JPanel that is inside a JScrollPane
The components inside a JPanel (which has a BoxLayout) are getting resized when there's lack of space.
The JPanel is inside a JScrollPane, but because of the fact that the components get resized, the ...
2
votes
1
answer
50
views
How to keep the other components in front when redrawing a JPanel used as a background?
I've looked all over and I can only find cases of people using their custom JPannel to draw an image over another image but what I'm trying to do is draw a component over the JPannel and no matter ...
1
vote
1
answer
692
views
How to enable a JButton on a condition?
I'm trying to create a JButton that enables when certain conditions are met. The program sets setEnabled(false) as initial value, but after an update, it should be setEnabled(true).
I tried several ...
0
votes
1
answer
263
views
The method add(Component) in the type Container is not applicable for the arguments (CheckboxesGUI)
I am in a programming class for java, I follow along with my proffessor's video of him writing a program in eclipse. I have this error, but he doesn't have it in his video, in the vid his code ...
2
votes
3
answers
812
views
How to send an KeyEvent to JFrame Component?
So im trying to send an KeyEvent to the JFrame component. Like when u press a key while the window is focused normally it sends an KeyEvent to the JFrame and triggers something. But how can i simulate ...
2
votes
1
answer
1k
views
Java - How to center components horizontally, and stack them vertically?
I am writing a application that will take user information such as the name, email, password. To get the user information I am using JTextFields. I would like to have all the components in the center ...
0
votes
1
answer
415
views
How to fix size error of Java Swing JFrame
I'm practicing about Swing Layout.
I seek JFrame's actual size is not match to size Dimension
import java.awt.*;
import javax.swing.*;
public class GridRanFruit {
public GridRanFruit() {
...