Questions tagged as 'swing'

2
answers

How to close a JFrame using keyboard events?

I have a JFrame that I want to close when I press the Esc key ... Well, I did this: public Cadastro() { addKeyListener(this); And then this: public void keyTyped(KeyEvent evt) { if(evt.getKeyCode() == KeyEvent.VK_ESCAPE){...
asked by 26.03.2015 / 21:08
2
answers

How do I run a video within JFrame?

I want to open a screen and it contains a type of player to run the video that is attached to the project!     
asked by 01.12.2014 / 03:38
1
answer

Enter Password to continue

Note: I do not speak Portuguese. This text was translated before it was posted and the translation was reviewed by other users. I'm using Netbeans 8.0.1. For days I've been looking for a solution to this. I've already tried JDialog...
asked by 30.11.2014 / 03:02
1
answer

How to "limit" a JComboBox according to the selected item?

I have a JComboBox , and I limit the size of it, with the following code: jcb.setPreferredSize(new Dimension(100, 21)); But I wonder if there is a way that, after I choose an option, the content is completely displayed. What happens i...
asked by 30.10.2016 / 00:19
2
answers

Trigger button per shortcut key in Java

I have a java application created by NetBean IDE 8.0. In this application I created a JFrame and put a JButton, which when pressed displays a message. private void btnExibirActionPerformed(java.awt.event.ActionEvent evt) { System.out.printl...
asked by 11.04.2014 / 01:27
2
answers

How to get all the paths of a JTree?

How can I get all the paths of a JTree including the nodes that have parents other than root? root exemplo1 exemplo1.1 exemplo2 exemplo2.1 If I do something like this: for(int i = 0; i< tree.getRowCount(); i++){...
asked by 18.12.2014 / 14:52
1
answer

Methods that require return even though Void in the "signature"

I'm doing some tests to understand in practice how the class works SwingWorker in% of%, and I noticed that the swing method requires doInBackground return, even starting the variable of the form below: SwingWorker<Voi...
asked by 21.03.2016 / 16:34
1
answer

Passing optional arguments in Java

I'm trying to learn how the class works SwingWorker<T,V> , I have already done another question regarding one of his methods. Looking at the source code of this class, I found the publish() method written as follows:...
asked by 22.03.2016 / 23:17
2
answers

How do I rotate an arrow within 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 have the arrow turn inside the circle so that the center of the circle is the fixed reference point...
asked by 10.10.2017 / 13:39
1
answer

Click event in a TextField conflicts as JOptionPane

I am learning how to create a sales system and I created this method to get information from a TextField and play within a table via the click of the enter button. I created a try-catch to handle exceptions, and if I enter the catch, it opens a...
asked by 17.05.2018 / 20:16