-2

how do i make this JButton look like a awt.Button?

JButton button = new JButton("bob");
button.setUI(???????);
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
blackDog
  • 1
  • 1
  • 5

1 Answers1

3

Here are three separate ui Lookandfeel options

UIManager.setLookAndFeel (“java.awt.swing.plaf.metal.MetalLookAndFeel” ) ;  
SwingUtilities.updateComponentTreeUI ( this ) ;
UIManager.setLookAndFeel (“java.awt.swing.plaf.windows.WindowsLookAndFeel” ) ;   
SwingUtilities.updateComponentTreeUI ( this ) ;
UIManager.setLookAndFeel (“java.awt.swing.plaf.motif.MotifLookAndFeel” ) ; 
SwingUtilities.updateComponentTreeUI ( this ) ;

If you want to find the installed looksandfeels on your machine:

//Get Installed look and Feels
import javax.swing.UIManager;

public class InstalledLookandFeels {
public static void main(String args[]) {
    UIManager.LookAndFeelInfo laf[] = UIManager.getInstalledLookAndFeels();
    for (int i = 0, n = laf.length; i < n; i++) {
        System.out.print("LAF Name: " + laf[i].getName() + "\t");
        System.out.println("  LAF Class name: " + laf[i].getClassName());
    }
    System.exit(0);
  }
}
RGG
  • 1,833
  • 1
  • 15
  • 28
  • `UIManager.setLookAndFeel (“java.awt.swing.plaf.windows.WindowsLookAndFeel” ) ;` This is not an option (fortunately) for OS X or *nix. Use instead `UIManager.setLookAndFeel (UIManager.getSystemLookAndFeelClassName());`. Also, that code has 'smart quotes' rather than normal quotes. – Andrew Thompson Nov 30 '12 at 00:43