9,977
questions
-1
votes
1
answer
23
views
why did my color of JPanel fill up all the window gui? I didn't know if there's something wrong in the code or the compiler?
the window appeared like this:
this is my code:
import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class gui2 {
public static ...
0
votes
0
answers
25
views
Weird whitish tint over video feed from the canvas frame
I have a jFrame, on that a jPanel, on that a jButton.
Of jButton, I have handled actionPerformed event of it.
But when I click on the jButton to open the canvasFrame where the image be shown, there is ...
1
vote
2
answers
60
views
What does "Canonical constructor cannot delegate to another constructor" mean?
Im new to programming and following this tutorial for a weather gui app in java. Below is the very small amount of code I'm working with so far. Where I am getting errors is at the "super(...
1
vote
0
answers
45
views
Adding ZOrder to JLabels causes them to Flicker in Jframe
I am trying to make a 2D game using Java Swing, but I am running into some trouble. I added ZOrder to my JLabels because I wanted them to appear in a certain order, but it caused them to start ...
0
votes
1
answer
45
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
50
views
Illegal Argument when trying to draw
I'm trying to draw a chess piece on the board I created but keep getting an error that seems my picture can't be found.
Exception in thread "main" java.lang.IllegalArgumentException: input ==...
2
votes
1
answer
57
views
How do I make this grid display in another jframe?
I have coded a MazeClass that paints a grid and has a method to change the color of a block on the grid. I would like to display this grid in a separate class on a jframe in the position I want to. ...
0
votes
1
answer
22
views
how do i make my g.drawline draw ontop of my JTextFields in a JFrame
i am attempting to make a soduku solving java program. i want it to be graphical and graphical isnt an area ive really explored before.first ive created a graphics method to draw all my needed lines. ...
0
votes
1
answer
36
views
My components in two different panels are too small and don't fit to the frames size, how can I fix this?
I made a JFrame (size: 500 , 600) that uses GridBagLayout to place two JPanels (one using GridLayout and the other using GridBagLayout) on top of each other; however, when I run my JFrame the ...
0
votes
2
answers
57
views
How do I Get JFrame to Display JPanel Text Content Even When Called by Action Event?
I have a simple JFrame dialog, that should display "Please Wait" message while the main program completes other activities (which may take anywhere from 30 seconds to more than 10 minutes):
...
0
votes
0
answers
22
views
Simple animation using a JLabel and ImageIcon throwing an exception
I'm making a simple static animation at the start of my program, and it uses a timer and ImageIcons to work. Here is the code:
int staticChecker = 0;
private void btnStartMouseClicked(java.awt....
0
votes
1
answer
60
views
Is it possible to connect two different JFrames to one single class?
I make two forms but I have this problem where my second form that will appear after we press a button on the first form could not get the data from the subclass. The plan was I want to only use one ...
0
votes
1
answer
59
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;
...
1
vote
0
answers
45
views
Starting X and sometimes Y coordinate of JFrame is displaced
Just recently started playing around more with Swing and right now I am trying to build an Algorythm Visualiser. The array being displayed is displaced. The starting X coordinate is shifted to the ...
0
votes
0
answers
33
views
my program still does not recognize txtFechaDev, even though I have the jcalendar 1.4 library
is my first time here, i have a problem in this program, I download the jcalendar 1.4 but the problem is in textFechaDev, it seems that the program txtFechaDev is not declared or there is an error in ...
1
vote
1
answer
72
views
Graphics2d on JPanel
I want to make a program in Java that drops a square at the position of your mouse. For that I wanted to draw a grid as background and then add the squares but as soon as I add a new component to the ...
0
votes
0
answers
52
views
Issue with object arrays and their usage among frames
I need to find a way to handle the object array to send it to the other frame "Start" I've tried various ways but I can't, I'm just a beginner in the field of OOP, I've tried creating ...
1
vote
1
answer
55
views
Image URL syntax
I am trying to make a background image in a java jframe window, but when I try to initialize it, I get a null pointer exception saying the location url I put in is null.
I've tried the following:
...
0
votes
0
answers
36
views
Add image as icon for window
this is the code
import javax.swing.*;
public class test {
public static void main(String[] args) {
System.out.print("Starting up...");
createWindow();
}
private ...
-1
votes
1
answer
28
views
Java KeyPress is getting the value before the key press, not the value during the key press
I'm writing a Java program that generates 5 random letters when user press G. After pressing G, if user press S, the next pressed key would be compared to the random generated letters to check if it ...
0
votes
2
answers
49
views
getResource not retrieving images in Source Package
I am trying out a java with Ant slideshow in a video I found. I have made the output, and the window is appearing, but none of the images are being shown.
I suspect I have done something wrong ...
0
votes
0
answers
8
views
Having an Issue with my JComboBox filling the entire JFrame/ Not displaying options
I am working on my final project for class and need some input on why my JComboBox isn't working properly. When I had it in the main program "GUI" I was able to display it properly but I ...
0
votes
1
answer
38
views
Continue Detecting Input with KeyListener While Typing In a JTextField
I'm currently working on a small utility window for another application and I'm running into the issue that KeyListener input stops detecting input while a user is focused on a JTextField.
I've made a ...
0
votes
1
answer
34
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 ...
0
votes
1
answer
44
views
JDialogue's components won't show up before while loop ends
I am currently building a RPG game using built-in GUI and is trying to display a simple fight scene on a JDialogue. My partial code are as follows:
public void setupFight(Character c) {
...
0
votes
0
answers
49
views
Can I delete a certain character from a JList?
First of all, English isn't my native tongue. So sorry in adavance for any mistakes!
For a project of mine I want to have a list with numbers the user decides to put in, and all of these numbers get a ...
-1
votes
1
answer
39
views
Why does my update function complete without updating the db and it gives no error?
private void Approve_btnActionPerformed(java.awt.event.ActionEvent evt) {
int bonus = Integer.parseInt(bonus_txt.getText());
int sal = ...
0
votes
1
answer
98
views
How do I run my java code on my JFrame in eclipse?
I'm currently trying to create what I thought was going to be an easy Java program. I want to create a GUI that prompts the user to enter the day of the week and will spit out the chores they have to ...
0
votes
1
answer
41
views
Frame showing up super small Java Swing
could someone tell me why my frame is showing up super small/minimized? I thought I just had to pack my frame to resolve the issue but packing my frame does not seem to have any effect on the outcome.
...
0
votes
0
answers
22
views
JComponent added to JPanel doesn't appear?
I have searched a lot for this problem and did find similar problems but not exactly this so nothing has worked yet.
I am making a game like Vampire Survivors and right now I am trying to get the ...
0
votes
0
answers
32
views
Java paintComponent not display background image on JFrame
I am trying to display an image that have in a subdirectory of my project src, and from the testing that I have done, the path reference to utilize the image is correct, however, when I run the ...
0
votes
0
answers
46
views
How to add good quality image to JFrame?
After inserting a good quality image into the JLabel, the final image quality is less detailed (as if it had a lower resolution).original image JFrame screen after inserting. The difference may not be ...
0
votes
0
answers
39
views
repaint() leaves trace of object initial position
I'm implementing a JFrame program that is supposed to mimic balls bouncing with wall & between other balls in a concurrent setting. While the balls are correctly displayed and updated, it leaves ...
0
votes
0
answers
25
views
How to Implement SRCAND with Java?
If I want to use Java to implement the SRCAND effect of BitBlt() in VC++, that is, perform AND operation on the image and background. For the following example, how can I mix the red string AAAAAAAA ...
0
votes
0
answers
52
views
Coding battleship in java using Jbuttons in a Jframe
I'm trying to code battleship in a JFrame with 2 matrices of 2d arrays with JButtons. I have most of the code ready to go, but I'm running into a problem with placing the ships. The problem is that ...
0
votes
1
answer
68
views
How do I colorize the text in a JFrame Title bar
I have an application controlling hardware that has a JDialog displayed when the user wants 'backdoor' access to the hardware. That JDialog is filled with buttons and features and I don't want to ...
-1
votes
2
answers
45
views
Java : How to display a label inside a Jframe component
I try do display a text at the bottom of the container (JFrame) but it doesn't appear ....
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import ...
0
votes
1
answer
48
views
Problems with moving an object in Java Swing
I'm having trouble displaying the movement of a custom Jbutton object in Jpanel that has been added to the Jframe.
The chart is displayed but when the startMovement method is called the chart ...
0
votes
1
answer
55
views
Get accurate coordinates within JPanel in a JFrame
How does one get accurate xy coordinates from a JPanel placed within a JFrame.
I tried figuring this out on my own but the coordinates are slightly off and I dont know why.
I know this probably isn't ...
0
votes
0
answers
35
views
table is not visible in the window. How to fix it?
String[] columnNames = {"Customer ID", "Name", "Address", "Salary"};
dtm = new DefaultTableModel(columnNames, 0); // 0 is row count
customerDetailsTbl = new ...
1
vote
1
answer
98
views
Why does my ImageIcon disappear after using setLocation() on JFrame?
I want to move a JFrame window containing a GIF across my screen, but when I try the following:
icon = new ImageIcon(spritePath);
frame.add(new JLabel(icon));
frame.setSize(icon.getIconWidth(), icon....
1
vote
1
answer
49
views
Why is only one component appearing
I have a JFrame and for some reason only one component is appearing
public JFrame mainMenuFrame = new JFrame();
public JLabel welcomeText1 = new JLabel();
public JLabel welcomeText2 = new ...
-2
votes
1
answer
45
views
why isn't the square drawing when i type 1 or 2?
here's the code but I don't know why it doesn't work I've tried adding a revalidate and a repaint but the square won't draw, I'm trying to make the square move over a bit when 2 is entered and the 1 ...
-1
votes
1
answer
25
views
The setSize() Method in my JFrame class is not working due to an API error
i was working with the JFrame class and i was trying to create an empty frame,but when i try to use the setSize() method,it shows some API error,something like Usage of API documented as @since 1.6+9
...
0
votes
0
answers
49
views
Action Listener (JFrame) will not change the instance variable
public class YourAge extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTextField fNameTextField;
private JTextField ...
-1
votes
1
answer
50
views
How can i change the size of the icon connected to the JButton
When you connect icon to JButton
( button.setIcon(icon); )
you get very small icon, How can I change the size of this icon?
My code:
(In this code you need to drag 1 file to the frame and look how ...
0
votes
0
answers
47
views
Can anyone help me with my JAVA Swing code?
It's been 3 days since I encounter this problem and still can't find a better solution:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
...
0
votes
1
answer
35
views
Resizing or removing Java JFrame headers
I am creating a java application with a set size (it is a project creation screen for now, and I don't want this screen to be large). I'm trying to set the JFrame I use to display in such a way that I ...
0
votes
0
answers
45
views
How to add custom cursor
Im trying to add a custom cursor to this game I'm trying to make
here is the code
JFrame window = new JFrame("First Java Window");
window.setDefaultCloseOperation(JFrame....
1
vote
1
answer
75
views
Sound playing even after closing the application in Java
So, I am making a game using Java and I wanna add background music to my application. So, I created a class SoundManager and wrote this code in there:
package Managers;
import java.io.File;
import ...