How to Resize JButton,JTextArea and JTextFields on Mouse Over....

Hi All...Hi friends.. I want to be implement my java swing application Resize the Width and Height wise of JButton,JLabel,JTextFields on mouse over etc.============================ Arjun Palanichamy.Senior Programmer.Chennai-India.
[273 byte] By [arjunmkuca] at [2007-10-3 2:59:49]
# 1
reset their preferredSize() and call pack(), or[frame].pack();but will not work in all cases, depending on layout manager and other components
Michael_Dunna at 2007-7-14 20:49:26 > top of Java-index,Desktop,Core GUI APIs...
# 2
Hi,what exactly do you want to do? Some kind of GUI layout editor?-Puce
Pucea at 2007-7-14 20:49:26 > top of Java-index,Desktop,Core GUI APIs...
# 3

Hi...

I want Increase and decrease the JButton,JTextField Hight and Width on mouse drag. example for VisualBasic Button creation Object. Just

example Code:

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class button extends JFrame

{

JPanel pane = new JPanel(); // create pane object

JLabel prompt = new JLabel(" Enter a number: ");

JTextField answer = new JTextField ("", 5); // constrain length

JButton pressme = new JButton("Press Me");

public button() // the constructor

{

super("JPrompt Demo");

setBounds(100,100,300,200);

pressme.setBounds(30,50,100,50);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Container con = this.getContentPane(); // inherit main frame

con.add(pane);// JPanel containers default to FlowLayout

pressme.setMnemonic('P'); // associate hotkey

pane.add(prompt);

pane.add(answer);

pane.add(pressme);

answer.requestFocus(); setVisible(true);

}

public static void main(String[] args)

{

button but = new button();

}

}

-

This wil excute display the some Textfield and JButton. Here i want Resize the that Textfield and Button on Mouse Drag Editable mode.

***********************

Thanks in Advance.

Arjun Palanichamy.

arjunmkuca at 2007-7-14 20:49:26 > top of Java-index,Desktop,Core GUI APIs...
# 4
I'm still not sure what you want to do. Do you want to resize (and move?) the components with mouse dragging or do you want an effect like a magnifying glass when the mouse is over the component and resize it to a predefined size?-Puce
Pucea at 2007-7-14 20:49:26 > top of Java-index,Desktop,Core GUI APIs...
# 5

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) {

if (RIGHT_TO_LEFT) {

contentPane.setComponentOrientation(

ComponentOrientation.RIGHT_TO_LEFT);

}

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);

}

};

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set up the content pane.

addComponents(frame.getContentPane());

//Display the window.

frame.pack();

frame.setVisible(true);

}

public static void main(String[] args) {

javax.swing.SwingUtilities.invokeLater(new Runnable() {

public void run() {

createAndShowGUI();

}

});

}

}

for example can you Click this.....

http://www.eclipse.org/vep/WebContent/docs/testcases/null-layout/null-layout.htm

************************

Thanks for your time.

Arjun Palanichamy.

Chennai-India.

arjunmkuca at 2007-7-14 20:49:26 > top of Java-index,Desktop,Core GUI APIs...