tldr; How do you use a MouseEvent on a JFrame object(specifically JLabel) to update the displayed image in the JFrame I am trying to create a program where an image is broken into tiles and on click of one of those tiles, the program moves the tile to the open space in the image. (See Sliding Puzzle for more …
Tag: swing
How do I put two Jpanels/Jbuttons in the borderlayout north section?
How do I display two JPanels in the ‘North’ in borderlayout? Here’s and example code that outputs a GUI with three distinct rows, Top, Middle, Bottom. There’s one button covering the first row, 3 buttons covering the second row, and one covering the bottom row. Output of above code: ou…
Display all the items I have ordered
How to display all the items I have ordered in “Sales Report File”? Like whenever I ordered 2 cookies, It will display on the Sale Report file. I have this code currently.. Answer If you want like a text list of what you have ordered, you can simply create an ArrayList<String> and every time…
determine identification of a JCheckBox in itemListener
I have 4 check boxes, and the user can select or deselect them for their required settings, however, the program requires at least 1 check box to be checked in order to generate the required information for the user. If the user unchecks the last remaining checked box, I want the program to recheck it for the…
how to make more buttons in java GUI swing
I would like to use the java swing to make two buttons, one that add +25 to 100, the initial value, and one other that adds +10 to 100, always the initial value: as you can see it should create two buttons, this is what I receive as output at first: and after I click it, it just adds 25
Filtering Table using BETWEEN but data are not showing up [closed]
I am trying to filter my table by Month using combobox but whenever I select October nothing shows up even the timestamp from my database is October. Here is my code: String monthSelection = …
How do I enable a button after the scrollbar goes to the bottom?
So, I used a JScrollPane and then I added a JTextArea. I used textArea.setCaretPosition(0) to reset the scroll and it went at the top. All good, until I wanted to set a disabled Button on enable when the scrollbar reaches at the bottom. How can I do that? Answer You can listen for changes to the JScrollPane’s…
Java move GUI panel While loop
I have a panel. I want to move the panel, inside a while loop, to the left and then to the right, after pressing a button and until a certain condition is met. But for this question let’s say continuously. After it finishes an iteration, it doesn’t move left or right. I used repaint() and Thread.s…
JComponent not being drawn on JLayeredPane, JPanel is
I’ve added a JLayeredPane to a JFrame. To said pane i’ve added a JComponent with overloaded paintComponent(Graphics g) method, which calls super.paintComponent(g) among other things. The JComponent …
Waiting for a task inside a thread pool using SwingWorker java
I’m simulating multiple Tasks inside a thread – when all of them should report to a GUI. So I have a unique form that has 4 Panels inside which should reply and do different Tasks.. they should each keep pooling a database and reporting stuff to the GUI. In this example, I just made it to write nu…