ADS

Using Windows Look And Feel For Jbutton

An example on using WindowsLookAndFeel for JButton
 import javax.swing.*;
import java.awt.*;
class WindowsButton extends JFrame
{
JPanel p;
public WindowsButton()
{

try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}catch(Exception e){}

setTitle("Windows Button");
setSize(400,400);
setLayout(new BorderLayout());
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);

p=new JPanel();
p.setLayout(new GridLayout(10,10));

for(int i=1;i<=100;i++)
{
p.add(new JButton("Button "+i+"\n"));
}

add(p);

}

public static void main(String args[])
{
new WindowsButton();
}
}

UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"): Set the default windows look and feel (chosen by your current theme) to the frame (ofcourse for components in the frame too). The class is situated in com.sun.java.swing.plaf.windows package and the name is WindowsLookAndFeel

p.setLayout(new GridLayout(10,10)): Create GridLayout for panel for 10 rows and 10 cols.
 An example on using WindowsLookAndFeel for JButton  Using Windows Look And Feel for JButton
Windows Button

Subscribe to receive free email updates:

ADS