Questions tagged [jframe]
A JFrame is a component and top-level container of the JFC/Swing framework.
9,820
questions
0
votes
0
answers
37
views
There is always a delay or bug when running JPanel & JFrame instances (Mac M1 Pro)
I'm a beginner to coding. I'm using IntelliJ on a MacBook M1 Pro. So far most things went great and the compiling time is fast. Apps where everything runs in the Terminal work perfectly.
Unfortunately,...
0
votes
1
answer
48
views
How to move an image on a Graphics2D after a user clicks it
I implemented MouseListener and on mousePressed, I get the x-axis and y-axis the piece is positioned on when the mouse is pressed, and on mouseReleased, I get the x-axis and y-axis the piece is ...
-1
votes
3
answers
76
views
Can't get absolute JLabel location
My JFrame uses a BorderLayout and it has a JLabel nested in several panels with different layout managers. I've tried several methods, however, cannot get the true position of where it sits in the ...
-1
votes
0
answers
35
views
How do I know the bounds of my window in Java
I have a JFrame:
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 836, 491);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(...
-3
votes
1
answer
58
views
How to Add a Junit Test Case? [closed]
How Can I Write a Junit Test Case for this Piece of Code? It's a GUI-Based WordCount Project
This is my finals project and I need to apply some functions in this application:
Thread Synchronization
...
0
votes
1
answer
39
views
Java Game in Fullscreen has way less fps than in window mode
The game runs at about 2000 to 3100 fps in normal window mode. If i set the JFrame component to fullscreen and scale up my JPanel to also the same resolution, the fps drops to 20-70.
(This is a ...
-2
votes
0
answers
23
views
Why does java not show my image even though I am using the right graphics [duplicate]
I've tried a ton of things to get my image to show. I know that there is a easier way to do this but I want to have a method that puts an image on a JFrame. Here is the main.
import java.awt.event.*;
...
-2
votes
1
answer
30
views
Add a jpanel from another class [duplicate]
I am a newbie in java. I want to add a jpanel placed in another class but don't know how to do it. Thank you so much!
GUIFile.java
import java.awt.*;
import javax.swing.*;
public ...
0
votes
1
answer
47
views
Is there a way to automatically edit button's properties in Java JFrame? [closed]
I've set following properties for one of my buttons.
try {
name.setIcon(new javax.swing.ImageIcon(ImageIO.read(newFile("./src/main/java/resorces/Default.png"))));
} catch (IOException ex)...
0
votes
0
answers
12
views
Jscrollpane scroll only appears at bottom
im have this jframe that has a jscrollpane and a jtextarea inside it, it works okay but the scroll button only appears at the bottom, I want it to show at the top as default. How can I change this?
...
0
votes
0
answers
14
views
Long text scroll in jframe
I am building this program and I would like to have a square area that is scrollable since the text is long. I've tried some methods but it seems to cut out the text out of the length. Could anyone ...
0
votes
0
answers
20
views
How can I activate a button without it being pressed? [duplicate]
So I am trying to make a JButton get activated without it being actually pressed. However, I want this action to be performed only if a rectangle-jcomponent is touched by my player. How can I achieve ...
0
votes
0
answers
23
views
Why I can't get medium level for math questions to appear?
import javax.swing.*;
import java.awt.*;
import java.awt.Color;
import javax.swing.border.*;
import java.awt.event.*;
public class MATHfighter extends JFrame implements ActionListener
{
Border ...
0
votes
2
answers
36
views
JLabel does not appear in JFrame when implemented in separate classes
I am trying to add a JLabel to my JFrame. I have implemented them in separate classes but when I run the code, I cannot see my label.
It worked well when I implemented both frame and label in the App ...
0
votes
0
answers
22
views
How to stop extreme lag when fullscreening a JFrame?
I am making a game with 60fps refresh speed that works fine when being ran outside of fullscreen, but whenever i put it in fullscreen, the framerate tanks heavily. Any ideas?
public class Game {
...
0
votes
0
answers
16
views
Java JFrame ; Clicking anywhere in the window disable all the listeners
So I started this little Kotlin project and I encountered a weird problem : When I click, anywhere on the window, listeners disappear and I can't input anything.
EDIT : Found the solution, add an ...
0
votes
0
answers
24
views
How can I change the final appearance of my project in Apache NetBeans
I'm using JFrame and when I click on the "Preview Design" button the preview looks very well, like this:
Preview Design
But when I run the project and see the window, look like this:
Final ...
0
votes
0
answers
11
views
How to display an HTML String in a eclipse (on user interface NOT in Browser)
//Thats the way I tried. It did not work as I can see ".src/fil..." in the user interface. I want to display the text from the html file
public class NewWindow {
private static String file = ...
0
votes
0
answers
32
views
Drawing a map on a jframe
I currently have a player rectangle that moves if an arrowkey gets pressed by the user. My next goal is to paint a map: 1 = walls(black rectangle), 0 = nothing(white rectangle). How do i implement ...
0
votes
2
answers
30
views
JFrame moving rectangle-Why isnt my rectangle moving and clearing his path
I am quite new to the work with JFrames and Graphics in java. My longterm goal is to create a RayCast Game-World. The following code is my first approach of a rectangle moving in a jframe at its ...
0
votes
1
answer
19
views
What is a good way to make a application selector layout? JAVA JFRAME
i am trying to make a application launcher in java, that launches different applications for example, one for snake game, and one for puzzle game, etc. Here is a example of what i want:
enter image ...
-1
votes
0
answers
23
views
The process keeps waiting
It gets stuck on the wait.
The button stays pressed (launch is a button) and the window doesn't close.
launch.addActionListener(new ActionListener() {
@Override
public void ...
0
votes
0
answers
8
views
How can I redraw a grid on a JPanel if the frame gets bigger?
So basically I am trying to code a grid, that adjusts it's size everytime I make the JFrame bigger/smaller.
Now I don't want the grid to take the whole JFrame up, it also is supposed to only grow to a ...
0
votes
1
answer
20
views
Set the view to a specific cell
Do you know how to set the view to a specific cell in Jtable?
Because I'm working on searching for specific content in cells (Such Ctrl + F)
I have a specific cell such as row 39 and column 5, but I ...
0
votes
1
answer
20
views
Drawing with functions on JFrame or JPanel java
I wanted to know if it is possible to use/make a function in another Class to draw an image/oval and then call it in the paint public void in our main Class.
If I have
public class Trydraw{
...
0
votes
0
answers
6
views
Mouse press not registering
When I click the JFrame it should register the click and output system.out.println but it isn't i'm fairly sure the mouselistener isn't on the jframe but I don't know how to add it. I've tried messing ...
3
votes
2
answers
70
views
JPanel and JLabels stretching to fit size of parent, regardless of maximum size - java wordle clone
In the class that extends JFrame, I have the following code:
public Frame() {
setTitle("WORDLE");
// creates all containers
Container mainContainer = getContentPane()...
0
votes
0
answers
32
views
Java Swing pack method not working as expected
I am trying to create a GUI using Java Swing, and am having a problem using the pack() method. As you can see, I create and add all of the elements to the frame in the createTitleText() method and ...
0
votes
1
answer
12
views
Getting jframe panel dimensions java
Pretty simple, I'm trying to figure out the jframe panel dimensions but whenever I get the dimensions it provides me with my screen dimensions, not the window dimensions. I have tried a multitude of ...
0
votes
0
answers
24
views
Eclipse bug doesn't respect the bounds set by GUI
So I've been having this little issue with this app that I'm developing for a school project and I believe my eclipse has bugged out, what happens is, whenever I set the bounds to something on the GUI ...
0
votes
0
answers
23
views
How to repaint a JLabel from it's child-class using repaint() in java?
I am a Java-Beginner and I am trying to create a Gui Version of Conway's Game of Life in Java.
My Problem is, that I am not able to paint the game progress, because I do not know how to deal with the ...
0
votes
0
answers
14
views
How would I display only part of an image in a JFrame in java - using the Graphics2D method
So, I am trying to make a program in Java that opens a JFrame window and displays images. these images are part of a Tile map/Sprite sheet.
g2.drawImage(image, screenX, screenY, gp.tileSize, gp....
0
votes
2
answers
24
views
Java JPanel not appearing
I have a two JPanels, one that is displayed as a home/welcome page, the other displayed when a user clicks a button. The first panel does not disappear when the button is clicked, the second panel ...
0
votes
1
answer
29
views
JFrame componentResized method works different between MacOS & Windows
We are currently doing a game project using Eclipse. We started the project on my friend's Mac and the code worked how it should. If we start the program on any other windows device it doesn't work ...
0
votes
0
answers
24
views
Java JFrame Border Layout - Is it possible to interchange the 'CENTER' with a different panel?
So firstly im new to Java and am learning as I go at this point.
I briefly made a Calculator/Scientific Calculator following guides a while ago which I enjoyed.
The way it was done had me wondering if ...
-3
votes
2
answers
31
views
I have a Exception (StackOverflowError) [duplicate]
I have this kind of error:
Exception in thread "main" Exception in thread "main" Exception in thread "main" java.lang.StackOverflowError
My Code (actually by BroCode):
...
0
votes
1
answer
31
views
JFrame and JPanel sizing
I have a JFrame and a few JPanels that are displayed depending on where the user goes (to login, homepage etc), is there a way to set all JPanels to the same size without having to manually specify?
...
0
votes
0
answers
19
views
JFrame startup Location
I made the size of the frame x:300, y:300 with the setSize method.
setSize(300, 300);
I drew a square with the Graphics variable g. The starting position of the square is x:320, y:20. The width of the ...
1
vote
1
answer
21
views
How do I make it so that the table is displayed inside the JFrame in Main?
I am currently making a program for my school project, it is a fast food order calculator, my problem is that I have to be able to display the table inside the JFrame in Main, if I add "frame.add(...
0
votes
1
answer
28
views
How can i draw a rectangle using Java and the JFrame class?
Im about to learn Java (after C++) now,and I am trying myself in Gui Programming.
My goal in this code was to draw something simple into a window created with the JFrame library.
This is my code:
...
0
votes
0
answers
10
views
Why does the save button not work out in GUI?
import java.io.FileWriter;
import javax.swing.JOptionPane;
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/...
0
votes
1
answer
21
views
flickering my jframe even i used doubleBuffer
when I call a repaint method its flickering, I was searching on the internet about doubleBuffered but its stil flickering all of objects on the same time,
import javax.swing.*;
import java.awt.*;
...
0
votes
0
answers
31
views
How to make a JLayeredPane transparent with visible figures?
**My JLayeredPane's overlap the way I want them to, but I can't seem to create a transparent background for the top layer.
I'm trying to create a game, called Kamisado, where the board 8x8 has ...
1
vote
1
answer
45
views
How do I make a top down view with the ability to rotate with built in java graphics?
I'm trying to make a racing game with the top down view on a static player in the middle of the screen, so instead of moving the player through the map, the map would move around the player. Since it'...
0
votes
1
answer
42
views
Problem with buttons exceeding the Panel (JAVA)
I'm having a problem with a layout I'm trying to do in java. I have 2 panels in a 800x600 frame. The first panel "gamePanel" is (600x600) and the second "menuPanel" is (200x600).
...
0
votes
1
answer
26
views
JFrame ending in some time
Whenever I run my code it ends in a few seconds. Why?
This is the Main file:
public class Main {
public static void main(String[] args) {
System.out.println("This is running");
...
0
votes
0
answers
30
views
JFrame/JDialog shows no content [duplicate]
I am currently writing an app where the user sometimes needs to wait for longer periods of times. Therefore, i have created a progressbar that shows how far along it is. This seemed to work great at ...
0
votes
0
answers
30
views
How to delete table records on cascade without the program freezing?
this is my delete button method, it takes the college name as a primary key and deletes it so the whole record gets deleted. However, it can't be deleted because this table COLLEGE is the parent table ...
0
votes
2
answers
31
views
How can I create a frame with a BorderLayout and assign each space a component?
When I type .setLayout(new BorderLayout());
It appears me this: The method setLayout(LayoutManager) in the type JFrame is not applicable for the arguments (BorderLayout)
I´m a beginner and I was ...
0
votes
0
answers
41
views
How do I use the same variable between buttons?
I've created a rock paper scissors game in java, but I don't know how I could use the same variable to work between 3 different buttons (rock, paper scissors). I use if loops for win loss and tie in ...