Most voted "swing" questions
Swing is a Toolkit widget for use with Java, compatible with the Abstract Window Toolkit (AWT). Use this tag for questions regarding components or classes related to the development of graphic applications using this API.
Learn more…749 questions
Sort by count of
-
2
votes1
answer128
viewsHow to position a component next to the Windows clock?
I learned that to center a component in the center of the screen just use: frame.setLocationRelativeTo(null); But how do I show the component on top of the Windows clock independent of the screen…
-
2
votes1
answer1313
viewsRecover the value of a Jtextfield via an Actionlistener
I’m a little new to java and I was trying to understand the listeners. So excuse me if the mistake is simple. I have a program that creates a simple graphical interface and I want to get the value…
-
2
votes1
answer311
viewsBuild report in Java
I’m doing a system with swing as a college job and at the end of each cycle of days the program wanted it to generate a report. Does anyone know how to compile a report in Java?
-
2
votes1
answer1537
viewsHow to change the standard source of Swing components?
I wonder if there’s any way I can change the font pattern from Labels and Swing buttons, if possible, for general design. All the Labels that I create I have to keep changing the font to one that is…
-
2
votes1
answer1507
viewsSelect Multiple Lines in Jtable in Java
Good evening Guys, my doubt is how to select several lines in an action, is that I intend to create a condition in a column if the value is higher select the row, more if have equal values have to…
-
2
votes1
answer1395
viewsHow to pick up Form value - Java - Swing
I created a form on Java interfacing Swing, in this has a field textfield Text and a button Send, in the code of the button need to assign the value informado in the textfield to a variable of the…
-
2
votes1
answer1392
viewsGet item value in focus on a Jlist?
I have a Jlist and would like to take the value of the item that is in focus on it, not want to capture this value with click or with some button, but rather just changing the focus(by clicking on…
-
2
votes1
answer838
viewsShoot event by clicking on day in Jcalendar?
How do I place an event in each Jcalendar day? My intention is to click on a day and create a kind of reminder that is related to the day, in a way that when the user clicks on the day again he sees…
-
2
votes2
answers3201
viewsHow to display incoming variables in a Jframe?
I’m working with server socket, it receives information from an Android app, are three information: table, order and quantity. However, I can not show this information in a JFrame, I have no idea…
-
2
votes2
answers119
viewsHow to get the type of component clicked?
The getSource() method returns the event source, there is some method that returns the event source type, whether it was a jlabel, or jbutton, something like?
-
2
votes1
answer1603
viewsPerform actions from the selected item in Jcombobox
I wanted to assign value to another class, whichever is selected in JComboBox. For example, if the "Active" item of a combo is selected I wanted to assign a value to a string from an external class,…
-
2
votes0
answers75
viewsSet width of Jdialog according to the size of the sums of the columns of a table
I have the column width sum and I need to set this value so that it does not hide parts of the columns and decrease the window. Any suggestions? I created a method that returns the sum of column…
-
2
votes1
answer140
viewsCustom jcheckbox does not appear
I’d like to exhibit a JCheckBox larger than normal by default interface. After some searches I found in the link Customize Jcheckbox icons an example to be used, but it does not change the size of…
-
2
votes1
answer2043
viewsHow to set the location of Jbutton according to the size of a Panel
I’d like to define the location of color1 according to the size of a Jpanel, the same way I did with the fundo public static void janelaPrincipal() { //FRAME JFrame janela = new JFrame();…
-
2
votes1
answer1068
viewsOpen Jframe in maximized Java
I’m having a problem, I’m creating a Jframe and I want it to open maximized. I’m using the following code: frame.setExtendedState(Frame.MAXIMIZED_BOTH); frame.setLocationRelativeTo(null); The size…
-
2
votes1
answer327
viewsSet which Jframes will focus?
I need to leave a JFrame in focus and not allow use of others, until I close this. Every time you open a new frame the others below it should be dead. How can I do that?…
-
2
votes1
answer3515
viewsHow to take data from a Jtable for storage in a database?
I’m developing a project called Menu List with a Mysql and Java database in Netbeans, with an added Mysql-Connector-Java library. I want the names of the selected products, the quantity of products…
-
2
votes1
answer1973
viewsAdjust columns according to available Jtable size
I have a JTable where the user can hide and then re-display one or more columns. I found a code at this link which adjusts the column according to the size of the "field value". I call this method…
-
2
votes0
answers214
viewsHow to display data dynamically in Jinternalframe?
I am making a little betting software and I am completely lost in being able to allocate data dynamically in my interface so that for each entry in the database a structure with a JPanel which will…
-
2
votes2
answers1178
viewsJava - Enter function
In the system there is a field, the person needs to fill this field and then press enter. By pressing enter the system does a check and then opens a JOptionpane asking to select: yes, nay, okay,…
-
2
votes1
answer1013
viewsOpen multiple windows from the same application without accumulating icons in the taskbar
I wonder how I could create frames in java, without opening so many windows in the windows taskbar. For example when I go to the menu and click on client registration, address registration, address…
-
2
votes2
answers175
viewsNullpointerexception error, where is the error?
I wanted to know where the mistake is. I read that the mistake NullPointerException is when we try to access a variable that wasn’t initialized, I just didn’t find this error in my code. import…
-
2
votes1
answer290
viewsHelp to fill jTable
I’m filling out a jtable with the birthday kids who are registered in a database. public void jTablePop() { javax.swing.table.DefaultTableModel dtm2 =…
-
2
votes2
answers560
viewsHow to create shortcut to open a Jmenu?
Speak guys, does anyone know how to create a keyboard shortcuts method to open a Jmenu. For example, click F1 or CTRL + "something" and open a screen.
-
2
votes1
answer1517
viewsCreate Jframe with label?
How to create a Jframe, containing a Jlabel with text, and can be positioned anywhere in the frame. I need this label to be anywhere in the frame area.…
-
2
votes1
answer243
viewsHow do I define column size?
I have a query screen, and I would like to define the size of the columns, because some columns take up more space than necessary. I thought that if I made a comparison with the title of the column,…
-
2
votes1
answer97
viewsIs it possible to open windows generated from netbeans in Window Builder?
I migrated some projects in swing netbeans with windows generated by GUI-Builder for Eclipse, but Window Builder cannot generate screen design by reading files .java created by netbeans. It is…
-
2
votes1
answer343
viewsIssues in netbeans with connection to Postgres
I have a bank called BANCO_DE_TESTES in Postgres that has some random tables. In netbeans when I try to use the Master Sample Form/Detail to use JPA to create a simple crud it doesn’t work saying…
-
2
votes1
answer540
viewsHow to exchange the Joptionpane background with an image?
You can use that "ImageIcon" as background of a JOptionPane? Follow the code I tried: public static void main(String args []){ UIManager UI = new UIManager(); ImageIcon icon = new…
-
2
votes1
answer2691
viewsHow to open a window inside a main frame?
I’m doing a show and I’m creating the layout manually with swing using GridBagLayout and GroupLayout. I wonder how to open a window inside the program I’m doing. For example: When the user clicks…
-
2
votes1
answer504
viewsView Splashscreen with progress while Jframe is loaded
I have an app made on swing, and I’m trying to add a SplashScreen in it. I managed to make the class SplashScreen work normally, but I’m not able to synchronize the loading of Jframe in invokeLater…
-
2
votes2
answers1031
viewsEvent click button
I add a few buttons like this: JButton bt; for(int i = 0; i <= 10; i++){ bt = new JButton("BT : " + i); bt.setPreferredSize(new Dimension(80, 80)); bt.addActionListener(new ActionListener() {…
-
2
votes1
answer741
viewsHow to leave only one edge on Jtextfield?
I wonder how to leave only one edge on one JTextField, similar to data entry when logging into Gmail, that is, with a border at the bottom.
-
2
votes1
answer1273
viewsHow to make part of the Jlabel text bold
Is there any way to leave only a portion of the bold text of a Jlabel? For example: label.setText("apenas esta parte em <b>negrito</b>"); But this snippet of code prints the 'b' on the…
-
2
votes1
answer115
viewsModify the range of a Jslider
In my project I have a Jslider, its minimum value is 0 and its maximum value is 10. I would like to modify it so that its interval is two in two numbers, so that it is only possible to select/show…
-
2
votes1
answer170
viewsWhy unmark the main class creation when we work with canvas?
So far, in all tutorials I’ve seen, when we’re going to work with a swing screen, we’re asked to clear the main class creation. I would like to know the science behind it, and what results if I…
-
2
votes1
answer898
viewsRemove Jpanel from view
I would like to know how to remove one JPanel that is inside a JFrame. I don’t want to use the information or anything, I just want it to close. Use setVisible(false) makes the panel invisible, I…
-
2
votes1
answer411
viewsHow to create a folder browser in java swing?
I want to create a window and it has a button, when the user clicks that button appears that "typical windows folder browser" for the user to select a folder from his machine and the folder address…
-
2
votes1
answer305
viewsQuestions about the Graphics and Graphics2d classes in Java
I am having many doubts regarding the graphic libraries of Java, which are the following: What is the difference between overwriting the method paint(Graphics) or the method…
-
2
votes1
answer32
viewsDoubt regarding the Dysplasia() and Repaint() methods
What is the function of the methods .dispose() and repaint() using Graphics in Java?
-
2
votes3
answers1139
viewsRetrieve/locate object in arraylist
I am making a small CRUD with the theme saving for study purposes. I created 3 classes: Save, Accounts and Canvas (UI Swing). On the screen I register an account with the attributes name, agency,…
-
2
votes1
answer257
viewsPlace object array in combobox
I have the following method for adding objects to a JComboBox: public void PopulaCategoria() throws SQLException{ for(Categoria categoria : caDAO.getCategorias()){ comboCategoria.addItem(categoria);…
-
2
votes2
answers2905
viewsJtextfield null field validation
On my system, I have a window and a controller, but for some reason, it is never launching the error as expected : Method of validation : private void validacao(){ if((form.txtNome.getText() !=…
-
2
votes4
answers788
viewsConvert Int to String
I’m trying to make a button to register to the bank but am having difficulties in converting the int to String. follows my line of code: private void…
-
2
votes1
answer96
viewsFix Jbutton that is running 2 events
I have an application where in a Jframe I create new records for mysql table, and in another I return a select JTable with all records created. I have a change button, which when I select a Jtable…
-
2
votes2
answers80
viewsButton does not work when code is added to Abstracttablemodel
I created a test project to implement in a larger table project with a button as one of the row elements. It works perfectly, but when I try to add to my code the button does not perform the action…
-
2
votes1
answer522
viewsHow to use the TIMER class in a method with Math.max and Math.min
I’m on a kind of ambitious project to create my little math game (which I found better than a simple calculator) in just one JFrame, methods only, without using any other class in the package...…
-
2
votes2
answers385
viewsDisplay Jcombobox object data in a Jtextarea from the selected item
I wanted to show the data of a customer who is on a combobox inside a Jtextarea, as in the following image: The problem is that only the information of "Igo Brasil" is shown, when I try to show the…
-
2
votes1
answer37
viewsNullpointerexception when trying to log into the system inside netbeans
Soon after I did some icon overwrites on the main screen and on the About screen, error occurred NullPointerException, I have no idea how to continue and continue the course I am doing. I use Mysql,…
-
2
votes1
answer507
viewsJbutton shoot two different events?
I have a program that simulates a game of dice, where I have two "dice" that, when the sum of the two gives 7, the user is winner, if not, he loses. Well, I made a simple interface on swing, where I…