Category "swing"

Java Swing - Maskformatter digits from Right to Left

I would like to enter in a JFormattedTextfield with a Maskformatter digits for inserting time units (min:sec with mask ##:##) from Right to the Left. I used Set

How to update chart after selecting item from JComboBox?

I'm trying to change the values of bar chart depending on the selected item from the combobox list. The code below is a short example. The method for creating/u

How to get the whole row of a JTable to save it into another table?

I am trying to validate that when the column step is equal to 2 the row is copied to another JTable. But the jtable_step2 I have not initialized correctly, that

Do I need synchronization if I reference objects from other thread to AWT thread?

Does SwingUtilities.invokeLater provides synchronization? Example: public class Threads { public static void main(String[] args) { new Thread(new Ru

The best layout for this image?

I don't know which is the best layout to use for this image, I think maybe grid layout (5*1) may be helpful but I can't add multiple components in one grid layo

Fixing WindowBuilder UI

The bug is hard to explain so I will add images to show my problem. As you can see in the provided picture the interface is completely empty. Does anyone know h

Open JFrame from JDialog and it shows on top of JDialog

This is the scenario, My JFrame has a button it will open a JDialog when click it and it is a model dialog. JDialog has another button and i want to open anoth

JOptionPane with switch cases

Well, this code actually run but ended up with wrong output (specifically in "Randoms" cases) Note: it has a random generator for a random result or output I

How to add an ImageIcon in java? this code is not working

I want to add an ImageIcon to the Panel, but I got this Exception ( java.lang.NullPointerException: Cannot invoke "java.net.URL.toExternalForm()" because "locat

Adding a JScrollPane to a JMenu

I have a JMenu which will include JMenuItems that are generated on start-up from a database. As such, it's quite likely that the menu will be too large and run

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.