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
0
votes
1 answer

Counting Toggle Buttons and

http://i415.photobucket.com/albums/pp235/wong93_photos/Untitled-3.png yo guys I have few questions here, before I ask, what I want do with this program is to count number of toggles that have been pressed and set the total in the jTextField below…
user3144549
  • 13
  • 1
  • 1
  • 6
0
votes
2 answers

JToggleButton.One selected, others deselected

So I have three buttons, let's say 1, 2 and 3. I want, when I click button1, button2 and button3 to be deselected. After, when I click button2, I want button1 and button3 to be deselected. Same for button3. Basically, when I click one button, I want…
MrSilent
  • 564
  • 10
  • 28
0
votes
2 answers

JTable render Boolean as JToggleButton

Hi I am able to render the Boolean column as a JToggleButton but if I keep the button pressed, I am seeing the checkbox instead of the button. TableColumnModel tcm = smartAlertsTable.getColumnModel(); TableColumn tc = tcm.getColumn( Index of the…
aditya
  • 112
  • 1
  • 10
0
votes
2 answers

Limit the number of selected JToggleButton

I'm new on swing java, I maked an array of jtoggle buttons and my problem is that I want to limit the number of selected(toggled) buttons for 4 toggled buttons. Is there any property that allows me to do that ? Here is my code example. package…
hamza-don
  • 455
  • 5
  • 26
0
votes
1 answer

Un-Select JToggleButton

I have a JToggleButton, not in a group, and if it's pressed, I want to be able to Un-Select it if I press another JButton. I've tried using: toggleButton.setSelected(false); toggleButton.doClick(); but neither un-Select the toggle button, it stays…
user1572522
  • 569
  • 2
  • 11
  • 26
0
votes
2 answers

Deselect JToggleButton if file exists

as I mentioned in a post before, I'm porting my program to Java, to make it available for Mac OS and Linux users. At the start of the program, I'd like to check if adb is installed to the system using this code: private void checkADBExists() //…
SimonC
  • 1,547
  • 1
  • 19
  • 43
0
votes
1 answer

Moving an image icon within a JToggleButton?

Here's a picture of part of my interface. The image is circular with a transparent background but it doesn't center properly within the button. I was wondering if I could manually move it into position.
0
votes
1 answer

JButton in a JDialog remains pressed

i have a problem with a JButton in a JDialog, the code is : package asdasd; import java.awt.Dialog; import javax.swing.JDialog; import javax.swing.SwingWorker; class F extends javax.swing.JFrame { /** * Creates new form F */ public F() { …
0
votes
5 answers

Is it possible to make JToggle text depend on its state?

Is it possible for me to set the text on JToggle button to "ON" if it is selected and if not, as "OFF"? I'm trying with this code: if(togbut.isSelected()){ togbut.setText("ON"); } else if(!togbut.isSelected()){ …
Tech Nerd
  • 822
  • 1
  • 13
  • 39
0
votes
1 answer

My Minesweeper program written in Java is throwing a NullPointerException

I have written a Minesweeper game in Java. However, after I click on a few buttons, it throws a NullPointerException. Here is the complete program (I'm afraid it is huge, and my comments won't help much, I suppose!) import java.util.Random; import…
0
votes
2 answers

need help putting a timer method behind a JToggleButton

I am struggling a bit with this. After researching on Google I have created the following timer routine which works well when called // play move method public static void playMove() { int delay = 1200; // delay for 1 sec. int period =…
user1432365
  • 103
  • 1
  • 1
  • 7
0
votes
2 answers

ButtonGroup: Quantity of selected elements

How do I get the quantity of all selected JToggleButtons in a ButtonGroup? ButtonGroup bGroup = new ButtonGroup(); bGreen = new JToggleButton("Green"); bYellow = new JToggleButton("Yellow"); bRed = new…
Evgenij Reznik
  • 17,916
  • 39
  • 104
  • 181
-1
votes
1 answer

Using JToggleButton in java to make other buttons visible

I am trying to create a doodle god style game in java, I cant figure out how to make it so when two JToggleButtons are toggled it makes a third appear. Here is my attempt, but it is not working any suggestions. I am new at this and its confusing. I…
-1
votes
1 answer

JToggleButton and unexpected nullPointerException

I have a class PolaczZBaza with 2 methods- polacz() - to open a connection with sql database rozlacz() to close this database there is a JToggleButton which is used for connecting with this database. @Override public void itemStateChanged(ItemEvent…
cinek181992
  • 155
  • 4
  • 13
-2
votes
1 answer

Creating multiple JToggleButton with indivdual ImageIcon

ImageIcon img_1 = new ImageIcon("src/menu/btn_1.jpg"); ImageIcon img_2 = new ImageIcon("src/menu/btn_2.jpg"); ImageIcon img_3 = new ImageIcon("src/menu/btn_3.jpg"); ImageIcon img_4 = new ImageIcon("src/menu/btn_4.jpg"); ImageIcon…
Zainau
  • 95
  • 4
  • 13
1 2 3
8
9