Category "swing"

Reading from a .txt file into a JFrame

I'm stuck trying to figure out how to read from a Java file into a JFrame. I need to make a frame and read in the names of cars and how much they cost. From the

Swing Timer stopwatch in Java

Can someone provide me an example of a Swing Timer stopwatch GUI in Java using a constantly-updating JLabel? I am not familiar with using @Override, so please

Is there a way to make a 2nd click change the result?

I'm trying to make it when you click the cameraButton, the graphics show, but when clicked again, it closes. @Override public void paintComponent(Graphics g

(Solved)Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException javax.swing.ImageIcon.<init> Resource file does exists

According to this video https://www.youtube.com/watch?v=n_Y7r-7GxDo I need to place the icons in the main package. Even after this, I get the same error packa

How to dynamically add items to a JList?

I'm having trouble adding items to a JList called lstContacts whenever a button is pressed. When I press my new contact button, a line should be added to lstCo

(Solved)Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException javax.swing.ImageIcon.<init> Resource file does exists

According to this video https://www.youtube.com/watch?v=n_Y7r-7GxDo I need to place the icons in the main package. Even after this, I get the same error packa

Open a JPanel after pressing a button in a JFrame [duplicate]

I know this question has been asked, but I failed to find a solution. I created a JFrame for Login and I want after the button "Cont Nou" is

Why does this GridBagLayout not appear as planned?

I was trying to achieve the end result required in Setting an arbitrary width in GridBagLayout. For easy reference, here it is: This is the current result:

Pagination in JTable with row sorting

I have implemented pagination in JTable, in that there is row sorting as well. My problem comes when I click on the column header for sorting it sorts the curre

Switching between screens in Java swing

I had build big application for my client in Android. The new project is to build the same app for PC in Java. So i have started developing with use of swing.

Drag and Resize undecorated JFrame

Currently, I am using the following code to drag and move my undecordated JFrames. private void initialiseGUI(Component component){ //<editor-fold defau

JSVGCanvas svg is blurry

I have pretty much copy pasted the code from http://people.apache.org/~clay/batik/svgcanvas.html but the svg that is outputing is blurry. I have used both a fon

jTable saving each row element in the new line in the .txt file

I have a problem with saving the jTable contents to a file. Every row data printed to file makes a new line along. So reading from .txt looks like this: Here

How to put Hover effect on jbutton?

I am trying to create a Java Desktop application where I am using two buttons. I want to add hover effect in those buttons. I want: When I click any button it s

Java Graphics, Graphics panel and Buttons Panel

I am trying to create a Frame that has a graphics panel on the top portion (through a Layout) and a buttons / labels panel underneath it in the same frame. So

Rotating BufferedImage instances

I am having trouble getting a rotated BufferedImage to display. I think the rotation is working just fine, but I can't actually draw it to the screen. My code:

How to validate Hour and Minutes that came from a Swing textBox?

I have a window that contains a HH:mm time TextField in it, in 24 hours format I need to validate if the user entered any non valid hour, like 28:00, 99:00, 24

How to validate Hour and Minutes that came from a Swing textBox?

I have a window that contains a HH:mm time TextField in it, in 24 hours format I need to validate if the user entered any non valid hour, like 28:00, 99:00, 24

How to remove auto generated code from Netbeans

Whenever I create new JPanelForm, NetBeans will create some auto generated code in initComponents() method. How can I remove this auto generated code from my JP

How to make JTextField lose its focus?

Exacly as stated in the subject how to make JTextField lose its focus? Something like: jtf.setFocus(false)