Here is a little program that should (in theory) draw an image of a ball on screen. The problem is that paintComponent seems to not get called. The program consists of two classes. As you can see, I tested if paintComponent was called using a console message. Sadly this was not the case. Can someone explain? Answer It’s no wonder
Tag: swing
JTable not visible inside JScrollPane
I have a JTable inside a JScrollPane. I want to show the table only when a particular button is pressed otherwise it should not be shown. Inorder to incorporate that I have set the setVisible method of the ScrollPane to false while declaring and I set it to true inside the actionPerformed method of the JButton. But the JTable is
JTable RowFilter – case insensitive
I’m having a problem with a RowFilter, I’m trying to make it display data without it being case sensitive. I tried adding “(?!)” in the RegexFilter but that only makes my table not display any data at all when I try searching. What am I doing wrong? Answer You probably wanted to prefix the search string with (?i) (case insensitive
How To Open File Dialog And Create File On It?
1 I opened File Dialog but I don’t create the file on it? How? Answer To save a file with JFileChooser, you need to use the showSaveDialog() method instead of the showOpenDialog() like in your snippet. For more information check out How to use File Choosers and check out the JFileChooser JavaDoc. Then the next step if the saving has
Ending a timer using keyadapters?
So, I am creating this reaction time game that shows a blue ball and once you see that blue ball, you press up arrow key to get your reaction time once it turned blue. However, I am having trouble in creating a timer. I want the timer to start once the ball actually turns blue and want that timer to
Java Inheritance: Paint Program only shows a black screen but doesn’t have any errors
I know its a lot of code but I could really use some help identifying my problem. Thank you! I am just now being introduced to inheritance and am challenging myself with this application to a painting program. The program is meant to draw different shapes (lines, oval, rectangles, etc.) and I used trial and error to get what I
How to trigger another action listener after completion of ActionListener?
I created a GUI with a JFrame, JPanel, JLabel and a JButton. I added the button and the label to the panel. I added two ActionListeners for the button. I want to execute the first action listener. Then execute the other one. Basically, I have some text that I want to output in the label, sequentially. I want for it
How to fix JPopupMenu get hidden inside the insets of the border?
I need to show a menu inside a dialog. However when the JPopupMenu gets hidden inside the border when the barder insets are large. Above code creates a dialog box and when clicked on the button menu should appear but it get hidden inside the border inset. like this If the insets of the border is changed as this return
Java GUI – Progress bar doesn’t update until the async task is finished
I am using CompletableFuture to run a long running operation. Meanwhile, i use SwingWorker to update a progress bar with increments of 5. The progress bar doesn’t update until the asynchronous method is finished. I have also tried doing this operation on the EDT thread, but to no avail. What you are seeing is basically me trying to just do
Creating a XYChart on button click
The purpose of the program is to display chart on click of the button with given parameters. However displayChart uses invokeAndWait, which cannot be executed inside ActionListener which makes sense. What is the proper way to solve this issue? I am using swing with XChart library Answer You have to create the frame and its content panel by yourself, note