jbutton

java beansbinding JButton.enabled

时光总嘲笑我的痴心妄想 提交于 2020-01-15 23:42:03
问题 I'm working with jdesktop's beansbinding library in Netbeans 7.3. I have a really specific question. I'd like to have a JButton enabled if any property of another bean is not null and disabled if it's null. So I tried to create an ELBinding (which has conditional support like ${myProperty > 50} returning a boolean holding whether this expression is true or not. But in my occasion I cannot figure out (nor find on the internet) how to write down this condition. If I had an event listener for

JButton with both ActionListener / MouseListener

蹲街弑〆低调 提交于 2020-01-15 07:18:30
问题 Is it possible to create a Jbutton with both an ActionListener and MouseListener Meaning so i create a button and then when i press it ( throught actionListener) it changes the frame so that AFTER then button was pressed i can press anywhere on the frame and MouseListener would in use. JButton button = new JButton();//Creates Button button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //Insert MouseListener //Then do something with mouseListener } });

Why isn't setIcon displaying image on JButton?

落花浮王杯 提交于 2020-01-15 06:42:48
问题 I swear I've looked everywhere and have been googling for hours. I have added actionListeners to all buttons, and when one is clicked, I want to give it an image with setIcon( image ) like so: public void actionPerformed(ActionEvent e) { if(e.getSource() == button) { ImageIcon icon = new ImageIcon(getClass().getResource("/Images/" +letter+ ".PNG")); button.setIcon(icon ); } 1) I know it's retrieving the image because button.getIcon() gives me something like file:/Users/path/to/Images/X.PNG .

Making a JButton stay depressed manually

淺唱寂寞╮ 提交于 2020-01-15 04:56:06
问题 I would like to make a JButton stay pressed down and not be able to be pressed again until some event occurs is there an easy way to do this? 回答1: Perhaps you just want to disable the button? Try setEnabled(false) in your callback for the button. 回答2: You should probably look at the JToggleButton class. Associate it with an Action which calls setEnabled(false) to disable interaction. Once your event happens you call setEnabled(true) and setSelected(false) to restore the original state of the

how to maintain transparency for JButtons (java)

我们两清 提交于 2020-01-14 22:50:18
问题 i'm making a tank game. in my menu i want to use pictures as jbuttons, they are partly transparent and when they appear on screen the transparent parts become white. i tried using .setOpaque but this doesn't work. i can't think of any other method to get rid of the white parts. i've been looking all over stack overflow but none of the methods seem to help. anyone who has an idea? Thanks! package menu; import java.awt.*; import java.awt.event.*; import javax.swing.*; @SuppressWarnings("serial"

how to maintain transparency for JButtons (java)

这一生的挚爱 提交于 2020-01-14 22:48:33
问题 i'm making a tank game. in my menu i want to use pictures as jbuttons, they are partly transparent and when they appear on screen the transparent parts become white. i tried using .setOpaque but this doesn't work. i can't think of any other method to get rid of the white parts. i've been looking all over stack overflow but none of the methods seem to help. anyone who has an idea? Thanks! package menu; import java.awt.*; import java.awt.event.*; import javax.swing.*; @SuppressWarnings("serial"

How to change JButton Icon when selected?

点点圈 提交于 2020-01-14 13:47:07
问题 I Want to change the JButton icon when user press/release the button. A icon image when the JButton were selected A icon image when the JButton were unselected and the JButton were release: How can I do this? 回答1: JButton b = new JButton(Icon x); // Create button with normal icon b.setIcon(Icon x); b.setDisabledIcon(Icon x); b.setPressedIcon(Icon x); b.setSelectedIcon(Icon x); b.setDisabledSelectedIcon(Icon x); ref: http://www.leepoint.net/notes-java/GUI/components/20buttons/23buttonicons

Set the button “background” of a Nimbus button

喜欢而已 提交于 2020-01-14 09:00:30
问题 I'm working on an app using the Nimbus Look and Feel. There's a table and one column contains buttons (using the Table Button Column from Rob Camick). That does work, but the result isn't what I had expected. I have tried to fix the look, but to no avail. So the question is: how do I change the "background" (the area outside the rounded rectangle) of a Nimbus button? Preferably in a non-hacky way :-) Using the default Table Column Button, the result looks like this: As you can see, the

Making Image button look pressed/clicked in Swing

时光怂恿深爱的人放手 提交于 2020-01-13 08:24:28
问题 I created a JButton which has an image set as an icon representing the button. Now, I've set setContentAreaFilled(false); setBorderPainted(false); setOpaque(false); the properties which this makes an image-button look nice with no borders or background colors etc. Now the problem is that when I click on the image, it shows no onclick effects of a button, so when there is some background processing involved or some event is bring fired on click of button which takes time to process the request

overlay images in java

一曲冷凌霜 提交于 2020-01-13 06:26:10
问题 I hope you can give me some advices to solve my problem. I need to overlay many images on a button.but the problem is, this is the base image (tooth): (http://i.imgur.com/7tIcP.gif) my first image is this: http://i.imgur.com/FYuD8.gif and then I put this: http://i.imgur.com/mWz9c.gif the first image overlaps the second so I just can see only the second image... maybe you will tell me that one option is change the order of the image before overlay, but the user will select what will be the