Results 1 to 4 of 4
  1. #1
    RichersooN is offline Senior Member
    Join Date
    Jan 2011
    Location
    Rizal Province, Philippiines
    Posts
    167
    Rep Power
    0

    Post Java Look and Feel

    Please any body have a code for java look and feel and how to set up it. I very confuse with this topic (Java Look and Feel)
    Last edited by RichersooN; 01-19-2011 at 01:31 PM.

  2. #2
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default

    Hi,
    Sorry, Maybe I not correct understand what you want. but if you want just look any code on Java you can look this topic Lesson: A Closer Look at the "Hello World!" Application (The Java™ Tutorials > Getting Started)
    Skype: petrarsentev
    http://TrackStudio.com

  3. #3
    Dinesh_rockz is offline Member
    Join Date
    Jan 2011
    Location
    India
    Posts
    22
    Rep Power
    0

    Default

    it is a simple example for look and feel...:)

    Java Code:
    import java.awt.*;
    import javax.swing.plaf.basic.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.lang.*;
    
    public class exam extends JFrame implements ActionListener
    {
    JButton def_but=new JButton("Default Look And Feel..");
    JButton sys_but=new JButton("System Look And Feel..");
    JButton mot_but=new JButton("Motif LookAndFeel..");
    exam()
    {
    super("Look And Feel");
    setLayout(null);
    
    def_but.setBounds(10,10,180,30);
    def_but.addActionListener(this);
    add(def_but);
    
    
    sys_but.setBounds(10,50,180,30);
    sys_but.addActionListener(this);
    add(sys_but);
    
    
    mot_but.setBounds(10,90,180,30);
    mot_but.addActionListener(this);
    add(mot_but);
    
    setSize(500,600);
    setVisible(true);
    setDefaultCloseOperation(2);
    }
    public void actionPerformed(ActionEvent e) 
    {
    	if(e.getSource().equals(mot_but))
    	{
    		 try {
            
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
            SwingUtilities.updateComponentTreeUI(this);
      		  } 
        	catch (Exception ex)
        		 {
        	System.out.println (ex.getMessage());
       			 }
    	}
    	
    	if(e.getSource().equals(sys_but))
    	{
    		 try {
           
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
             SwingUtilities.updateComponentTreeUI(this);
        	} 
        	catch (Exception ex) 
        		{
        	System.out.println (ex.getMessage());
        		}
    	}
    	
    	
    		if(e.getSource().equals(def_but))
    	{
    		 try {
      
          UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
          SwingUtilities.updateComponentTreeUI(this);
        } catch (Exception ex) 
        	{
        	System.out.println (ex.getMessage());
        	}
    	}
    	
    }
    
       
        
        public static void main (String[] args) {
        	exam obj=new exam();
        	obj=null;
    }
    }
    Last edited by Dinesh_rockz; 01-20-2011 at 03:20 AM.

  4. #4
    e05_102 is offline Member
    Join Date
    Jan 2011
    Posts
    1
    Rep Power
    0

    Default

    Hi Richersoon,
    if you use IDE Netbeans, you can try in class main

    EX :

    before :

    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {

    // insert function to call Look And Feel in here

    new MainFrame().setVisible(true);
    }
    });
    }


    after :

    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {

    public void run() {

    try { UIManager.setLookAndFeel("org.fife.plaf.Office2003 .Office2003LookAndFeel");
    } catch (ClassNotFoundException ex) {
    Logger.getLogger(frameMain.class.getName()).log(Le vel.SEVERE, null, ex);
    } catch (InstantiationException ex) {
    Logger.getLogger(frameMain.class.getName()).log(Le vel.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
    Logger.getLogger(frameMain.class.getName()).log(Le vel.SEVERE, null, ex);
    } catch (UnsupportedLookAndFeelException ex) {
    Logger.getLogger(frameMain.class.getName()).log(Le vel.SEVERE, null, ex);
    }

    new frameMain().setVisible(true);
    }
    });
    }


    i hope can help u

Similar Threads

  1. How to work Nimbus Look & feel in java
    By justbeller in forum AWT / Swing
    Replies: 5
    Last Post: 01-18-2011, 02:08 PM
  2. How to work Nimbus Look & feel in java
    By justbeller in forum Java 2D
    Replies: 1
    Last Post: 01-18-2011, 07:59 AM
  3. Java Look & Feel: how to change default settings?
    By mirsev in forum New To Java
    Replies: 0
    Last Post: 07-21-2010, 07:48 PM
  4. vista look and feel in windows 2000 using java
    By zion892 in forum New To Java
    Replies: 1
    Last Post: 11-23-2009, 08:30 AM
  5. Look and Feel
    By Stein in forum New To Java
    Replies: 10
    Last Post: 10-03-2008, 05:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •