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
-
1
votes1
answer586
viewsMultiple buttons (Jbutton) with the same function in different Jpanels
I’m making a program (using the Netbeans GUI Builder and Cardlayout) with multiple screens (multiple Jpanels) and they’ll all have a start button, which obviously goes back to the home screen. I…
-
1
votes2
answers407
viewsHow to receive user date through Jtextfield, using Jodatime?
I am unable to do the user input. I want the program to make the difference of days between today’s date and the date typed by the user. The program has more implementations but it’s just this part…
-
1
votes2
answers2638
viewsHow to call a method into an If and Else?
I am developing software for a video rental company with Pattern MVC (Model-view-controller) design and the problem of not calling the save() method and the change() method is occurring inside If…
-
1
votes1
answer355
viewsAdd lines in a Jtable according to ascending order
I’m making a RBC system to verify the similarity between computers. I would like to sort my table rows by the value of probability. The problem is that the table has around 9,500,000 rows. Does…
-
1
votes0
answers104
viewsHow to use setCaretPosition in Jformattedtextfield?
I’m having trouble to "set" the cursor at the beginning of the field, using the setCaretPosition(0); in Textfield fields, it works correctly, but in any field with masking (Jformattedtextfield…
-
1
votes1
answer2024
viewsDisplay text in Jframe
I would like to know how to assemble a text in my Java class, but this text would have the contents of a record of my database. I’ve done more or less that using JLabel but it creates one-line…
-
1
votes0
answers472
viewsI can’t update jFrame from a Java thread
I have a code that reads the Serial Port through a thread, but when I try to update a label I can’t. I implemented a Serialread Runnable class, and in this class I run a loop to read the serial…
-
1
votes0
answers173
viewsHow to underline a specific character in a Jtextfield
How to change, say, the font of one or more characters of a JTextField allowing them to be underlined, bold or italic? But, the rest of the text would be normal. But in this case I need to…
-
1
votes0
answers82
viewsIs there a Recyclerview equivalent in Swing?
In Android Studio, I use a class called RecyclerView, that repeats a layout while there is data for it, as if it were a list. There is an alternative to this in Java using Swing?
-
1
votes1
answer463
viewsHow to add Mouseclicked to a Jlabel?
I am creating a program with MVC rules in Java and would like to know how to create an Event in JLabel for when I click on it with the mouse. For example, for the buttons I do so: View class: void…
-
1
votes1
answer150
viewsQuestion about updating Jlabel in Jframe
Why can’t I update my labelHora in the Frame? Using a print after the line labelHora.setText(x); I realized that the content of lip changes, but on the screen continues the pattern, which in the…
-
1
votes1
answer41
viewsJtree does not update when starting GUI
I’m having a problem that I’m not being able to visualize the solution: Simply put, my Java program has a swing GUI that contains a Jtree (Treemodel customized for system directory view ) There is a…
-
1
votes1
answer106
viewsIs it possible to activate the Operating System context menu in swing application?
Some time ago I realized that it is not possible to call the operating system context menu in swing components, although it is possible to perform standard keyboard actions (such as copy, paste,…
-
1
votes1
answer157
viewsJframe opening repeatedly twice
I’m new to desktop programming, well, I’m making a program in java using swing and sqlite database, I’ve already made some things work, but after login the jframe that should open a single view…
-
1
votes3
answers1781
viewsHow to validate a double field?
Good afternoon guys, I’m not able to validate the field type value double The field I cannot validate for the registration is the field valor. Follows the class method to validate the data to…
-
1
votes1
answer1228
viewsNullpointerexception error when running java Maven project
I created a Maven Java Application project and only created a layout of a screen. When I try to run, it shows the error of NullPointer, I have not yet implemented any code other than the IDE’s own.…
-
1
votes1
answer762
viewsShow typed text in a text field after clicking button
The code below I got from the Internet is working for me. In the main, it executes a form with the name to type and the button ok. I wanted to run, no main, shortly after the new MeuPrograma(); one…
-
1
votes1
answer911
viewsCreate java icon button?
I’m having trouble creating an icon button in java, I’ve looked at several tutorials, but I can’t make it work. Note: I am using eclipse, Windows 10. The folder that is the image is src where the…
-
1
votes2
answers797
viewsAvoid opening more than one of the same Jinternalframe
I’m developing an application that uses JInternalFrame within a JDesktop. When I push the button, this one JInternalFrame is instantiated and the window is opened, however, if I press the button…
-
1
votes1
answer172
viewsAdd Jinternalframe to another Class
I own a JInternalFrame for editing budgets, my JDesktopPane is in a different class from the class I call the JInternalFrame, how to add the JInternalFrame in the JDesktopPane. Start Class public…
-
1
votes1
answer70
viewsCan I create a full app without using swing?
I’m creating a system and a question has arisen! Can I create forms without using Swing, AWT or the basic libraries in Java? If I use another framework, I can set aside Swing, AWT etc? What better…
-
1
votes1
answer368
viewsHow to draw GIF with Image and drawImage
I need to draw a GIF, I have the following code: public BasicBlock(String path, String name, int id, boolean gif){ this.path = path; this.name = name; this.id = id; File img = new File(path); try {…
-
1
votes1
answer71
viewsDisplay multiple columns
I am developing a basic program in Java Application (Desktop) that performs a simple registration and displays on another screen through a Jtable the recorded data in the same. My problem is that…
-
1
votes0
answers304
viewsValidation of Jdatechooser
I need to validate three dates that are like JDateChooser. These dates are: date of birth, date of admission and date of dismissal. The date of birth may not be longer than the date of admission or…
-
1
votes1
answer3495
viewsUpdate Jtable after each data change in a cell
I’m using java swing where I have a window and in it a JTable. I run a method where you will read the data from this Jtable and update a column, cell by cell, of this Jtable. The problem is that it…
-
1
votes1
answer173
viewsHow to recover combobox index from a string?
I have the String for a combobox item, but when the user clicks on the table, the combobox should automatically select the category for that particular item. However, I found that there is no…
-
1
votes1
answer547
viewsLine break in Jbutton
I am developing a complete and beautiful periodic table for the course. But when it comes to implementing jbutton it lets me put only one text, no space, line breaks and other sentences in other…
-
1
votes1
answer661
viewsClose window by clicking Jbutton
It is possible by clicking a button and the JFrame be closed as if you had clicked on the window X? If possible, how do I create it? From what I’ve studied is using ActionListener but I can’t find…
-
1
votes1
answer421
viewsDisplay confirmation when trying to close a Jinternalframe
I’m creating a program using JInternalFrame, but would like to request a confirmation in case the user click the close button "Closable". For that, I’m trying to overwrite the methods…
-
1
votes1
answer441
viewsPick selected value from Jcombobox populated with Enum
I have at my window one JComboBox with items from an Enum, and a JLabel to show the value of the selected item in the combo. So far so good, I’m able to do this, only I’m a little unsure if I’m…
-
1
votes1
answer558
viewsHow to use arrow keys, like up, down, from the keyboard to navigate a list of buttons?
I have these buttons implemented with mouse click, only I wanted the following: that I could navigate through them direction keys up and down and enter through the enter. Does anyone know how it…
-
1
votes1
answer66
viewsDoubt regarding dimensioning methods in a Frame
What is the difference between the method setSize() and the method setPrefferedSize() in a Frame, and in which situation each one should be used?
-
1
votes1
answer148
viewsPick up Frame already started from the "Event Dispatch Thread"
I have a desktop application on swing, and in it, I have a single JFrame which is always visible while the application is open. There are also some JDialogs modals dependent on this Frame, which…
-
1
votes1
answer184
viewsLook and Feel in java
I have an application that uses Windows Look and Feel. However I have a problem where the user can have a computer with Windows XP, and everything is stylized with windows XP. It’s like the…
-
1
votes1
answer661
viewsHow to change border color and Jframe title in Java?
I would like to know how to change the border and title color of a Java Jframe. I only found information on how to remove the border and title, but how to change the color not. I am currently using…
-
1
votes1
answer294
viewsHow to apply a Jdatechooser two filter to a Jtable?
I need to filter the data simultaneously to be displayed in a JTable. Consulting some old questions I managed to solve part of my problem. I have a DATE field in the String type table and I have two…
-
1
votes1
answer97
viewsCombine Rowfilter.andFilter with Rowfilter.orFilter
I have a project that has a table and items to be filtered. They are a categoryJComboBox, an id JTextField and a date interval JDateCooser. I made all filters separately with RowFilter.andFilter and…
-
1
votes1
answer352
viewsOpen Panel through a Jmenuitem
I need to know how to make one JMenuItem open a JPanel, that is, by clicking on JMenuItem, open the corresponding Jpanel, this in Eclipse, via windowBuilder. This is the image of my screen with the…
-
1
votes1
answer49
viewsWhy doesn’t my button event start in Swing?
import javax.swing.JFrame; import javax.swing.JButton; import javax.swing.JLabel; import java.awt.event.ActionEvent; public class main{ public static void main(String[] args){ JFrame frame = new…
-
1
votes1
answer628
viewsAdd line with empty fields in a Jtable
I have a AbstractTableModel only that I do not know how to add blank lines, when pressing the add line button on my frame I want it to call a method called addLine() of my Modelotabela, someone can…
-
1
votes1
answer156
viewsQuery ORDER BY dynamics from the selection of a combobox
I’m developing an application on java managing a database. This application primarily performs a SELECT the database, then submitting the ResultSet for an editable table. I tried to add a comboBox…
-
1
votes1
answer65
viewsJtables Simultaneos
Hi, I was wondering if there’s a way to select 2 Jtables simultaneously, I’ll explain: i need some columns of my Jtable, do not change when the horizontal Jscrollbar is changed, according to my…
-
1
votes3
answers1071
viewshow to select the entire row of a Jtable using Defaultcellrenderer which changes the color of the line
Hello, I’m working with Jtables and on such a Jtable I needed to leave some lines in differentiated colors, so I implemented the method class cellRenderModel extends DefaultTableCellRenderer { /** *…
-
1
votes1
answer1159
viewsDraw lines in binary tree graphical representation
I’m trying to draw a binary tree using swing and awt in java. I can already show the knots of the tree but I’m not able to draw the lines of a parent knot to your children. I have the Node, Treegui,…
-
1
votes1
answer544
viewsHow to call a class through another class using Jmenuitem?
I have two classes in the same package, one called Calc, which is a simple calculator, whose code is below: public Calc(){ super("Calculadora"); Container tela = getContentPane(); setLayout(null);…
-
1
votes1
answer198
viewsHow to put title in Jdesktoppane?
I am developing software for a video rental company with Pattern MVC (Model-view-controller) design with the Java Persistent Api Framework and XML language. My question is this: How do you put and…
-
1
votes1
answer1315
viewsHow to make a Jframe return an instance of a given object?
I have a JFrame called Jframecadastre person which has only two fields name and surname, as shown in the image : Jframecadastre person: public class JFrameCadastroPessoa extends javax.swing.JFrame {…
-
1
votes1
answer87
viewsFill in a jCombobox using Join and Hibernate
I’m doing a job at college where I’m supposed to create a scheduling system for car dealerships. The technologies used are Java, Swing, and Hibernate. I divided the project in layers to facilitate,…
-
1
votes1
answer1153
viewsFill text field with return from another window
I have a JTextField instantiated in the class time relay. By clicking on that JTextField, he calls another JFrame search. When performing a search on this new JFrame and click on Confirm, I need him…
-
1
votes1
answer631
viewsHow to add an event to the Trayicon notification balloon?
I have an app that uses the class TrayIcon and I’m displaying a message through the method displayMessage(). (A small "balloon" that rises from the icon represented by my Trayicon). The method call…