
how to increas size of button (especially width)and height
Thanks in advance

Using setBounds() method, we have increased the height and width of button.
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.awt.event.*;
import java.sql.*;
class IncreaseButtonSize extends JFrame
{
JButton b;
JLabel label;
final JTextField text;
IncreaseButtonSize(){
setLayout(null);
label = new JLabel("Name");
text = new JTextField(20);
b=new JButton("View");
label.setBounds(10,10,100,20);
text.setBounds(120,10,120,20);
b.setBounds(120,40,150,40);
add(label);
add(text);
add(b);
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String value=text.getText();
JOptionPane.showMessageDialog(null,"Hello "+value);
}
});
}
public static void main(String arg[])
{
IncreaseButtonSize frame=new IncreaseButtonSize();
frame.setSize(300,120);
frame.setVisible(true);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.