Questions tagged [swing]

Swing is a user-interface toolkit in Java and is shipped with the standard Java SDK. It is contained within the package javax.swing.

Filter by
Sorted by
Tagged with
0 votes
0 answers
3 views

How i can puild project using Springboot with swing?

I devellope before an application with angular and springboot and also anther using springboot and reactjs so i am wanderings if i can build a project using swing for ui and hibrnate for database with ...
Deidine's user avatar
-2 votes
0 answers
15 views

Java/Swing: enable save menu item only if changes are presents in one or more forms

I have to develop a small Java Desktop application with Swing in which the user can modify several tables loaded from a database. To save changes, there is currently a "Save" button per form....
Christophe's user avatar
0 votes
0 answers
15 views

graalvm 21 new Robot().createScreenCapture(size) returns magnified

For the java project below that screencaptures to a jpg file, why jar version creates proper jpg file, graalvm exe version creates magnified jpg file even though they both detects screen size ...
Tugalsan Karabacak's user avatar
1 vote
0 answers
22 views

How to load watermark over the jxbrowser [closed]

I have one parent browser and the content on the parent browser . On which one more child browser is opened with some content but on the child browser which is created using jx browser , there over ...
Ajay Kumar's user avatar
0 votes
1 answer
21 views

How do I make it so that my Jbuttons / Jpanels resizes with the JFrame?

I made this calculator program on Java and I wanted to add one more touch to it. What I want the program to do is to rezise the JButtons / JPanels with the JFrame. Meaning when a user stretches out ...
Sajal 's user avatar
-4 votes
0 answers
40 views

how reload jframe in swing [closed]

I have a problem with a Swing application. I have tried closing the GUI and running it again in the terminal, but this isn't working. My question is how to refresh the UI in a Swing application. ...
Deidine's user avatar
0 votes
1 answer
34 views

Table is not fetched from mysql database to JTable in Java Swing

I created a DataConnector Class which connect my program to database. Then I created default constructor DataConnector(), which would be a common part for other parametrized constructor. So I used ...
Przemysław Poskrobko's user avatar
1 vote
1 answer
30 views

Why when I run my code the panel opens but it never reaches the actionPerformed function

panel view of my 2048 gameI am trying to make the 2048 game. I made the terminal version to check my game logic and everything seems to be working. Now I added a GameFrame and GamePanel class. My aim ...
Maria's user avatar
  • 11
0 votes
1 answer
28 views

Backspace stopped working in any JTextField in Java Swing after adding the custom class for IP text field with KeyListener added to it and only to it

After adding the below code, Backspace key stops working at any JTextFields, when I press Backspace, nothing happens. import javax.swing.*; import javax.swing.text.DefaultEditorKit; import java.awt.*; ...
Eljah's user avatar
  • 4,232
-3 votes
0 answers
28 views

Why is there a visual error after my code finishes running? [closed]

So I am making an editor for this simple adventure game where a single square one a 10 x 10 grid runs around a maze like structure (still early development), I wanted to make an editor for the game as ...
NChallenger's user avatar
0 votes
1 answer
40 views

Is there a way to make terrain generation with JPanels and Java Swing?

I have been wanting to make an array of JPanels(a 3 by 3 array) with a randomly generated JPanel that is either a forest or plains, with the center one always being one called house. There will always ...
LeninYT's user avatar
0 votes
0 answers
23 views

Why isn't the keylistener working after adding a component to the main JPanel [duplicate]

Please forgive my impatience and stress as this is my 7th day trying to figure this out. I have tried requestfocus everywhere to no avail. I've tried System.out.print'ing the keyPressed at the ...
ABC DEF's user avatar
  • 91
0 votes
2 answers
60 views

Can Java cause Windows split screen?

Context In Microsoft Windows, I am able make an application's window occupy half the of display by using the shortcuts: ⊞ Win + ← ⊞ Win + → These shortcuts cause a "split screen," as seen ...
Cardinal System's user avatar
0 votes
0 answers
18 views

InvalidPathException when browsing to "Desktop" in JFileChooser with custom FileFilter on Windows

JDK 17.0.3 - Azul Zulu I have a custom FileFilter class which extends the java classes of javax.swing.filechooser.FileFilter and java.io.FileFilter. (All code is in Kotlin) The accept() method is ...
Josh's user avatar
  • 136
1 vote
1 answer
22 views

Having problem when using GridBagLayout on JPanel and putting JButton inside

Here's what I've got. I have two JPanels, each with GridBagLayout. They have weightx = 0.5 and fill both directions. So basically the window is half one JPanel, half the other. And it should stay this ...
MouseTheMilkLover's user avatar
-1 votes
0 answers
17 views

Missing Window Buttons and Textfields Using Java Swing [duplicate]

I'm using a Windows 11 Laptop, the IDE is JetBrains Intellij Idea Community Version. My JDK version is Open JDK 20. I'm trying to make a simple window that accepts Centigrade or Farenheit and converts ...
Samuel Forel's user avatar
2 votes
2 answers
56 views

