Home Java Example Java Swing Showing the Frame with Default Look and Feel



Showing the Frame with Default Look and Feel
Posted on: April 14, 2007 at 12:00 AM
In this section, the given program shows the frame in the default look and feel.

Showing the Frame with Default Look and Feel

     

In this section, the given program shows the frame in the default look and feel. Displayed frame has a combo box and a text box, the text box text is changed as per your selection in the combo box.

Screen shot of frame with default look and feel:

Frame with default look and feel.

Here is the code of the program:

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

public class DefaultLookAndFeel{
  JFrame frame;
  JPanel panel;
  JTextField field;
  JComboBox combo;
  public static void main(String[] args) {
  DefaultLookAndFeel l = new DefaultLookAndFeel();
  }

  public DefaultLookAndFeel(){
  JFrame.setDefaultLookAndFeelDecorated(true);  
  frame = new JFrame("Default Look And Feel");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  String str[] {"BCA""CIC""PPC""MCA"};
  panel = new JPanel();
  field = new JTextField(5);
  combo = new JComboBox(str);
  combo.addItemListener(new ItemListener(){
  public void itemStateChanged(ItemEvent ie){
  String st = (String)combo.getSelectedItem();
  field.setText(st);
  }
  });
  panel.add(combo);
  panel.add(field);
  frame.add(panel);
  frame.setSize(300300);
  frame.setVisible(true);
  }
}

Download this example.

Related Tags for Showing the Frame with Default Look and Feel:
displaydefaultviidoosimpleframeexampleramexamesplulimfaultinmplayispmeproxaxampsspeedisplaysatkishamplandsimssthhatdispfeefaultframpleplprndo


More Tutorials from this section

Ask Questions?    Discuss: Showing the Frame with Default Look and Feel  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.