Questions tagged as 'swing'

1
answer

How to remove add / remove panel according to checkbox selection?

I'm adding a panel at the bottom of a JFrame , when a checkbox is selected, and when I unmark it, remove the panel, and leave only the checkbox, however, I'm not getting it, I think the manager layout is preventing the effect I want...
asked by 24.06.2018 / 21:05
1
answer

How to draw lines following the mouse movement?

I need a JPanel , which draws lines following the mouse pointer while it is dragged, and when released it needs to stop drawing. It turns out that whenever you draw two or more rows in a row, they connect to the previous rows, this shou...
asked by 13.03.2017 / 15:55
1
answer

How to display the time the program is running?

I wanted to know if there is a way to take the time the program is running, and display it on a label. From the moment it is run, it is "running a time", ie it shows exactly how long it is running. public class ProgramaExemplo extends JFrame {...
asked by 04.02.2017 / 20:03
2
answers

Put a name depending on the number of the array

Let's say I have 4 variables: - Porto = 1 - Benfica = 2 - Sporting = 3 - Braga = 4 I have this code that makes me a shuffle of numbers in an array called "arr". Integer[] arr = {1,2,3,4}; Collections.shuffle(Arrays.asList...
asked by 16.03.2018 / 18:49
1
answer

Show text in JFrame

I would like to know how I can put text in my Java class, but this text would have the contents of a record in my database. I've done more or less this using JLabel but it creates one-line labels and would like to create multi-line runnin...
asked by 13.11.2016 / 22:38
2
answers

How to hide title of JTabbedPane tabs?

I need to hide the JTabbedPane titles because I'm creating my own buttons to access the tabs.     
asked by 15.07.2015 / 14:04
1
answer

Pick up the selected item in Jcombobox

How do I get the item selected by the user in this Combobox? opcaoBusca.setModel(new DefaultComboBoxModel(new String[] {"Op\u00E7\u00E3o da Busca", "N\u00FAmero do Pedido"})); entBusca = new JFormattedTextField(); entBusca.add...
asked by 08.01.2015 / 11:33
1
answer

How to use scroll keys, such as up, down, on the keyboard to navigate a list of buttons?

I have these buttons implemented with a click of the mouse, but I wanted the following: I could navigate through the direction keys up and down and enter through enter . Does anyone know how to implement it? They are the buttons: btStart,...
asked by 11.01.2018 / 04:23
1
answer

How to put icon in tooltip?

I'm trying to print a text in a tooltip, and in the end, put an icon, however I'm not getting it, I tried doing with html. The problem is that the image comes "broken", does not appear. Whatwouldbetherightwaytodothis?importjava.awt.Dimens...
asked by 11.10.2017 / 00:39
1
answer

Doubt regarding sizing methods in a Frame

What is the difference between the setSize() method and the setPrefferedSize() method in a Frame, and in which situation should each be used?     
asked by 12.03.2018 / 16:50