Skip to main content

All Questions

Tagged with
-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 ...
NinaJava's user avatar
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, ...
wongl89's user avatar
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 ...
Mr. Mutant's user avatar
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 ...
UglyBob's user avatar
  • 267
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 ...
Yahia's user avatar
  • 95
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 ...
user avatar
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 ...
Max's user avatar
  • 1
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 ...
JJJokers223's user avatar
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 ...
JCGdev's user avatar
  • 39
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 ...
clivet268's user avatar
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 ...
user avatar
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 ...
BuffKitTon's user avatar
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 ...
Coderman69's user avatar
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 ...
IssiahB's user avatar
  • 52
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() { ...
LeeHyun's user avatar

15 30 50 per page
1
2 3 4 5
19