Rectangles created from java.awt.Graphics dissapear shortly after window is launched

Overview: I'm making a chess game using Swing (Java) and while making the checkered-board pattern, I've run into an issue where the rectangles that I created with drawRect disappear shortly after the ...
grenade05's user avatar
-2 votes
3 answers
44 views

(JButton) size of button in new window in JAVA GUI

I am using setbounds() medthod on my button to set the size and location of the button . After running,the size of the button is taken up all the frame.[my source code](the result: https://i.stack....
dopyman's user avatar
-1 votes
0 answers
28 views

How can i use this timer?Trying to stop the color change for 1 second and then make it back to the original red color [duplicate]

How can i use this timer?Trying to stop the color change for 1 second and then make it back to the original red color. code: Random rand = new Random(); int zufallszahl = rand.nextInt(4); Timer ...
Exotic's user avatar
  • 1
-2 votes
2 answers
54 views

why does the code work within main but not the class java swing [closed]

Cant seem to understand why the import doesnt work within the class import javax.swing.*; public class Main { public static void main(String[] args) { JFrame frame = new JFrame("Test&...
user22178888's user avatar
0 votes
0 answers
28 views

How to navigate between files in order to be able to add/remove panels from a frame?

I'm trying to make a text-based game and since I'm expecting to write a long code I decided to split it up into multiple files. (https://gist.github.com/Okkun9001/6d511dda544279a2c9d2e636b714a215) The ...
Péter Marschall's user avatar
0 votes
0 answers
33 views

How to properly design a desktop application managing a small database? [closed]

I have to develop a small Desktop application in Java/Swing managing a small SQLite database. The example described here is largely stupid but it fairly accurately represents my question. I need to ...
Christophe's user avatar
-2 votes
1 answer
42 views

Head First Design Patterns in p.543, What is The last question's answer? -> Design pattern to separate Model and View perfectly [closed]

I am reading chapter 12 "Compound patterns (MVC)" in Head First Design patterns second edition. On p.543, there is a Q&A, the last question of which is Q: The view is not supposed to ...
user18906921's user avatar
1 vote
0 answers
37 views

Zoom to Mouse Pointer using AffineTransform and JScrollPane

my goal is to implement an image viewer, where one can zoom to the mouse position and the JScrollPane correctly response to this zoom gesture. Also the possibility to roate the image would be nice. I'...
Displayname's user avatar
-2 votes
0 answers
31 views

How can I customize the rounded border of JTextField? [duplicate]

Finally i've created border-radius or rounded-border through the provided code below, i'm stuck on border customization on left side of JTextField as top-left: 0px, bottom-left:0px but top-right: 10px ...
Mohamed Gharib's user avatar
0 votes
1 answer
64 views

How to remove edges from JButton after border radius?

Finally it's done to make rounded corners for JButton, i'm tired to remove the edges that show after border radius without using transparent images Screenshot of JButton here's the code ...
Mohamed Gharib's user avatar
-2 votes
0 answers
40 views

I wrote a code to create a frame and button. On clicking the button, the labels and texts should be created. But no action is taking place [closed]

import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; /** * * @...
Ria Lalwani's user avatar
-1 votes
0 answers
27 views

Best Practice for implementing multiple ActionListeners in Java Swing? [duplicate]

I'm writing a GUI project in which I need the user to be able to access different JPanels at will. For that purpose, I have a bunch of buttons in a menu panel, as well as taskbars with buttons in ...
CodingPhoenix8's user avatar
0 votes
0 answers
35 views

How to create a new textfield in a panel at runtime with Java Swing and Netbeans UI

i have a problem: I want to create a new textfield at runtime by clicking a button (jButton1). But when i click the button nothing happens. Can anybody help? I use Netbeans and create the existing ...
texs89's user avatar
  • 1
1 vote
0 answers
86 views

Random text showing on JButton when changing background to translucent color [duplicate]

If I change my JButton to have a translucent color (0 < alpha < 1), I get wonky results for my JButton text. package Paint; import javax.swing.*; import java.awt.*; import java.awt.image.*; ...
davidalayachew's user avatar
1 vote
1 answer
32 views

JPanel CardLayout causes visual glitch between swaps

I am trying to create a JPanel with a CardLayout that switches between a menu and a forum when a button is pressed, but I am encountering a visual error where elements of the menu are still displaying ...
FMrts's user avatar
  • 21
0 votes
1 answer
36 views

Java JTable "scrollRectToVisible" Bad Graphics?

I am trying to consectively scroll a JTable, and scroll to the given cell by index with the following code... public void UpdateCurrentStep(final int index) { jTable1.setRowSelectionInterval(index,...
M. Rogers's user avatar
  • 367
-3 votes
0 answers
36 views

How to add a background for JTextArea? (TextArea into a ChatBubble)

I'd like to add a background frame the size of the message that gets sent to mimic a text bubble. However, it's not appearing when I run the code. The frame should also be positioned under the message....
PokeCedGo's user avatar
1 vote
1 answer
28 views

Is there a way to center only the selected item in a JComboBox (so keep all items in the combo box left-aligned)

I know there is a simple way to center all the items in the JComboBox, but i have searched StackOverflow and across the web and there is no talk about how to center the selected item only. To make it ...
Chiselled's user avatar
0 votes
1 answer
50 views

TablecellRenderer setForeground only on certain characters in cell

I'm trying to create a JTable where in one column certain characters have a different color than the rest. Text1test Text2test Text4test In this example, I want the numbers to be blue, the rest black (...
charly's user avatar
  • 3
0 votes
1 answer
17 views

New netbeans project outputs code but not jframe ui

I just created a new java project and opened a jframe file. When i added a few buttons and previewed it, it looks fine. But when i run the file (indexx.java) it shows me only the standard 'Hello World'...
Tnsae's user avatar
  • 1
0 votes
0 answers
20 views

Why I am getting build fail in my NetBeans project when I tried to clean and build my project?

I started clean and build my NetBeans project, but it gives me this output that it can't build. My library JAR files are OK and I have checked all my connections. this project is palced in local drive ...
Bilal Sahi's user avatar
0 votes
0 answers
40 views

How to create a Scrolling Pane for a Chat System?

I've already created a working scrolling pane using JScrollPane, however, the current code works as follows: I type something into the chat input, press enter, it creates a JPanel and adds it to the ...
PokeCedGo's user avatar
-1 votes
0 answers
54 views

How can I use DbUtils.resultSetToTableModel with a TableModelListener [closed]

How can I use a TableModelListener with JTable.setModel(DbUtils.resultSetToTableModel(rs). Please give an example and make your code very easy to understand.
Oluwatobiloba Oni's user avatar
1 vote
1 answer
31 views

Is there a way to access the Components contained by a PanedWindow in python tkinter?

I have to access the components contained by a tkinter.PanedWindow so I can modify the value of the amountused of the ttkbootsatrap.Meter with the method update(). Is there a funcition similar to the ...
Ícaro Aquino's user avatar
0 votes
0 answers
34 views

How to make image automatically resize in the JLabel after being selected by the user

Actually I want to create a car dealer application, using Java Swing, in which I want the user to select an image of the car which he wants to sell and that image should be visible automatically in ...
beginner's user avatar
0 votes
0 answers
26 views

How to make image automatically resize in the JLabel after it is selected by the user

Actually I want to create a car dealer application using Java Swing. In which I want the user to select an image of the car which he wants to sell and that image should be visible automatically in the ...
beginner's user avatar
1 vote
1 answer
39 views

Canvas render sometimes and doesn't render other times

It is not completely random, at some point in my code I create a matrix, the smaller the matrix, the higher the chances of the canvas rendering normally. Even if I completely remove the matrix it ...
Rafael Silva's user avatar
-2 votes
1 answer
39 views

Code was skipped after a instance of JPanel was created

I am making a copy of the game Tetris and have created a game panel. I was trying to swap the order of tetris.initGamePanel(); and tetris.initWindow(); in public static void main(String[] args){ ...
山宗陽成's user avatar
1 vote
3 answers
61 views

adding a non-scrolling component to a JScrollPane

I'd like to add a non-scrolling element, always visible element (a "pinned" element) in a JScrollPane of a Swing GUI. Taking this example code: public class Main { public static void ...
ix0rai's user avatar
  • 49
0 votes
2 answers
37 views

How to increase the height of a Jscrollpane after it is visible?

My customer have lib of classes that extends swing components. One class extends Jscrollpane. There is a case when he knows what will be displayed in it. ( A size expandable text component, like a ...
user2902165's user avatar
0 votes
3 answers
62 views

How to read and print Hindi characters from text file in java

Text file is: MHEM CLASS 1 MHEM CLASS 2 MHEM CLASS 3 MHEM CLASS 4 MHEM CLASS 5 कक्षा 4 रिमझिम कक्षा 5 रिमझिम I need to read character's कक्षा 4 रिमझिम कक्षा 5 रिमझिम The dropdown is showing ...
Monita Shinkar's user avatar
0 votes
1 answer
43 views

fireTableDataChanged() java

Why does my model update the JTable view even if I do not call the fireTableDataChanged() ? Is this normal behaviour? @Override public void updateGUI(GUIUpdateEvent obj) { System.out.println("...
wydra__'s user avatar
  • 27
-1 votes
0 answers
37 views

Components appear to be duplicated with some offset within a bounded region in GUI [duplicate]

I have essentially no experience designing GUIs, so I am currently trying to teach myself a little Swing. My current project involves rendering a simple game-board-like grid, and a number of objects ...
R. Thomas's user avatar
0 votes
1 answer
69 views

Make JButton update JLabel text in other class in Java

I'm writing a program for my company that references an excel file for project information. I've organized the program into 4 JPanels, each in it's own class. i.e. Panel_1, Panel_2, etc. I have a ...
JarodH99's user avatar

1
2 3 4 5
1621