Skip to content
Advertisement

Tag: swing

paintComponent() not being called

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

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

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

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

Advertisement