jtogglebutton

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

天大地大妈咪最大 提交于 2020-02-04 10:57:49
问题 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 for a while(maybe 2 second). so i used Thread.sleep(2000) but i doesnt work properly. it sets icon null and then start to wait 2 seconds. here is my code a tried to make a SSCCE, import java.awt.BorderLayout; import java.awt.Color; import java.awt

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

a 夏天 提交于 2020-02-04 10:57:04
问题 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 for a while(maybe 2 second). so i used Thread.sleep(2000) but i doesnt work properly. it sets icon null and then start to wait 2 seconds. here is my code a tried to make a SSCCE, import java.awt.BorderLayout; import java.awt.Color; import java.awt

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

五迷三道 提交于 2020-01-11 14:39:47
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . 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

Creating multiple instance of an object with same variable in Java

风格不统一 提交于 2019-12-24 14:34:54
问题 I have a modeless dialog which i need to show multiple instances of it displayed at the same time. I have kept the dialog as a member variable in a class which i new and show the dialog. Here there are multiple instances of dialog visible but i am assigning it to the same member variable.(I need to have it as member variable for some processing). It is working fine but i dont understand why this is working. Am i missig something very obvious? public class ABC { CMyDialog m_dlg; onSomeEvent()

Disable standard repainting of JToggleButton when It is selected

删除回忆录丶 提交于 2019-12-23 03:49:08
问题 I want my JToggleButton not to repaint when It is selected. I indicate state changing by pair of words ("check/next"). Standard behavior is blue lighting but I want to disable it. 回答1: Perhaps you could show the words on ImageIcons. For example: import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JToggleButton; public

How to create a ButtonGroup with connected buttons in Java?

房东的猫 提交于 2019-12-19 06:18:53
问题 I am currently trying to create a group of toggle-buttons that are similar to the one's used in the formatter preferences of Eclipse: Currently I have attempted this in the following way: public class Exercise extends JFrame { private String[] buttonNames = {"A", "B", "C", "D", "E"}; Exercise() { final JPanel topPanel = new JPanel(); topPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); int tabCount = 0; final ButtonGroup topButtonGroup = new ButtonGroup();

Getting the state of JToggleButton

牧云@^-^@ 提交于 2019-12-17 16:26:07
问题 Say I have a JToggleButton but = new JToggleButton("OK") ; Now I need the state of but when it is clicked. I mean I need to know if it's clicked or not. 回答1: You can also use the itemListener's itemStateChanged method like follow: JToggleButton jtb = new JToggleButton("Press Me"); jtb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { if(ev.getStateChange()==ItemEvent.SELECTED){ System.out.println("button is selected"); } else if(ev.getStateChange()==ItemEvent

JButton isselected method doesnt work

廉价感情. 提交于 2019-12-13 14:24:51
问题 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. Anyone knows why? Is it because JButton.isselected() method is bugged and it always returns false? I appreciate any help...thank you. public class bgcolor2 extends JFrame { private static final int FRAME_WIDTH = 300; private static final int FRAME

Disabling a jToggleButton [duplicate]

♀尐吖头ヾ 提交于 2019-12-13 11:14:15
问题 This question already has an answer here : Disabling a jToggleButton throughout entire execution, possible? [closed] (1 answer) Closed 5 years ago . 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

JToggleButton - How to change the color?

房东的猫 提交于 2019-12-13 04:47:07
问题 I could to set the color of the button, but once the button is pressed its color is blue - standard. I want to be black. How do I change it? Below is the current code: public JPanel gameBoard(){ JPanel pBoard = new JPanel(); pBoard.setSize(5*horizontalOptions,5*verticalOptions); pBoard.setLayout(new GridLayout(horizontalOptions,verticalOptions)); jb = new JToggleButton[verticalOptions*horizontalOptions]; int k=0; for(int i=0;i<verticalOptions;i++){ for(int j=0;j<horizontalOptions;j++){ jb[k]