All Questions

456
votes
9answers
95378 views

The Use of Multiple JFrames: Good or Bad Practice?

I'm developing an application which displays images, and plays sounds from a database. I'm trying to decide whether or not to use a separate JFrame to add images to the database from the GUI. I'm ju...
56
votes
1answers
32080 views

Swing: Obtain Image of JFrame

How do I obtain a java.awt.Image of a JFrame? I want to obtain a screen shot of a JFrame (for later use within my application). This is presently accomplished using the robot to take a screen shot sp...
12
votes
4answers
5174 views

Something seems wrong with the layout, JButton showing unexpected behaviour at resize of the window

JRE Version 1.7 Update 3 EXPECTED BEHAVIOUR As I run the program, it works as expected, everything works smoothly. As when I click on STOP JButton the animation stops and the text on the same JButto...
3
votes
2answers
3575 views

JComponents not showing up with picture background?

My components are not showing up. How do I fix this? Code: import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.BufferedImage; import jav...
13
votes
4answers
27698 views

Java Bouncing Ball

I am trying to write a Java application which draws multiple balls on screen which bounce off of the edges of the frame. I can successfully draw one ball. However when I add the second ball it overwri...
5
votes
1answers
1742 views

Program not accessing method paintComponent() of extended JPanel class

This is the JFrame package client.connection; import java.awt.Dimension; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import javax.swing.JFrame; class DrawFrameRemoteContro...
209
votes
18answers
424597 views

How to programmatically close a JFrame

What's the correct way to get a JFrame to close, the same as if the user had hit the X close button, or pressed Alt+F4 (on Windows)? I have my default close operation set the way I want, via: setDef...
89
votes
4answers
87283 views

Java: Difference between the setPreferredSize() and setSize() methods in components

Ok, I read the Java Documentation and I just can't figure out what is the main difference between those two methods. Sometimes I used setSize(), sometimes setPreferredSize(), sometimes one does what I...
31
votes
4answers
169222 views

Setting background images in JFrame

Are any methods available to set an image as background in a JFrame?
75
votes
12answers
110313 views

Unresponsive KeyListener for JFrame

I'm trying to implement a KeyListener for my JFrame. On the constructor, I'm using this code: System.out.println("test"); addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { S...

Previous Next