Home Java Example Java Util To Create a Frame with Preferences

Related Tutorials


 
 

Share on Google+Share on Google+

To Create a Frame with Preferences

Advertisement
In this section you will learn how to use the preferences in frame. The example will make it easier to understand to use the preferences with frame window.

To Create a Frame with Preferences

     

In this section you will learn how to use the preferences in frame. The example will make it easier to understand to use the preferences with frame window. the required package to use the preferences with frame window are java.awt, java.awt.event, javax.swing and java.util.prefs. I the given example we make a preferences object and call it in main.

 

 

Here is the Complete Code of the Example :

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

 import java.util.prefs.*;
  
  public class PreferenceTestFrame extends JFrame {
  
  // A reference to Preferences object
  private Preferences myPreferences = null;
  
  public PreferenceTestFrame() {
  super("Preferences Test Window");
  
  // Obtain a references to a Preferences object
  myPreferences = Preferences.userNodeForPackage(this.getClass());
  }
 public static void main(String[] args) {
  JFrame window = new PreferenceTestFrame();
    window.setVisible(true);
    }

  }
  

After thoroughly knowing the code you should save the file by "PreferenceTestFrame.java" file name and when after compiling the code you run your program you will get the output given below .  

Here is the Output of the Example :

Download this example.

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 27, 2008

Related Tutorials

Discuss: To Create a Frame with Preferences  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com