All Questions
369
questions
1
vote
1
answer
608
views
How to use Flow Layout inside a Panel in Java?
Here is the code with problem:
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
public ...
-1
votes
2
answers
56
views
Space Invaders generate initial Asteroids Java Failure
I have written a Space Invaders-like game, which has a rocketShip and some Asteroid objects falling, and the objective of the game is to survive and shoot as many Asteroids as possible.
I am having ...
0
votes
1
answer
49
views
Why does this program only display the last graphic?
Im using JPanel and JFrame to create a program that can draw lines and circles. The problem is that my program only redraws the last object added.
I have tried moving around the repaint. For some ...
0
votes
1
answer
672
views
Array in java, how to calculate hamming distance between String and int?
I have to write a programm.I am learning 2 month java and i am stuck.An advice how to forwoard on this is very helful for me.
The class will contain two methods, public static void main and public ...
-1
votes
1
answer
63
views
Java swing scrollpane doesn't show the scroll bar
I was working on a java swing gui project for my course. When I was doing that, I found that I had too much information in a panel and it was not able to show everything. As a result, I wanted to add ...
0
votes
0
answers
91
views
Why does my panel move when i resize the window?
In this code I have created a Frame with a Panel. When the user clicks in the panel the x and y point of the location that was clicked will be displayed.
The goal is to add the panel in order to ...
0
votes
1
answer
47
views
Java Swing: Why are my panels layered? I can't see my first panel
I'm trying to have one panel appear under the other (textPanel to appear under mainPanel).
But instead, textPanel is appearing overtop of mainPanel:
FlatLightLaf.setup();
FlatLightLaf....
1
vote
1
answer
265
views
How top-align side-by-side panels, Java swing
I want my dissimilar-height panels to be top-aligned within their containing panel.
I've tried BorderLayout with NORTH, I've tried panel.setAlignmentY(TOP_ALIGNMENT). No luck with any approach so far.
...
0
votes
0
answers
84
views
Loading images via JFileChooser
3 Classes - GUI, ImageLoader and Wizard
GUI is the main frame whereas Wizard is just a popup that changes settings and imageloader is image handler
What I want is to load image from wizard to Jlabel ...
0
votes
1
answer
118
views
add panel to frame in inner listener class?
class MemberBook extends Frame {
MenuBar mb;
Menu menu;
MenuItem miReg, miList, miExit;
MemberBook() {
super();
mb =...
0
votes
2
answers
197
views
Java GUI paint picture on labels
I want to add a picture that will be in the panel and also on labels but I don't know how to do that.
my code:
JFrame frame = new JFrame();
JPanel panel = new JPanel();
JPanel mainPanel = new JPanel(...
0
votes
2
answers
841
views
Got on <<error javax.imageio.IIOException: Can't read input file!>> when I tried to add an image on the background of my JPanel
I am currently learning java and I have problem and can't find anything about it. I got an "javax.imageio.IIOException: Can't read input file!"
I don't understand what I did wrong :
this is ...
0
votes
1
answer
33
views
How to use action listeners to run designated methods on seperate input
I am nearly done with the backend work for a small app I am making to help me give out construction estimates.
There are four input fields (2 drop-down, 2 text input) and a button at the bottom which ...
1
vote
1
answer
77
views
How to make different animations for keyboard input
I'm making a top-down shooter game in java where I have a stationary player who can turn side to side and can shoot a gun at enemies that move to the center(where the player is). I have made different ...
2
votes
1
answer
29
views
JPanel drawing is slowed down after several instances are painted
I'm building a game and I'm painting the road sprites with the JPanel's draw function. The roads (Building class) can be built by dragging the mouse and on each field a new road sprite appeares. But ...