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
-
3
votes1
answer335
viewsHow do I keep Look And Feel selected in Jcombobox after the window is closed?
I just created a simple JFrame no Neatbeans with some Look And Feel’s(LAF) available, using a JComboBox for the user to choose the LAF you want, and I also put the "Save" button for Action. I can…
-
3
votes1
answer571
viewsHow to change the Jtable header background without removing the edge?
I’m trying to change the color of the background header of JTable. With this code I got: public Principal() throws UnsupportedLookAndFeelException { initComponents();…
-
3
votes1
answer508
viewsBreak java loop
My project in Java is a lighthouse control with Arduino. Up to there everything right. However I made a function in which the leds is automatic in a loop after a RadionButton be selected. My problem…
-
3
votes1
answer1558
viewsDisplay dialog box on screen in the foreground even if window is in the background
I am developing an application where it works with schedules, the user will leave the problem running and will continue using the pc normally and when a certain time will play a sound (already being…
-
3
votes1
answer197
viewsWhy isn’t this method adding up?
I’m trying to put two numbers together by Swing and JOptionPane, but is appearing error below. Someone to help me solve this ? Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException:…
-
3
votes1
answer203
viewsImplement a "result counter"
I have a search/query register screen and when I do the query, for example, from all countries, a label "arrow" how many countries found, (eg 19 countries found). However, if within these results I…
-
3
votes1
answer165
viewsProblems with Rowfilter output
I’m working with Documentlistener and Rowfilter, and I realized that my filter is taking the data that I type, and searching for correspondence in all the columns of my table. I would like to know,…
-
3
votes2
answers213
viewsJpanel width exceeding the dimension defined in getPreferredSize()
I’m trying to create a little game Breakout, I’ve done a lot of logic, only I discovered an uncomfortable problem related to the size of the panel of the "scene" of the game. Follow my class Board,…
-
3
votes1
answer142
viewsLambda expressions in nested classes with multiple methods
I was reading about Ambdas and out of curiosity, I wanted to know why it is not allowed to use when the class/ interface has more than one method, which ends up forcing us to do things like below:…
-
3
votes1
answer541
viewsQuestions with mask in Jformattedtextfield
Working with JFormattedTextField, I had two problems for which I found nothing that helps me to solve. The example in this case would be a JFormattedTextField for CPF. First problem: the mask. When…
-
3
votes1
answer53
viewsHow do I create a showOptionDialog method that the default value is "no"?
I want my system’s confirmation messages to behave with the default value "no". I have achieved this by doing so: private void jButtonActionPerformed(java.awt.event.ActionEvent evt) { Object[]…
-
3
votes1
answer885
viewsHow to display the contents of a . txt file on the screen?
I’m using JFrame to try to display the contents of txt files in a window and then delete the entire file. However, when I put it to display, it erases the file no longer displays on the screen I…
-
3
votes2
answers827
viewsProblem with component position and size
I’m doing a program using the wizard, the famous "click and drag". Most of the project I’m doing on my computer, and I use the command to maximize the screen on the frame, and I adjust the panels so…
-
3
votes1
answer109
viewsUpdate Jeditorpane as a function’s data return - JAVA
Basically, the situation is this, I have a Java application that communicates with an API to update a database. The problem I face is this, I’m doing the process as follows: Application Class…
-
2
votes3
answers12003
viewsToggle Jpanels within a single Jframe
In a Java code, I have a Jframe and within this Jframe I have a contentPane (Jpanel). I have several screens in Jpanel format, I want to exchange these Jpanels by clicking a button that is attached…
-
2
votes2
answers995
viewsProgress bar not updated correctly
Working with progress bar (JProgressBar) I faced a problem in PropertyChangeListener. In fact, not necessarily in PropertyChangeListener, but yes at the time of returning the property being updated.…
-
2
votes2
answers635
viewsJdialog does not design components in Java
I am developing an application that will run a processing soon, and I want a message warning that the process is running stay on the screen while it does this processing. I tried to do with the…
-
2
votes1
answer5391
viewsHow do I handle Joptionpane.showMessageDialog() options?
How do I handle user choices on JOptionPane.showMessageDialog()? For example, when the user chooses okay the program continues normally if he chooses cancel the program executes another line of…
-
2
votes1
answer1087
viewsOpen word file through the . jar
I have a calculator in . jar working perfectly ! My questions are: In the menu I have the "Source code" button and I would like to open a Word document with the source code of the program. I managed…
-
2
votes1
answer551
viewsHow to get the color of a pixel on the screen in JAVA 2D game?
Was there any way How to get the color of a Pixel on the x and y coordinates of the screen I specify?
-
2
votes1
answer349
viewsLayout management issues with Miglayout
I’m having trouble managing the layout of a Jframe that is a test. How are you: How I wish it were: import java.awt.Color; import java.awt.GridLayout; import javax.swing.JFrame; import…
-
2
votes1
answer74
viewsHow to put Outlines in the text
I would like to know how to put black Outlines in the text JLabel label_name = new JLabel(); label_name.setPreferredSize(new Dimension(100,20)); label_name.setForeground(Color.white);…
-
2
votes2
answers505
viewsPassing Different Object Types to a Tablemodel
I’m starting to mess with Jtable but I’m having a doubt. I’m seeing this post here on another forum and my question is. In case it passes to the table template a list of book type: private…
-
2
votes1
answer1794
viewsCapturing events on a button
I’m starting in GUI in Java and wanted to understand how it works to capture events on a button, as for example in the code below: Simplegui1.java import javax.swing.*; import java.awt.event.*;…
-
2
votes1
answer121
viewsSyntax Highlighting with/in the Swing framework
How to make a syntax Highlighting, like what Ides use, but in/with Swing framework, with Java. I intend to use syntax Highlighting in several different keywords. How can I change the color of the…
-
2
votes1
answer121
viewsLook and Feel is not updated on all subcomponents
I am facing a problem with the look and Feel that I found a little strange, when running the project by the IDE all components are rendered according to the skin I selected, but when I use the JAR,…
-
2
votes1
answer783
viewsHow to put an image in Jcombobox?
When the user selects the option, an image appears on the side.
-
2
votes1
answer596
viewsHow to make the Combobox list bigger than Combo itself?
How can I make visible all the contents of the combobox I have without increasing its size? Today she’s like this: I want her to stay that way: Updating Through one comment, I found the solution at…
-
2
votes2
answers1749
viewsDraw a pixel-by-pixel image
I’m trying to make a stupid little program but I’m not getting it. I want to randomly redraw a pixel-by-pixel image, doing this with multiple threads. I don’t know much about Java Swing, so I’m…
-
2
votes2
answers329
viewsHow to know when two Threads ended up in Swing?
I have a method that performs two tasks. I would like two threads perform each task. Tasks do not share data, are completely independent. Before starting the tasks is shown a dialog with the…
-
2
votes1
answer3610
viewsMonetary mask for Jtextfield
I have a field JTextField which must receive a monetary value from the user. I would like to add a mask to this field so that it format the inserted values as follows: 9.999,99.
-
2
votes1
answer642
viewsLabel is not displayed
I created a label where it would contain the status of the process of connection with the database, but it does not appear and I have no idea why this happens, already three days that I look at the…
-
2
votes1
answer692
viewsjFrame frozen/locked when opening in a jTable
The idea is to click on the row of the table that is a jFrame1 and open another jFrame2 with the search of the information of the person based on RE, but when I click on it the code works but opens…
-
2
votes1
answer237
viewsIs there a Java function equivalent to drawPixel?
I wanted to know if there is any function in java that Plot a pixel, something like drawPixel or setPixel that I see in some other programming languages, in which you report as parameters the X and…
-
2
votes1
answer676
viewsHow to maintain the layout of the components created by Windowbuilder in eclipse after compilation?
I created a Jframe using the Eclipse Windowbuilder plugin. Spacing, sizes and patterns have been defined. However while compiling the project the patterns are lost. Below the 2 photos for…
-
2
votes2
answers1169
viewsDoubt - setDefaultCloseOperation
It would be possible to somehow pass to: setDefaultCloseOperation(UM METHODO?); Or using some other option to do the same procedure? What happens is that I created a button and it calls a "method"…
-
2
votes1
answer1459
viewsPlace icon inside jLabel on jTextField
How to change the date insertion mode in my jTextField? Here’s what I got: I want to insert this icon that is in jLabel inside my jTextField. Is this possible? Upgrade: import java.awt.*; import…
-
2
votes2
answers2888
viewsHow to use mouse click and keyboard ENTER?
How to include in my class an event that gives me the possibility to click on JButton and he show a JOptionPane? And in the same way JButton, I press the ENTER and he show me the same JOptionPane?…
-
2
votes1
answer211
viewsControl java application on the outside
I created a java SE application that runs in the background, without swing or anything... But how do I control this application? for example, in python applications we can execute commands (python…
-
2
votes1
answer764
viewsHow to determine the size of a Jlabel?
I’m creating a program, and I’m making his menu. But to make the menu, I need to create a button and I’m creating this button using images with the JLabel and using the MouseListener. However, I…
-
2
votes1
answer435
viewsHow to update a Jtextarea with information from Jcheckboxes?
I am in need of help in the following, I have a window that the user can activate the Jcheckboxes to write in the Jtextarea that is below, as the following image: What I wanted is that when you…
-
2
votes1
answer193
viewsIs there any way to add more than one mask to a Jformattedtextfield?
I have JFormattedTextField for a price attribute'. In it I say that its format is "R$ #####,##". However, as I do not yet know how to add events (I am learning) I would like right away if it is…
-
2
votes1
answer122
viewsWhich method can I use for the edges of Jbutton do not appear?
I think the question already describes it all: Which method can I use so that the edges of my JButton are transparent (not shown) in Java?
-
2
votes2
answers2363
viewsClose all open jframes when opening a new one
How can I close all jframes opened in my project when I run an action that opens another jframe? I have a login system and when necessary, I invoke another frame to define a password. After setting…
-
2
votes1
answer1150
viewsCreate graphical interface using Miglayout
I need to create this graphical interface: The last code I tried was this: (but the settings are not correct) frame.setLayout(new MigLayout("wrap","[grow]","[grow][]")); panelInfo.setLayout(new…
-
2
votes1
answer527
viewsjava.lang.Nullpointerexception in this code
This gives java.lang.Nullpointerexception error in these two classes. import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JTextField; public class…
-
2
votes1
answer62
viewsException in Java Uithreadingviolationexception
I did a project with the LookAndFeel Substance, in it I have a thread which periodically updates a JProgressBar, the problem is that in function JProgressBar.setValue(1) and…
-
2
votes1
answer503
viewsRemove selection color from Jtable’s line?
It may sound silly, but I can’t find the method to remove the color from the selection when the mouse clicks on the line. I have a table with red and blue lines, blue colors are lines that mean an…
-
2
votes1
answer1040
viewsJfreechart - Java Swing charts do not appear on the screen
Hello, I’m developing a Java swing application for a university project. Basically it is a program that reads XML files from another application (mobile game) and generates graphic reports from the…
-
2
votes2
answers801
viewsConfirm form closure
I need to ask if I want to close the window that is open. I made the following form, but in any of the options, it closes. I currently use this event option: private void…