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
-
5
votes2
answers1293
viewsHow to create Jbutton in "square" format?
It is possible to create JButton in a "square" format, without the rounded corners when they are already in the JFrame? Does anyone have an example? I don’t use any specific laf, but the netbeans…
-
5
votes1
answer2234
viewsTo limit and display the number of characters in a Jtextarea
I have a supplier registration window, and I’d like to insert a jTextArea so that the user has the option to enter some observation about the supplier. The idea is that, limit the amount of…
-
5
votes1
answer851
viewsJtable getValueAt() behaving differently than expected
I have a Jframe where there’s a Jtable that displays some data. When the user selects some records and clicks on a certain button, those selected records should be deleted. When only one record is…
-
5
votes1
answer186
viewsMethods that require return even having Void in "signature"
I am doing some tests to understand in practice the functioning of the classSwingWorker in the swing, and I noticed that the method doInBackground demands a return null, even starting the form…
-
5
votes1
answer587
viewsConvert String from Jtextfield to Calendar
How to perform input conversion via Swing’s Jtextfield via JDBC ? public class DadosPessoais { private Calendar dataNascimento; public Calendar getDataNascimento() { return dataNascimento; } public…
-
5
votes1
answer1677
viewsJdesktoppane background without losing quality and expandable
I have code to add a background image to a JDesktopPaneand it works perfectly on widescreen 16:10 screens. However, when the screen is a little wider (16:9), it does not fill the rest of the…
-
5
votes1
answer232
viewsTextfield click event conflicts like Joptionpane
I am learning how to create a sales system and created this method to take information from a Textfield and play within a table by clicking the enter button. I created a Try-catch to handle…
-
5
votes1
answer42
viewsIn Java Swing, should I extend Jpanel and top-level containers like Jframe?
Has in the Soen but I was not satisfied with the answers, and temporarily I am not able to ask IF.. Top-level containers like the JFrame I guess there’s no need, but a JPanel kind of made to be an…
-
4
votes2
answers1204
viewsFixed column of a Jtable in a Jscrollpane
How do I leave a fixed Jtable column (no scroll) inside a Jscrollpane? I want to leave the first column of a fixed table, the scroll bar will only scroll from the second column onwards, the first…
-
4
votes1
answer3825
viewsHow to color specific lines of a Jtable?
I’m developing a Java application that involves a JTable, i need to paint some red lines depending on the age and status of that line. I’m wearing a DefaultTableModel to popular my table. I don’t…
-
4
votes1
answer2089
viewsEdge effect of a Jbutton component
How do I create a smooth transition(Fade Effect) from the edge of a Jbutton by hovering the mouse? My code is like this: @Override public void mouseEntered(MouseEvent e) { Object temp =…
-
4
votes2
answers7146
viewsHow to make buttons of various formats in java?
I am creating a little game using Swing, and would like to make buttons with different formats, the way I choose. For example: a round button, or an eye-shaped button, for example. And if you know,…
-
4
votes1
answer588
viewsJtable, add multi-lines[Cell span] +Format table
I need to do something like this: Right now I have a table like image 1, but I wanted to create a table like image 2. How can I create something like this? Any ideas? The closest example I saw was:…
-
4
votes1
answer641
views -
4
votes1
answer292
viewsJtable does not save information when focusing on the cell
My JTable does not save information when there is focus on the cell. To effectively save the information I need to focus manually and then click on the "Register". How can I make this process…
-
4
votes2
answers472
viewsHow to expand the window by clicking a button?
Is it possible to expand a window with more information when the user clicks a "Details" button? The behavior is similar to that of some error screens, which show the data of an error, as shown in…
-
4
votes1
answer1778
viewsChange text and background color Tooltip
How do I change the background and text color of a Tooltip? I already did a search and found here a chunk of code but I can’t change it. Colors always stay the default Netbeans. Any suggestions? I…
-
4
votes1
answer2475
viewsHow to popular a Jtable using a . txt file?
I wonder how do I make to popular one JTable using a pre-existing text file. I have a query table and I want the user when placing the account number, it shows the data on Jtable and also how I can…
-
4
votes1
answer125
viewsHow to implement the 'auto complete' feature in a Jformattedtextfield?
I need that when I type in JFormattedTextField pop up text suggestions. It would be possible to do this?
-
4
votes1
answer617
viewsHow to set a char in a Preparedstatement?
My typical variable is a char how to set this in Preparedstatement ? PreparedStatement ps = conexao.prepareStatement(sql); ps.setString(1, veiculo.getTipoCombustivel());…
-
4
votes1
answer2506
viewsInsert data into a table from a Java form (Netbeans+SQL Server)
I have a form created so that I can enter data about a client and from this form open a table with a button that has the data, so far I have been able to link the buttons. Now my question is how I…
-
4
votes1
answer566
viewsHow to create a circle of progress?
I’m looking to make progress in a circle like this: In Java, I could only find something about JProgressBar.…
-
4
votes1
answer114
viewsError in logical TV control - Java
I’m a beginner in java and I’m having a hard time making the button btnVolumeUp raise the counter. First I have this TV class where I created the methods. public class Televisor { int canal = 0; int…
-
4
votes1
answer645
viewsTemporary text in Jlabel
I would like to exchange the text of a JLabel and leave it for just a few seconds, then go back to the previous text. I have to execute a method that takes a few seconds to get ready and would like…
-
4
votes1
answer279
viewsHow to open Jinternalframe window after login?
I am new in java for desktop and am making a program with swing, and would like to know how to make a JInternalFrame open after login is done, follow the code for analysis.…
-
4
votes1
answer243
viewsProblems with changing Jpanel inside Jdialog using Swing
I’m having a problem with a system I’m developing regarding screen swapping. Sorry for the extensive post, but I could not explain the problem otherwise. He owns a JFrame main with a menu that are…
-
4
votes1
answer1653
viewsI can’t leave Jbutton on Jlabel
I have a JPanel, and within it a JLabel of the same size. The JLabel has an icon associated with it, working like a wallpaper. When I try to put a Jbutton on top of Jlabel, Netbeans repositions the…
-
4
votes1
answer1033
viewsslow remote Mysql database with java swing application
I have a swing java application that is connected to a remote Mysql database, that is, on an online server. When running the program it works normal, except for the slow response of the bank. For…
-
4
votes2
answers661
viewsReturn jtable line information after selection
I have an application with 2 Jframes.. 1st Jframe: A screen with a search button and Jtextfield 2nd Jframe: A Jtable with BD information. When I click the search button in the 1st Frame opens the…
-
4
votes1
answer482
viewsChange text of a Jtextarea at runtime
Good morning to all, I have a backup routine that should write the result in a JTextArea, at runtime. The copy works, the problem is that the window containing the JTextArea gets stuck and does not…
-
4
votes1
answer181
viewsDelay of the swing timer.
I’m making a little game that flashes some images in order on the frame, my goal is that they blink in order, but they’re all flashing together: public class Logica { List<Integer> seqAlea =…
-
4
votes1
answer1310
viewsHow to align the column title of a Jtable?
I have a table (Abstract table model) and would like to center column titles. I tried the following: DefaultTableCellRenderer centralizado = new DefaultTableCellRenderer();…
-
4
votes1
answer187
viewsRename an element in a Jlist
Greetings, my friends. I have a problem in Java. I am trying to add a "Occurrence" element to a Jlist. This element has 4 elements within it, which I need to maintain. So far so good. However, the…
-
4
votes2
answers438
viewsList years in Jcombobox dynamically from certain rule
I have an application that lists records in a JTable, and each record has a registration date using Date. On this list, I put one filter per year via JCombobox, where the initial year is what the…
-
4
votes2
answers1662
viewsApply filters to a Jtable
I have a table and in a JPANEL on top of it I created textFields and combobox with the intention of using them as filter. The method: tableRowSorter.setRowFilter(RowFilter.regexFilter("(?i)" +…
-
4
votes1
answer114
viewsHow to prevent a certain key from being sent to the program several times
I’m making a calculator for year-end activity, which even works normally, as long as it doesn’t exceed typing. For example, if you sum two fractional numbers, it performs the entire sum correctly,…
-
4
votes1
answer1129
viewsHow to add values in Jtextfield via the button without deleting the previous value?
My problem is that I put a button so that when it was clicked, add the value 1 in JTextField. However, when I click again, it replaces the value, and what I wanted is for it to add another 1 like, I…
-
4
votes1
answer1484
viewsUpdate a Jtable that is in a Jframe from a Jdialog
What I’m doing is a little longer, so I’m going to shorten the problem with a more objective example: I have a registration form and created a modal Jdialog with the fields I want to search. When I…
-
4
votes1
answer253
viewsDoes the Netbeans Builder GUI Code affect application performance?
Netbeans has a user interface creation tool using the swing, which greatly facilitates the development of desktop applications, however, the tool seems to create numerous lines of code even for…
-
4
votes1
answer368
viewsDifference between methods to close Jframe and Jdialog after keyboard event
I need to implement in a desktop application built using swing, a way for the JFrame main close the application when user click on ESC, and the JDialogs daughters of this JFrame, close only…
-
4
votes2
answers622
viewsHow to rotate an arrow inside a circle using Java2d?
Previously, I asked "How to draw an arrow using Java2d?" and now with the arrow drawn correctly and positioned within my circle, I would like to make the arrow rotate within the circle so that the…
-
4
votes2
answers351
viewsJoptionpane in the foreground
I have an app that uses one JOptionPane to show an error message, however I would like the JOptionPane always appeared in the foreground. JOptionPane.showMessageDialog(null, "Usuário ou senha…
-
4
votes1
answer149
viewsCustomers do not communicate in the same multiplayer game in Java
I’m trying to make a simple tank multiplayer game by implementing chat. The game and the chat are all ok! However, I can’t get 2 customers to view the same object Arena. In this case, each customer…
-
4
votes1
answer305
viewsRowfilter.regexFilter does not filter Date type columns in Jtable
I have a JTable with a TableModel customized, and I’m trying to run a search field using JTextField. However, columns of the type Date and my class Cadastrante are not researched. In my TableModel,…
-
4
votes1
answer774
viewsHow to create a method in a Jbuttons Array that changes the color of jButton with Actionperformed?
I am doing a project that requires the creation of a pencil tool that will paint a group of jButtons positioned in gridLayout (10x10) as if they were pixels. I created a method called 'colorButton'…
-
4
votes1
answer1116
viewsChange title bar and window icon
I want to change the title bar icon of the Java window, as shown below: I’m going the method initComponents() and leaving as it is in the code below, but the line setIconImage(iconeTitulo); is left…
-
4
votes1
answer669
viewsDecorating a Jtextfield with an icone
My question is whether it is possible to "decorate" a field, like Jtextfield or Jformattedtextfield, with an icon. An example would be something like this: Following an example, I made the following…
-
4
votes1
answer258
viewsAssign a function to Jcombobox
I am with the following doubt, I have a combobox, and I want that when you click on one of the combo options, it does something. I wanted to know how I put a variable or method "linked" to combo…
-
4
votes1
answer560
viewsFlashing buttons with Thread
I’m having a problem trying to make the buttons blink. Using the Thread.sleep(), by clicking the button, Thread.sleep() ignores what comes before it, executes the sleep and performs only what comes…
-
4
votes1
answer437
viewsWhy does the Jframe size exceed the size of your Contentpane, even though it has a defined size?
I noticed a strange behavior between containers in the swing. To illustrate the test, I created a JFrame and a JPanel, and defined the panel as contentPane of JFrame. Set the preferred and maximum…