EarthWeb
Developer.com
Site
windows 2000
visual c++
java
visual basic
javascripts
recommend it
 
Book
thinking in java
 
Interact
forum
guest book
jobs
jokes
what's new

share code
 
Resource
add resource
modify resource
new resource
 

[Internet Jobs]
-----
Java by E-mail:

Get the weekly e-mail highlights on Java!
-----

-

Look & Feel to match the native OS


Author: Zafir Anjum

Select a L&F that matches the look and feel of the native OS.


try {
	UIManager.setLookAndFeel(  UIManager.getSystemLookAndFeelClassName() );
}
catch (Exception e) {}

Note that the native L&F should be installed for this to work.

Here's a sample program.


import java.awt.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;


public class Tree
{
	static JTree tree ;
	
	public static void main(String[] args)
	{
		JFrame frame = new JFrame("Tree");
		frame.addWindowListener( new WindowAdapter() {
			public void windowClosing(WindowEvent e)
			{
				Window win = e.getWindow();
				win.setVisible(false);
				win.dispose();
				System.exit(0);
			}
		} );
		
		frame.getContentPane().setLayout( new BorderLayout() );
		
		
		try {
			UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
		}
		catch (Exception e) {}

		tree = new JTree();
	
		JScrollPane sp = new JScrollPane( tree );
		frame.getContentPane().add( sp, "Center" );

		frame.pack();
		frame.show();
	}
}

Posted On: 21-Feb-1999

internet.commerce



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy