jbutton

Problem with 2D Array of JButton

I need to put number(2d array) on the top left of JButton. But, i got the number result in wrong ordder (upside down), not as the same as the array topLeftNum order. How to make it so the number will show up as the same order?Please help me solve my problem..Thanks final int ROWS = 12; final int COLS = 12; final static int topLeftNum[...

JButton needs to change JTextfield text

This is homework. Beginning Java class. Still wrapping my head around this stuff. The project is to make an Inventory Management System. I have everything figured out except how to make this button change the text in a JTextField. It needs to add info from an array of a product (DVD's in this case). The book talks about different wa...

JButtons need to modify 8 JTextFields using an Array. Listen to Buttons or Text?

This is homework. Beginning Java class. Still wrapping my head around this stuff. This questions Extends this one So there is a button for First, Prev, Next, and Last Each should modify Item ID, Name, Rating, Price, Units, Value, Fee, ValueW/Fee, Total Inventory Value The last one is a static total of all units) I am not sure if ...

Setting Mnemonics and Hot Keys for a JOptionPane Dialog

Is it possible to assign hotkeys and mnemonics to the buttons in a JOptionPane Dialog? I'd like to be able, in a JOptionPane generated message dialog with the options Yes, No and Cancel, press Y to hit the Yes button, N to hit the No button and escape to activate the escape button. Similarly in a dialog with Okay and Cancel buttons I'd...

Place button side by side

Hi, how can I make a button place side by side. I used a gridBagLayout to design the layout.The problem is that the button place too far from each other. I have tried to choose the CENTER as anchor but this makes the button overlapping. If I used WEST and EAST, the button placed too far from each other. e.g. SAVE ---------- NEW PATTERN ...

How to change the look of a disabled JButton in java

I am making a game and when I disable a button with setEnabled(false); the buttons turn grey which clashes with the other colors in the game. Is their a way to change the color of the button when it is disabled? ...

How to disable javax.swing.JButton in java?

I have created a swings application and there is a "Start" button on the GUI. I want that whenever I clicked on that "Start" button, the start button should be disabled and the "Stop" button be enabled. For that I have written the following code in the "ActionPeformed(...)" method of the "Start" button startButton.setEnabled(false); st...

How to create a JButton with a menu ?

I want to create a Toolbar for my application. If you click a button on that toolbar , it will pop-up a menu , just like the toolbar of eclipse. I don't know how to do it in Swing. Can someone help me please ? I've try google but found nothing. ...

Making a JButton stay depressed manually

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? ...

JButton in Java swing

Is there a way to check whether a button is enabled is set to true or false through code? ...

Howto make JButton with simple flat style?

Hi, whats the most simple way to make a JButton only show the background color? I don't need any other effects like borders, 3D-look or hover-highlighting. Thanks in advance. ...

reseting a flow layout with a button

What I am trying to do here is set the layout scheme once I press a button to align all the buttons to the left of the contentPane I have three buttons this is the code i have for that particular button leftButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { cp.setLayout( new FlowLayout(F...

Java Swing JButton

I want to create button with custome look and feel. I have got different images to be set as background of button for normal, mouse over, mouse click, button disabled etc. I have created my own class, extending javax.swing.JButton and overrides paintComponent method. How can i change my button background for all the above given states. ...

Java Swing JButton

I have created customized Button. For that i have overrided paintComponenet method. How can I set Button Text on such button? I tried doing it using drawString method. But which x,y values should i give? (g.drawString("button text",x,y)). Please till me if anyone has handled this. @Override public void paintComponent(Graphics g) { s...

Java Swing group of Jbuttons without raised portion.

Hi I wanted to know how to display a group of JButtons to look like smooth panel without raised portion. thanks ...

Can I make Swing JButtons have smaller margins?

I prefer buttons with minimal margins, about as wide as their text caption. Is there a way to achieve that in a JButton in Swing? What I am seeing in practice now is that even if I try to use setMaximumSize() and similar, it just ends up eating the text caption, cutting it off to the right. But it does not reduce the margins. ...

Unable to resize JButton

I'm Stuck with how to resize the third button to became the same size like the other two and place it on the bottom. class ControlFrame extends JFrame implements Runnable { JButton jb_inc = new JButton(); JButton jb_zero = new JButton(); JButton jb_dec = new JButton(); ControlFrame() { super("Control Frame"...

Right click on JButton

Hi guys, I am trying to write a Minesweeper clone in Java for fun. I have a grid of JButtons whose labels I will change to represent the danger count, flags, etc. My problem is, I don't know how to get a right click on a JButton to depress the button. I've done the following: button.addMouseListener(new MouseAdapter(){ public ...

Adding Buttons inside cell of JTable along with data?

Hi, Is it possible to add buttons inside the JTable cell along with data? What I am trying to do is to create a table with columns which display data(number) from the database, and two buttons to increase/decrease the number inside the same cell. |ID | Quantity| |06| 2 [+][-] | it would be something like above with [+][-] being but...

JButton with text below the icon

In Java Swing I would like to create a JButton which contains an image(icon) and some text. In few words a JButton(text,icon). I would like the text to be displayed below the image, and not beside, as in normal JButton layout. Does anyone have an idea on how to achieve this? ...