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
-
4
votes1
answer1320
viewsHow to change the color of the border?
How I could change the color of the border created by Borderfactory? import java.awt.Dimension; import java.awt.GridBagLayout; import javax.swing.BorderFactory; import javax.swing.JComponent; import…
-
4
votes1
answer51
viewsHow to set content at position 0 with field disabled?
I need that when my component receives a text (it will receive through a query), the text is "set" at the beginning of the field, because in many cases, the text is extended and the beginning is…
-
4
votes1
answer1031
viewsHow to maintain the screen ratio after being resized by the user?
I need to restrict a certain proportion of a Jframe so that the layout of what I want to display on it isn’t distorted, but I wouldn’t want to have to block resizing with setRezisable(). The minimum…
-
4
votes1
answer590
viewsHow to create a mask for Jformattedtextfield?
I am making a program that simulates the Turing machine, and the user fills in a form with the states in this way {q0,q1,q2}. But I want to create mask that the user type only q0q1q2 and the value…
-
4
votes1
answer361
viewsChange button color at runtime
I asked for help on how to paint a button with 3 different colors: You can put 3 colors on a button? But I’m trying to change his color at runtime and I can’t. Even instantiating a new and…
-
4
votes1
answer426
viewsHow to make more than one panel transparent?
Implementing the answer of this issue, i managed to make a panel transparent. However, in order to organize the way I want, I wanted to use more JPanels, with different layout managers. But when I…
-
3
votes1
answer2686
viewsPositioning of components using Gridbaglayout
I’m making a panel and I want to have the following layout: The width of the panel takes up the entire width of the frame, and I want to have 4 buttons in the right corner of that panel. I created a…
-
3
votes3
answers3039
viewsHow to make a decision structure to close a window?
In the code below, I want you to choose sim the window closes and when choosing não the window remains open. private void formWindowClosing(java.awt.event.WindowEvent evt) { // TODO add your…
-
3
votes1
answer1357
viewsDynamic graphical user interface in Java
I need to create something like this: I usually do the GUI’s with the help of the IDE but in this case I can’t(I think), because I need the GUI to repeat an undefined number of times, depending on…
-
3
votes1
answer9074
viewsHow to select only one radio button?
In the swing of Java, a user can select more than one radio button simultaneously, so this does not happen, one can do: private void radio1ActionPerformed(java.awt.event.ActionEvent evt) { if…
-
3
votes1
answer113
viewsJdialog does not show Jlabel
I created a class called Jdialogprogress, but when I "call it" the Jlabel object does not show on the screen. I’m calling it that: JDialogProgress Progress = new JDialogProgress(new JFrame(),…
-
3
votes1
answer727
viewsCreate data validation and page sequencing
I’m starting in Java and I want to make a screen where the person register the login and password, the system stores the data and then, in a new window is asked to enter the user and password, I did…
-
3
votes1
answer244
viewsMatrix in Forms
I’m having trouble creating a matrix within a JPanel in Netbeans, I tried to customize the code by placing within the Netbeans customization code: jPanel1.setLayout(new GridLayout(15,15));…
-
3
votes2
answers1867
viewsHow to pass an array to a Jtexfield?
I’m doing a college paper where we have to do a kind of screen login, however, with array and not Arraylist. My question is how I pass on the information from JTexfield to the array? That one array…
-
3
votes1
answer250
viewsMulti-processing/Multithread not working
I want to try to solve the problem of when the client cannot connect to the server(connection failure, server below, etc). In my main class is the connection to the server and I want in case of…
-
3
votes1
answer612
viewsHow to put a Jlabel above the buttons on a Jdialog?
I’d like to put a label on a Jdialog, but above the existing buttons. How can I do that? All components stay online for me: private void…
-
3
votes1
answer1530
views"Transparent" text in java
I wanted to do a text similar to this: This "transparent" text, when clicked it disappears and you can start writing in the dialog box... someone knows how to do it in Java? Help me, people, help…
-
3
votes1
answer1395
viewsHow to make a button blink?
I created a simple code for a game similar to Genius, where a random button of a set of 20 buttons starts to blink, but I can’t get an interval for the color change to be visible... Here’s an…
-
3
votes1
answer225
viewsCreate document templates in Java
I am creating a Java system with Swing, where I would have templates of documents, and fill with data informed by the user in a form that I have already created, so that it generates a PDF of the…
-
3
votes1
answer677
viewsHow to set background color on multiple lines of a Jtable?
I would like to know how to set the background color of multiple rows of the table. In the code below it simply arrow the background in only one line, that is, in the last element of the vector. The…
-
3
votes1
answer356
viewsMinimizar + Sytemtray
People are wanting that when clicking to minimize the program, its icon is next to the clock. I created a button that does this action. I confess that I didn’t do it, but the author helped me a lot.…
-
3
votes2
answers1346
viewsCenter Swing Window
I wanted to know how to call a Secondary Window in Swing and leave it centered with the Main Window of the program. At the moment, when I call him appears in the upper left corner.
-
3
votes3
answers1552
viewsHow to set index when inserting item in Jcombobox?
I wonder if someone could help me. I’m trying to add items to a JComboBox: Pessoa carlos = new Pessoa(12, "Carlos" , 0.0f); jComboBoxF.addItem(carlos.getNome()); Pessoa maria = new Pessoa(23,…
-
3
votes2
answers797
viewsImplementation of Jmenubar in a Jframe
I’m having trouble trying to insert a component JMenuBar to my main frame. I don’t get any kind of problem when executing the code, but the options bar is not displayed in the program. What is…
-
3
votes0
answers109
viewsClassifying with colored cells and Date column
I have two problems to finalize my table: 1) I have one TableCellRenderer customized to paint an entire row based on the value of a column. It works, but when I click to sort, the colors of the…
-
3
votes1
answer770
viewsHow to change the appearance and behavior of the "Open" and "Cancel" Jfilechooser buttons?
Good people, I’m trying to use Jfilechooser to select directories and also files. What I’m using so far is public void buscaFile() { File[] diretorio = null; diretorio = selectDir(); if(diretorio !=…
-
3
votes2
answers136
viewsRelease only the last line for writing
How do I allow the user to write only in the last line of a JTextArea, that is, without being able to make modifications on the upper lines? (as in CMD or Terminal, for example).
-
3
votes1
answer1450
viewsStopwatch - Timer
I made a chronometer (better to say: a timer) that should be executed when a certain button is clicked. I managed to make the timer, but I can’t close it. After calling it he is timing "forever" rs.…
-
3
votes1
answer610
viewshow to style the selected text Jtextpane?
what I want is to take the selected text from Jtextpane and edit it, for example: change the font color, size and family. The problem is that after I change the selected text once, it doesn’t change…
-
3
votes1
answer1122
viewsHow to center the title of a Jframe?
I have a jFrame component and I want to center his title, would it be possible?…
-
3
votes2
answers796
viewsUpdate Combobox receiving a list from another panel
I have a screen where I register a film, and I play for a ArrayList with a Movie class, which contains some attributes such as title, year, nothing else so far. So I want in my other screen where I…
-
3
votes1
answer192
viewsHow to use setNextFocusableComponent in a Jtextarea
I used setNextFocusableComponent in a JTextArea, but it doesn’t work because the TAB works as a "space" inside the JTextArea, how to solve this ??
-
3
votes1
answer3069
viewsWhat is the advantage of using Bufferedimage for images?
I want to know the difference in using BufferedImage and the method graphics to draw the images to the ImageIcon. Here is an example: @Override public void paint(Graphics g) { g.drawImage(bfImage,…
-
3
votes1
answer314
viewsBy icon in Jframe
It would be possible to icons in the application executable through code?
-
3
votes1
answer1699
viewsUpdate a Jtable within a Jframe through another Jframe
I own a JFrame, where inside it has a JTable and a JButton (Change) that makes the call from another Jframe. In this other Jframe, a data change is made according to the row selected in the table…
-
3
votes1
answer162
viewsThread of a "flashing" dot
Hello, I made a program that moves a ball with the arrow keys on the keyboard only that keeps blinking the screen when it moves. I’ve seen other programs in this kind of mine that don’t keep…
-
3
votes1
answer403
viewsHow to make a grid with squares?
I would like to do something like this one, a grid based on an array (and that based on the value of the matrix, set a color to the corresponding cell), and I can manipulate it with the mouse.…
-
3
votes1
answer2066
viewsHow to format field for RG with issuing organ?
I have the following java class: public class TesteRG { public static void main(String[] args) { String RG = "24.77.195 ssp/pb"; Pattern pattern =…
-
3
votes1
answer743
viewsProblems with swing calculator operations
I need to make a calculator that works like the windows. I’m having trouble at the moment the user can change the type of operation he wants to perform. For example, if he typed 10+ and wants to…
-
3
votes1
answer498
viewsPass the execution of a particular method to Swingworker as argument
I have a small application on swing, where I would like to display progress when certain actions are executed As an example, I have the listener below that is run when a JComboBox is changed. It…
-
3
votes1
answer217
viewsHow to remove Hover from menu items and buttons?
I think my question is very objective: how to remove the "Hover effect of menu items and buttons? Here is a screenshot of the Hover effect I intend to remove (button and menu items):…
-
3
votes2
answers2074
viewsAdd line in Jtable at the click of the button
I’m starting in creating interface in Java, an example I’m trying to do is to have a form with textField nome and email, and by clicking on the Enviar the data of those textField goes to my JTable,…
-
3
votes2
answers707
viewsReturns database data in a Jtextfield
I have a question regarding listing the data I recorded in a database for a JTextField. I created a screen, with the field for the user to enter the registration ID in the database and a FILTER…
-
3
votes1
answer178
viewsIllegalityxception when reopening jInternalFrame several times
I am with an application that is validating when the window JInternalFrame is open or closed, but if the window is opened and closed a few times in a row, the console shows an error and does not…
-
3
votes1
answer125
viewsActionlistener does not identify the recovered button
My goal is to click the button Andar and then select on the board which direction the character will be moved to, as shown in the image: My button Andar has a ActionListener and is treated as…
-
3
votes1
answer545
viewsChange Jtextfield value from another class or automatically
I found some similar issues in the English version, but I could not resolve. I have a boiler class, with the following attributes: Boiler temperature; how much; Fire temperature; In this program I…
-
3
votes1
answer421
viewsHow do I access the contents of a Jtextfield?
In a java project no connection to Database where we have only the layers Model, View and Controller, what would be the most appropriate way to catch a String which is contained in a JTextField of a…
-
3
votes1
answer1765
viewsHow to change the text color of a column of a Jtable
I have a form for payment of installments, and this form has a table where I show both the installments paid and those that should still be paid. To popular this JTable, I make a query in the…
-
3
votes1
answer3486
viewsUse the same jFormattedTextField for CPF and CNPJ mask
I wonder if it’s possible in one JFormattedTextField, toggle mask for CPF and CNPJ. When I wear the mask of JFormattedTextField the value is already static, and if put to the CPF, It will not fit…
-
3
votes4
answers1482
viewsHow to change the color of the text in a Jtextpane?
I’m developing a chat and he uses a JTextPane to display messages in different colors for each user. However, I don’t know how to change the colors of the text of this component. Example: We have…