Questions tagged as 'swing'

1
answer

how to position the Caret of a JTextField?

I have JTextField where opening and closing parentheses is optional. However, whenever the user opens and does not close a parenthesis, my program gives error, because I use this text field to calculate an arithmetic expression. In ord...
asked by 05.07.2017 / 16:05
1
answer

Doubt regarding dispose () in JFrame

I'm trying to check the login screen to see if the configuration file where the access information is already set exists. If it does not exist, it was supposed to give dispose on the login screen and open the setup. For some reason,...
asked by 12.07.2017 / 17:39
1
answer

Align JPanel button

I want to align a single button to JPanel, but I'm not getting it, it's using the default layout. public class Test extends JFrame { private JButton btn; private JPanel painel; private JScrollPane scroll; private JTextArea tAr...
asked by 21.05.2017 / 00:51
1
answer

IndexOutOfBounds while populating an AbstractTableModel

I have a AbstractTableModel that has a List filled through a method that fetches the data in the database. The method that fills List has two overloads: one with no parameters (which fetches all data) and one with a search paramete...
asked by 20.05.2017 / 07:08
1
answer

Trigger two different events with JButton

I'd like to know how to trigger different events using the same button. What I wanted was for the next click to give jButton1.setText("Créditos"); and return to btnGerar.setVisible(true); The idea is that when I click on "Credit...
asked by 04.06.2017 / 06:14
1
answer

How to add scrollbar to a Scrollpane?

I have a panel, and I will have just fields and buttons on it. I thought about using JScrollPane to not make the screen so large. However, I'm not able to add this scrollbar. How do I add a scroll bar inside the p panel, in the sample...
asked by 02.05.2017 / 04:45
1
answer

How to differentiate buttons within the same event?

I'd like to know a method to differentiate a button that generated event, in my method that will handle events. In the example below I add the same class that handles events to 2 buttons, but I can not differentiate the buttons in my method...
asked by 13.05.2017 / 03:36
1
answer

How do I add an event to an icon?

I wanted to make clicking on an icon possible to open a screen, perform any action and so on. I wanted to put different formats, so I do not use a JButton . For by passing the image to him, he continued "rectangular". More, if there is...
asked by 27.05.2017 / 05:10
1
answer

Error accessing local variable in anonymous class

For some reason netbeans asks to change the variable i to FINAL, but if so, I will not be able to edit it. The following is the error:    Error: local variable is accessed from within inner class; needs to be declared final The...
asked by 05.03.2017 / 04:11
1
answer

Java java.lang.NullPointerException in the constructor of a JPanel

I'm trying to compile a game from memory in java, but it gives the following error: Exception in thread "main" java.lang.NullPointerException at javax.swing.ImageIcon.<init>(ImageIcon.java:217) at memorygame.Game.initSquares(Game.java:...
asked by 09.12.2016 / 02:12