jtogglebutton

Java JToggleButton freezes in While loop

瘦欲@ 提交于 2019-12-11 10:00:30
问题 public void playMet() { int tempo = Integer.parseInt(met_speed.getText()); tempo = tempo/60; int delay = tempo*1000; if(Play.isSelected()) { try { FileInputStream in = new FileInputStream(new File("Click1.wav")); AudioStream as = new AudioStream(in); AudioPlayer.player.start(as); Thread.sleep(tempo*1000); playMet(); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } } else System.out.println("not playing"); } Here's a section of my code, basically when a button is pressed it

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

会有一股神秘感。 提交于 2019-12-11 03:28:39
问题 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 have had some trouble retrieving which button has been pressed. Here's my code, please run it if you can you will understand it better. PS: I'm not making use of a database. Thank you. // CM1203 Fundamentals of Computing with Java; Second

JToggleButton addItemListener seems to repeat the ItemListener forever

我是研究僧i 提交于 2019-12-10 17:16:24
问题 I'm programming a JToggleButton to load to/discard from memory the configuration of an element (a telescope config), so I've added a JComboBox in a JFrame and near it the button to load the selected item. When the JToggleButton is selected, an hard disk icon is displayed, another icon if otherwise. I'm using the IntelliJ IDEA GUI editor for that. Of course, I've added an ItemListener (as suggested from the web) to that button: loadTelescopeButton.setSelected(true); System.out.println

Disabling a jToggleButton throughout entire execution, possible? [closed]

百般思念 提交于 2019-12-02 12:56:42
Hey guys so I'm making this simple movie ticketing system My program flow is as follow and all pages are in different JFrames: Main Menu>Choose Day>Select movie>select seat>back to MainMenu I'm using JToggle in the seat chooser. Is it possible to disable the toggle button throughout entire execution once selected? I'm using JToggleButton.setEnabled(false); but everytime I go back to menu and come back to seat chooser,the button is still not disabled .what I want to do is to have it disable even after I'm back to MainMenu, so when I go back to seat chooser, I can't select this seat anymore.

Drawing text in java, Look and Feel problems

大兔子大兔子 提交于 2019-12-01 19:59:58
I've overridden the paintComponent method of an extended JToggleButton so that I can use a TexturePaint fill for the text when the button is toggled. The problem I'm running into is that I can't seem to draw the text using the same font as my look and feel is using as a default. I've tried g2d.setFont(this.getFont()); , where "this" is the button I'm working with. The font is close, but appears bolder than the default text when I draw it. Is there a better way to draw text such that it looks the same as the default, save for the color? Thanks in advance! camickr If you are overriding the

Simple ActionListener within a 2D array of JButtons

荒凉一梦 提交于 2019-11-27 15:54:53
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 like javax.swing.JToggleButton[,59,58,19x14,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@53343ed0,flags=296,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,right=14],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=false,rolloverIcon=

Changing the background color of a selected JToggleButton

白昼怎懂夜的黑 提交于 2019-11-26 23:35:27
问题 I am trying to change the color of a JToggleButton when it has been selected in a reliable, look and feel independent way. If using the Metal L&F, then using the UIManager is an approach: UIManager.put("ToggleButton.selected", Color.RED); Note : Iyy pointed out that I had a typo in the property name above, but I will leave it above for people getting here, but the actual property name is supposed to be: UIManager.put("ToggleButton.select", Color.RED); However, this does not work in my current

set and disable icons of JToggleButton

有些话、适合烂在心里 提交于 2019-11-26 21:06:54
hi there i am trying to make a matching memory game which i use JToggleButton. the main thing is when i press to button it must show a picture and i must find the other same picture. so the problem is when i create a button without any icons i cant use other other methods for example .setRollOverIcon() , .setPressedIcon() etc. so i appreciated if you can help me . and thanks anyway :) import java.awt.*; import java.awt.event.*; import javax.swing.*; public class ButtonsIcon extends JFrame { private static final long serialVersionUID = 1L; private ImageIcon errorIcon = (ImageIcon) UIManager

Simple ActionListener within a 2D array of JButtons

老子叫甜甜 提交于 2019-11-26 17:25:07
问题 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 like javax.swing.JToggleButton[,59,58,19x14,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@53343ed0,flags=296,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2

set and disable icons of JToggleButton

无人久伴 提交于 2019-11-26 07:49:32
问题 hi there i am trying to make a matching memory game which i use JToggleButton. the main thing is when i press to button it must show a picture and i must find the other same picture. so the problem is when i create a button without any icons i cant use other other methods for example .setRollOverIcon() , .setPressedIcon() etc. so i appreciated if you can help me . and thanks anyway :) import java.awt.*; import java.awt.event.*; import javax.swing.*; public class ButtonsIcon extends JFrame {