Questions tagged [jtogglebutton]

The JToggleButton represents button that can be toggled, similar to a check box.

JToggleButtons can be placed wherever checkbox functionality is desired in a button. When the user presses a JToggleButton, then the button stays visually pressed. When the user presses again, then it is visually unpressed.

Depending on the user's look and feel, the button may look like a normal button, or it may look completely different.

122 questions
3
votes
4 answers

How to make a toggle button toggled automatically

How to make a toggle button toggled automatically when someone types anything in text field?? i am using java Net-beans
remi yazigi
  • 85
  • 1
  • 10
3
votes
1 answer

JButton isselected method doesnt work

The code below is to change the colour of the background on selecting any of the 3 buttons: red, green or blue. When I select either of them, nothing actually happens. However, changing from JButtons to JRadioButtons or JToggleButtons does work.…
user1657862
  • 83
  • 1
  • 8
2
votes
2 answers

How to color Jbutton in java

hello guys i have problem coloring those buttons the background allways change color but the other stay in grey color, any way to change that to other color? /sorry for my english/ import javax.swing.*; import java.awt.*; import…
2
votes
1 answer

keep 2 pictures open for a while in memory game in java

hi there i am working on a project(card matching game) and it is almost finished but the things is when i clicked on second button to open the picture if it not same with first it suddenly closed. well nothings is wrong but user must see the picture…
quartaela
  • 2,579
  • 16
  • 63
  • 99
2
votes
0 answers

JToggleButton inside JToolbar on macOS - no indication of being pressed

I can't seem to get simple toggle buttons working inside a JToolbar. This example program adds three toggle buttons in a button group to a JToolbar. On macOS, currenty toggled button is only visible if the app looses focus. import…
predi
  • 5,528
  • 32
  • 60
2
votes
2 answers

How to check JToggleButton state in a class from another class using IF-statement that have actionPerformed within it?

EDIT : I found my problem but still don't have a clue for why this happen, I'm still not finished Online Lectures from Professor Mehran Sahami (Stanford), maybe I'll find an answer if I push on on the lecture videos. The problem is I remove my…
punkdawa
  • 23
  • 1
  • 7
2
votes
1 answer

Java Swing Making On/Off Button

I am trying to make an on/off button for my GUI project. I made a button, when I click on it, a message appears. I used ActionListener for that. When I click it again, I want that message to dissappear. I tried to use jToggleButton but I don't know…
berkc
  • 525
  • 3
  • 9
  • 21
2
votes
1 answer

Click j/ToggleButton then set Icon/Image

I am making a 4x4 board kinda like minesweeper. Each button has a bomb or another image. Here's my code: private void jButton1MouseClicked(java.awt.event.MouseEvent evt) { this.jToggleButton1.setIcon(new…
2
votes
2 answers

Prevent switch from a specifc toggle button in button group unless a condition is met

I'd like to create a group of two buttons (A and B), where switching from B to A is always allowed, but switching from A to B is dependent on a condition. The condition may only be checked in the latter case (A to B) and the check may only be done…
predi
  • 5,528
  • 32
  • 60
2
votes
2 answers

Is this the influence of ButtonGroup?

I've added a JToggleButton to a ButtonGroup. Then I can't unselect this ToggleButton by clicking it one more time anymore. I'm pretty sure that JToggleButton can be unselected by clicking it. Is there any simple way to let the Button works as…
user1850337
  • 99
  • 1
  • 7
2
votes
2 answers

Using a For Loop to work with many variables where the names differ only slightly (different numbers)

I have a program where I am using several hundred JToggleButtons. Their names differ only slightly by numbers (e.g. jToggleButton1, jToggleButton2, jToggleButton3,...) Is there a way that I can use a for loop when doing the same thing to multiple…
setherj
  • 91
  • 1
  • 11
2
votes
2 answers

Center a JToggleButton ImageIcon

I've created a JToggleButton and when it is selected the image is shown. It all works perfectly except the image isn't centered on the button. The top left corner of the image is on the center point of the button and then the image goes down and out…
Michael Esteves
  • 1,445
  • 3
  • 21
  • 38
2
votes
1 answer

Java: Disable all JToggleButtons after Submission — setEnabled(false);

I am currently developing a booking system as a task for my degree. What would be the best way to disable selected JToggleButtons after a button is pressed; so seats wouldn't be available after purchase. I have tried using for loops and arrays but…
waltfy
  • 137
  • 3
  • 16
1
vote
4 answers

Simple ActionListener within a 2D array of JButtons

Okay so I am making a 2d array of JToggleButtons. I got the action listener up and going, but I have no way to tell which button is which. If I click one, all it returns is something…
Austin
  • 3,010
  • 23
  • 62
  • 97
1
vote
3 answers

Show user that something is on from JButton

Okay, I'll admit - the title is not the most descriptive/helpful but I couldn't really think of a better way to put it, which is probably also why I couldn't find an answer when I was searching. Basically, I'm making a basic MS Notepad like text…
Andy
  • 3,600
  • 12
  • 53
  • 84
1
2
3
8 9