Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java: How to use Windows look and feel

Java: How to use Windows look and feel
{filelink=906}

import java.awt.Dimension;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.UIManager;
public class LookAndFeelWindows {
	public LookAndFeelWindows()
	{
		JLabel label = new JLabel("Cliquez sur ce Site");
		    JTextField champ = new JTextField("www.tubedir.com");
		    JList list = new JList(new String[] { "Janvier", "January", "Januar" });
		    JScrollPane panelList = new JScrollPane(list);
		    panelList.setPreferredSize(new Dimension(250, 100));
		    JScrollPane panelJTree = new JScrollPane(new JTree());
		    panelJTree.setPreferredSize(new Dimension(250, 100));
		    JButton button = new JButton("Click me");
		    JPanel panelPrincipal = new JPanel();
		    panelPrincipal.add(label);
		    panelPrincipal.add(champ);
		    panelPrincipal.add(panelList);
		    panelPrincipal.add(panelJTree);
		    panelPrincipal.add(button);
		    JFrame frame = new JFrame();
		    frame.setTitle("Utilisation de theme en java");
		    frame.setPreferredSize(new Dimension(280, 300));
		    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		    frame.setContentPane(panelPrincipal);
		    frame.pack();
    		frame.setVisible(true);
	}
  public static void main(String[] args) {
    try
    {
    //Use Microsoft windows theme
      UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
      new LookAndFeelWindows();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

Users who found this page were searching for:

  • how to use look and fell in java simple program
  • how to use windows look and feel java
  • java swing animation example

No comments yet.

Leave a Comment