Questions tagged [jbutton]

A JButton is a common button in Java Swing.

A JButton is a common button in Java Swing that allows users to execute actions and events which have been tied to that button. It is designed to be used with ActionListener and Action classes for interacting with a gui.

Relevant Java Tutorials:

4918 questions
1
vote
1 answer

Multiple Buttons?

I'm having trouble getting mutliple buttons to work in Java. Right now I have 2 buttons that should both be doing something. The "Fill" button should fill the top 3 fields "Title" "Director" and "Year" with the what I have set in the "Fill" method…
Slabach
  • 391
  • 1
  • 4
  • 9
1
vote
4 answers

JButton color won't change

I'm making a reaction time game where a button will turn green and you have to hit it as fast as possible, but the button will not change colors. Can someone tell me why this is happening? Also, how could I get my program to wait until a random time…
user4258987
1
vote
2 answers

Using JInternalFrame and some button

Can we use a JInternalFame with a button in the main frame? The frame contains a JDesktopPane, of course. The button should open up the JInternalFrame How?
Eddinho
  • 1,279
  • 5
  • 19
  • 29
1
vote
0 answers

Date of Birth selector error in Java

For the last few weeks I have been spending some time on a date of birth picker for a small Java project. I have got everything working but there seems to be one error. When I choose some dates and then switch the JComboBoxes desynchronize and won't…
user4285058
1
vote
1 answer

change JLabel of a panel depending on Jbutton of another panel in the same Jframe

I have constructed a class for the JPanel with several JButtons.Inside this class I want to construct another JPanel with JLabels that will change depending on the actionPerformed on the JButtons of the first JPanel.Finally, I want to add these 2…
1
vote
1 answer

Batch Repainting Swing Components using FormLayout

I'm making a touch screen keyboard. I want the alphabetic keys to change text when I press shift (from lower case to upper case). Here's a snippet of my current implementation: public void updatedButtons() { switch( m_state ) { …
Ironcache
  • 1,719
  • 21
  • 33
1
vote
1 answer

Java Jbutton KeyListener

I have a 3x3 grid of jbuttons labeled 1-9 representing the number pad. I have added an actionlistener and keylistener which both call to the same function, so if they click btn1 or press 1 on the number pad the same thing happens. The problem is…
user3562657
  • 167
  • 3
  • 15
1
vote
3 answers

JButton Action Performed?

I have created a Jframe/button with 10x10 grid. Each jbutton is apart of the grid. I am trying to how to affect each button pressed through JFrame/button, as I want to eventually make it into a battleships games. frame.setLayout(new…
3eternus
  • 33
  • 1
  • 1
  • 8
1
vote
1 answer

Move JOptionPane's showConfirmDialog along with Java Application

I want to have warning showConfirmDialog window in front of the application even if GUI moves to different position, it works fine if I don't move the application and press 'Close ALT+X' button, but if I move the application to second screen the…
Java.beginner
  • 871
  • 2
  • 19
  • 37
1
vote
1 answer

Customizing JButton borders

Is there a way, if so how, to add a border to a button but only to the bottom of it? I want to change the colour of the bottom border of the button. Is it possible?
user3650137
  • 31
  • 1
  • 6
1
vote
1 answer

get node value from JTree and display it in JTable using JButton

I know it's simple and stupid questions, since I am newbie don't know how to link. I am trying to get a node value (file with path), and to push the node value into JTable using JButton - 'Add Files', have posted the code so far have tried, it…
Java.beginner
  • 871
  • 2
  • 19
  • 37
1
vote
1 answer

add JButton into frame with JTable

I would like to know how to put a button inside a frame that contain JTable inside. (The button should not be inside a cell, but after the table ends) Here is the example code I wrote so far: class SimpleTableExample extends JFrame { // Instance…
firestruq
  • 719
  • 6
  • 15
  • 27
1
vote
0 answers

Color of JButton only changing once

I am trying to make a game where JButtons need to change colors multiple times. This works once, but then stops changing color. import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; public class Start { int…
XMB5
  • 1,384
  • 1
  • 13
  • 17
1
vote
1 answer

How to allow user to continuously input elements into JList

I want to be able to allow the user to continuously add elements to JList. The program allows the user to input an element into the textfield and when the user presses the JButton, it will add it into the list. I was able to do so but my program…
1
vote
1 answer

simulate button click according to jtextfield's changes

I'm facing problem with the simulation of the button click. I have JTextField that takes data from scanner (like in grocery stores). After that i need to push enter button, to activate function jTextField1ActionPerformed. Is there any way to do it…
Medet Koilybay
  • 111
  • 2
  • 9