• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Maximize and minimize JButton on Mouse over

Arjun Palanichamy
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All...

I am herewith enclosed my sample code for resize the JButton(),But This one resize the when will be extend the Button Caption letters,But i want mouse click resize the without button caption or with caption.

sample code :

package Resize;

import java.awt.Container;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;

import java.awt.Dimension;
import java.awt.ComponentOrientation;

public class ReButton{
public static boolean RIGHT_TO_LEFT = false;

public static void addComponents(Container contentPane) {
contentPane.setLayout(new FlowLayout());

contentPane.add(new JButton("1"));
contentPane.add(new JButton("100"));
contentPane.add(new JButton("100 100"));
contentPane.add(new JButton("100 100 100"));
contentPane.add(new JButton("100 100 100 100"));
contentPane.add(new JButton("5"));


private static void createAndShowGUI() {

JFrame frame = new JFrame("FlowLayoutDemo") {
public Dimension getMinimumSize() {
Dimension prefSize = getPreferredSize();
return new Dimension(100, prefSize.height);

//Set up the content pane.

//Display the window.

public static void main(String[] args) {

javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {


Thanks for your time.

Arjun Palanichamy.
[ August 19, 2006: Message edited by: Arjun Palanichamy ]
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic