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
answer144
viewsPlace a table created in an existing container
need help! I’m developing an application in college that will use Bubblesort - yes! We had the misfortune to catch this one! - to draw some data within a table. I created the table through a class…
-
1
votes1
answer1244
viewsHow do I change the Look and Feel of an app?
Can anyone explain to me how I change the layout of my application windows? I was building the app and testing by the method main normally, but since it took me a long time to wait to connect to the…
-
1
votes1
answer1845
viewsHow to change the color of a Jmenubar?
Is there any way to change the color of background and foreground from the java menu bar? I searched several forums and tutorials and could not find a way to change the menu bar color. Following…
-
1
votes2
answers166
viewsDoubt in the implementation of Actionlistener
I have a college project to make a system of any category that, in this case, I chose a medical system and had something I didn’t quite understand about what the implementation would be like: I have…
-
1
votes1
answer60
viewsReturn focus to a Jformatedtextfield after clicking button
I need to click on Wipe Button on the Login screen the CPF and Password the cursor goes back to the CPF field. JFormattedTextField ftUsuario = new JFormattedTextField(); try { MaskFormatter…
-
1
votes1
answer141
views -
1
votes1
answer933
viewsHow do I add a background image to a Jframe?
I’m trying to change the background image of my Jframe, but I’m having a hard time. Here’s the code: public class teste_tamagotchi extends JFrame { private JPanel contentPane; /** * Launch the…
-
1
votes0
answers107
viewsRemove file from a Jlist and from the computer
I have a frame, with a list of values where several files are displayed. At this time I am doing the delete button sentry (last part code), where the goal is to delete the file from disk, and jlist.…
-
1
votes2
answers852
viewsHow to Throw the dice of a Jlist into another Jlist that is in another Jframe?
I tried it in various ways, but I couldn’t find a solution. When I click the save button. I want him to throw the dice on that Jlist to the other Jlist that’s in the Other Jframe. "I couldn’t…
-
1
votes1
answer1423
viewsPick object id attribute selected in Jcombobox
I have a table in BD with Columns Id, Board N° and Drilling on board. I’d like to show on JComboBox the concatenation of "Plate N° + Drilling". Example: Plate 10 - 113,00 mm But when a combobox item…
-
1
votes1
answer145
viewsHow to position Jtabbedpane in the lower half of the screen?
I would like to have my canvas divided into at least two parts, at the top I will add some fields, and at the bottom, a JTabbedPane with a few tabs. The problem is that I don’t know how to do this,…
-
1
votes1
answer194
viewsHow to pass more than one parameter in a Paint() method in Java?
I was developing a project where I need to overwrite the Paint() method, but the Paint() method only receives a Graphics object as a parameter. What I need to do is create a Paint method that takes…
-
1
votes1
answer196
viewsHow do I get a line back on my jTable?
I’d like to know how to retrieve information from a line of mine JTable, follows the code line of the same. Usuarios operacao = new Usuarios(); DefaultTableModel tabela = new DefaultTableModel();…
-
1
votes1
answer245
viewsWhat is the difference between using Swingutilities.invokeLater(Runnable) and Eventqueue.invokeLater(Runnable) when calling a window?
I was reading this answer where it talks about the use of EDT to manipulate swing components, but there is suggested to use one of the two methods cited to "dispatch" the interface to the EDT. There…
-
1
votes1
answer2049
viewsHow to display date and time "at runtime"?
I would like to know how to display the current date and time of the computer, and the time should be updated at runtime. I thought of passing an object to a label, but it did not. I’m not going to…
-
1
votes1
answer131
viewsHow to display the time the program is running?
I wanted to know if there is a way to take the time that the program is running, and display on a label. From the moment it runs, it is "running a time", ie shows exactly the time it is running.…
-
1
votes1
answer525
viewsHow to center a component using null layout?
my knob I want to center is 100 pixels wide. Jframe is 350 wide. how to center? /* * To change this license header, choose License Headers in Project Properties. * To change this template file,…
-
1
votes1
answer319
viewsMultiply 2 fields in Jtable
I’m trying to get a 2-field multiplication on Jtable but I can’t do it Specifically the Quantity Field and Unit Value to multiply and give the Total Value Tela do Jtable package Telas; import…
-
1
votes1
answer899
viewsHow to draw lines following the mouse movement?
I need a JPanel, that draws lines following the mouse pointer while it is dragged, and when released it needs to stop drawing. It turns out that whenever two or more lines are drawn in a row, they…
-
1
votes1
answer1508
viewsView an image with Java Swing Jlabel
I’m trying to display an image in an app using Swing Java. I take some frames from a video and display them as an image private void updateView(){ Image tempCurrent =…
-
1
votes1
answer765
viewsHow to resize the application with the monitor?
I have an app that opens a JFrame, having at the top a JMenuBar. Until I call an item from Menubar one JTabbedPane, is hidden and as soon as a menu item is chosen, a Tabbed with jPanel inside opens.…
-
1
votes1
answer315
viewsHow to capture colors from an image on a Jlabel that behind another Jlabel?
I need to get the pixel colors of an image inserted in a JLabel with MouseMotionListener, and this Jlabel is under or behind another Jlabel. I know it is possible to get a background color behind a…
-
1
votes1
answer122
viewsHow to capture the colors of a label that is behind another label?
I have two Jlabels superimposed on each other. JLabel label = new JLabel(); label.setBounds(15, 15, 300, 300); label.setOpaque(true); label.setBackground(Color.red); JLabel label1 = new JLabel();…
-
1
votes1
answer94
viewsHow to do tabbedPane concealable?
I’m having trouble trying to make a tab (tabbedPane) that is displayed according to the status of a Checkbox ("selected/unchecked"). I do not know if it is possible, since it will end up changing…
-
1
votes1
answer667
viewsValidate Jdatechooser
I am having trouble determining if the user has filled in a date field of type JDateChooser, would like to do a validation, to know if this empty or not. I tried to do by looking at the…
-
1
votes1
answer135
viewsProblem inserting Jtextfield inside Jpanel inside Jtabbedpane
I have a Swing app where the main window consists of a JtabbedPane which contains some extended classes JPanel [Viewprincipal, Viewcadastro, Viewrelatorio, etc...]. When I add Jlabels and Jbuttons,…
-
1
votes2
answers313
viewsButton locked in while
My program has a loop, created with the command while. I start the loop with the start button. However, I can’t do anything else in the program while the while is spinning. I wanted to put a button…
-
1
votes1
answer1239
viewsHow to change the color of a Jtable’s lines?
I need the line color to change whenever the cell value is 0. However, all lines are being painted. View with a simple Jtable import javax.swing.JTable; public class View extends javax.swing.JFrame…
-
1
votes1
answer365
viewsRender table cell image size
I created a java table that shows my images stored in blob in the database. However the height of the table is not automatically resized having to put a value manually, for example:…
-
1
votes0
answers30
viewsView Jframe image
When trying to display an image in JFrame, it is always displayed with height size, a few pixels less. How do I solve? public class Janela extends JFrame { private JPanel painel; private…
-
1
votes0
answers196
viewsJava swing - exercise
I’m having doubts about Container, I’d like to know if the form I’ve made is correct. public class Exercicio2 { public static void main(String[] args) { JLabel lblTitulo = new JLabel(); JLabel…
-
1
votes1
answer487
viewsInsert a submenu into a Jmenu
When I click on the woman or man icon on JFrame, is called a JPanel where I enter the data such as weight and height. But by clicking save, I cannot call another JPanel to show the result of the…
-
1
votes3
answers1055
viewsJava error - Square root calculation
I was doing some basic exercises in Java and one of them asked: In this example, we will use the method sqrt class Math to extract the square root of the number that is typed in a text box, a 'Text…
-
1
votes1
answer136
viewsCapture action of certain buttons in a Jframe
I created a JFrame that by clicking the keyboard buttons: up, down, left and right, there should be a certain action (a Joption in the case). That’s why I’m wearing one KeyListener, but…
-
1
votes1
answer287
viewsItem in selected combobox, display data in jTable
Before asking this question, I searched the forum and in several places but could not solve... I have a combobox that already carries the names of customers, then I wanted to select the customer,…
-
1
votes1
answer118
viewsControl event in the field?
I’m trying to treat a possible empty search when the user gives enter in a field without typing anything. I applied a keyboard event, and every time you press enter, the field performs a search. The…
-
1
votes1
answer223
viewsHow to remove listeners according to component status?
I have a Jlabel that receives an event, and would like to disable that event when the component is disabled (setEnable = false), and only activate it again when the component is enabled. what I did:…
-
1
votes1
answer83
viewsControl animation speed using the Jslider component
Good guys, I’m developing a little project that aims to simulate the controlled environment of train tracks, where I have 3 trains circulating in a clockwise direction, where the three pass by the…
-
1
votes1
answer303
viewsLike putting a Jscrollpane in a Jtextarea?
I’m trying to create a project where I print several sentences in one JTextArea, but for that, I need to include a JScrollPane. I looked at some examples on the internet but none is working. public…
-
1
votes1
answer86
viewsJtextpane Word Wrapper
I’m not finding a way to organize the lines within a Jtextpane, and I need to continue with styling but also with a Word Wrapper, there is some method or some component that does similar? public…
-
1
votes1
answer51
viewsJslider does not appear in Jpanel after inserting
I was trying to add a JSlider in a JPanel but he doesn’t show up. Could you tell me where I’m going wrong? import java.awt.Dimension; import javax.swing.BorderFactory; import javax.swing.JFrame;…
-
1
votes1
answer236
viewsCreating Row filter "dynamic"
I’m using RowFilter to create filters for certain columns in my table. My intention is to pass the components that I want to use as "bar" search by Paramento, creating them dynamically, and likewise…
-
1
votes1
answer465
viewsPosition Jpanels vertically
I am trying to add 4 panels, so that they are below each other. So, I decided to use the BorderLayout, together with the "positioning" (NORTH, SOUTH etc.), pass a index, however, he ends up skipping…
-
1
votes1
answer139
viewsHow to use a Jcombobox of one class in another?
I want to create two screens, one registers the values of Jcombobox and the other I use the values. I can get the Combobox back but there’s no value. Class of register public class Combo extends…
-
1
votes1
answer415
viewsHow to hide and block the last line of a Jtable?
It is possible to hide and lock the last line of a DefaulTableModel? I have this difficulty and I am not able to solve it. If it is not at least possible to hide this line? import…
-
1
votes1
answer276
viewsHow to put icon in tooltip?
I’m trying to print a text on a tooltip, and at the end, put an icon, however I’m not getting it, I tried to do with html. The problem is that the image comes "broken", does not appear. What would…
-
1
votes0
answers113
viewsMake "Enter" trigger an action
I have a login screen to a system and I want that when the user has a selected button, when pressing "Enter" on the keyboard, the button triggers its action. Ex.: if the confirm button is selected…
-
1
votes1
answer79
viewsHow to use the Balloontip library?
I would like to use tooltips as in the library balloontip, but I haven’t found a way to use it, it seems to be different from toolTips conventional methods that use the method to be applied…
-
1
votes1
answer41
viewsButtons are not displayed correctly
I am trying to add 2 Jbuttons to a program, I do all the process to add, but shows only one. package ldegraphic; import java.awt.Graphics; import javax.swing.*; public class LDEGraphic extends…
-
1
votes1
answer229
viewsPosition components vertically with Gridbaglayout
I created code in java to position objects in the type window JComboBox and JTextField and I want them to be below each other. The code I tried is this: /*Biblioteca */ import java.awt.*; import…