Differences between awt and swing

Ive written the following code, however Ive implemented the gui in awt rather then swing. Ive been told it hs too be in swing. What is the difference between swing and awt what will I need to change in my program so that its done using swing rather then the awt? Heres the code:
// pp.java
// Grant Brown
// 22/02/02
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
// =========================================================
// Class: pp
// This class drives the customer manager. It contains the
// main method which gets called as soon as this application
// begins to run.
// =========================================================
class pp extends Frame implements ActionListener
// Container of customer objects
private Vector customers = new Vector (100);
// List of names component. (Must specify java.awt in
// front of List to distinguish the List class in the
// java.awt package from the List class in the java.util
// package.)
private java.awt.List names = new java.awt.List ();
// Delete and update button components.
private Button delete;
private Button update;
// Default constructor.
public pp ()
// Assign "Paper Round Manager" to title bar of frame window.
super ("Paper Round Manager");
// Add a listener that responds to window closing
// events. When this event occurs (by clicking on the
// close box in the title bar), save customers and exit.
addWindowListener (new WindowAdapter ()
public void windowClosing
(WindowEvent e)
saveCustomers ();
System.exit (0);
// Place an empty label in the north part of the frame
// window. This is done to correct an AWT positioning
// problem.
Label l = new Label ();
add ("North", l);
// Place the names component in the center part of the
// frame window.
add ("Center", names);
// Create a panel object to hold four buttons.
Panel p = new Panel ();
Button b;
// Add an Insert button to the Panel object and register
// the current pp object as a listener for button events.
p.add (b = new Button ("Insert"));
b.addActionListener (this);
// Add a Delete button to the Panel object and register
// the current pp object as a listener for button events.
p.add (delete = new Button ("Delete"));
delete.addActionListener (this);
// The Delete button should be disabled until there is at
// least one customer to delete.
delete.setEnabled (false);
// Add an Update button to the Panel object and register
// the current pp object as a listener for button events.
p.add (update = new Button ("Update"));
update.addActionListener (this);
// The Update button should be disabled until there is at
// least one customer to update.
update.setEnabled (false);
// Add a Finish button to the Panel object and register
// the current customer object as a listener for button events.
p.add (b = new Button ("Finish"));
b.addActionListener (this);
// Add the panel object to the frame window container.
add ("South", p);
// Set the background of the frame window container to
// lightGray
setBackground (Color.lightGray);
// Set the size of the frame window container to 400
// pixels horizontally by 200 pixels vertically.
setSize (400, 200);
// Allow the user to resize the frame window.
setResizable (true);
// Load all contacts.
loadCustomers ();
// Make sure that the frame window is visible.
setVisible (true);
public void actionPerformed (ActionEvent e)
if (e.getActionCommand ().equals ("Delete"))
delete ();
else
if (e.getActionCommand ().equals ("Finish"))
saveCustomers ();
System.exit (0);
else
if (e.getActionCommand ().equals ("Insert"))
insert ();
else
update ();
public Insets getInsets ()
// Return an Insets object that describes the number of
// pixels to reserve as a border around the edges of the
// frame window.
return new Insets (10, 10, 10, 10);
public static void main (String [] args)
// Create a new pp object and let it do its thing.
new pp ();
private void delete ()
// Obtain index of selected contact item from the names
// component.
int index = names.getSelectedIndex ();
// If no item was selected, index is -1. We cannot update
// a contact if no contact item in the names component was
// selected - because we would have nothing to work with.
if (index != -1)
// Remove the contact item from the names component.
names.remove (index);
// Remove the Customer object from the contacts Vector
// object.
customers.remove (index);
// If there are no more customers ...
if (customers.size () == 0)
delete.setEnabled (false);
update.setEnabled (false);
else
// Make sure that the first contact item in the names
// list is highlighted.
names.select (0);
private void insert ()
// Create an Insert data entry form to enter information
// for a new customer.
DataEntryForm def = new DataEntryForm (this, "Insert");
// If the bOk Boolean flag is set, this indicates the user
// exited the form by pressing the Ok button.
if (def.bOk)
// Create a Contact object and assign information from
// the form to its fields.
Customer temp = new Customer ();
temp.name = new String (def.name.getText ());
temp.publication = new String (def.publication.getText ());
temp.round = new String (def.round.getText ());
temp.address = new String (def.address.getText ());
temp.phone = new String (def.phone.getText ());
// Add a new customer item to the names component.
names.add (temp.name + ", " + temp.publication);
// Add the Customer object to the contacts Vector
// object.
customers.add (temp);
// Make sure that the Delete and Update buttons are
// enabled.
delete.setEnabled (true);
update.setEnabled (true);
// Destroy the dialouge box.
def.dispose ();
// Make sure that the first customer item in the names list
// is highlighted.
names.select (0);
// ===========================================================
// Load all contacts from contacts.dat into the contacts
// Vector object. Also, make sure that the last name/first
// name from each contact is combined into a String object and
// inserted into the names component - as a contact item.
// ===========================================================
private void loadCustomers ()
FileInputStream fis = null;
try
fis = new FileInputStream ("Customers.dat");
DataInputStream dis = new DataInputStream (fis);
int nCustomers = dis.readInt ();
for (int i = 0; i < nCustomers; i++)
Customer temp = new Customer ();
temp.name = dis.readUTF ();
temp.publication = dis.readUTF ();
temp.round = dis.readUTF ();
temp.address = dis.readUTF ();
temp.phone = dis.readUTF ();
names.add (temp.name + ", " + temp.publication);
customers.add (temp);
if (nCustomers > 0)
delete.setEnabled (true);
update.setEnabled (true);
catch (IOException e)
finally
if (fis != null)
try
fis.close ();
catch (IOException e) {}
// Make sure that the first contact item in the names list
// is highlighted.
names.select (0);
// ========================================================
// Save all Customer objects from the customer Vector object
// to customer.dat. The number of customerss are saved as an
// int to make it easy for loadCustomers () to do its job.
// ========================================================
private void saveCustomers ()
FileOutputStream fos = null;
try
fos = new FileOutputStream ("customers.dat");
DataOutputStream dos = new DataOutputStream (fos);
dos.writeInt (customers.size ());
for (int i = 0; i < customers.size (); i++)
Customer temp = (Customer) customers.elementAt (i);
dos.writeUTF (temp.name);
dos.writeUTF (temp.publication);
dos.writeUTF (temp.round);
dos.writeUTF (temp.address);
dos.writeUTF (temp.phone);
catch (IOException e)
MsgBox mb = new MsgBox (this, "PP Error",
e.toString ());
mb.dispose ();
finally
if (fos != null)
try
fos.close ();
catch (IOException e) {}
private void update ()
// Obtain index of selected customer item from the names
// component.
int index = names.getSelectedIndex ();
// If no item was selected, index is -1. We cannot update
// a customer if no customer item in the names component was
// selected - because we would have nothing to work with.
if (index != -1)
// Obtain a reference to the customer object (from the
// customers Vector object) that is associated with the
// index.
Customer temp = (Customer) customers.elementAt (index);
// Create and display an update entry form.
DataEntryForm def = new DataEntryForm (this, "Update",
temp.name,
temp.publication,
temp.round,
temp.address,
temp.phone);
// If the user pressed Ok...
if (def.bOk)
// Update the customer information in the customers
// Vector object.
temp.name = new String (def.name.getText ());
temp.publication = new String (def.publication.getText ());
temp.round = new String (def.round.getText ());
temp.address = new String (def.address.getText ());
temp.phone = new String (def.phone.getText ());
// Make sure the screen reflects the update.
names.replaceItem (temp.name + ", " + temp.publication,
index);
// Destroy the dialouge box.
def.dispose ();
// Make sure that the first customer item in the names
// list is highlighted.
names.select (0);

Ive doen pretty much what you said burt now my program isnt working at all. The window comes up but instead of doing something when you click the button it just throws shit loads of exceptions. Heres my abridged code
// pp.java
// Grant Brown
// 22/02/02
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
// =========================================================
// Class:PP
// This class drives the Paper Round manager. It contains the
// main method which gets called as soon as this application
// begins to run.
// =========================================================
class pp extends JFrame implements ActionListener
// Container of customer objects (one object per customer)
private Vector customers = new Vector (100);
// List of names component. (Must specify java.awt in
// front of List to distinguish the List class in the
// java.awt package from the List class in the java.util
// package.)
private java.awt.List names = new java.awt.List ();
// Delete and update button components.
private JButton delete;
private JButton update;
// Default constructor.
public pp ()
// Assign Contact Manager to title bar of frame window.
super ("Paper Round Manager");
// Add a listener that responds to window closing
// events. When this event occurs (by clicking on the
// close box in the title bar), save contacts and exit.
addWindowListener (new WindowAdapter ()
public void windowClosing
(WindowEvent e)
saveCustomers ();
System.exit (0);
// Place an empty label in the north part of the frame
// window. This is done to correct an AWT positioning
// problem. (One thing that you'll come to realize as
// you work with the AWT is that there are lots of bugs.)
JLabel l = new JLabel ();
getContentPane().add ("North", l);
// Place the names component in the center part of the
// frame window.
getContentPane().add ("Center", names);
// Create a panel object to hold four buttons.
JPanel p = new JPanel ();
JButton b;
// Add an Insert button to the Panel object and register
// the current cm object as a listener for button events.
p.add (b = new JButton ("Insert"));
b.addActionListener (this);
// Add a Delete button to the Panel object and register
// the current cm object as a listener for button events.
p.add (delete = new JButton ("Delete"));
delete.addActionListener (this);
// The Delete button should be disabled until there is at
// least one contact to delete.
delete.setEnabled (false);
// Add an Update button to the Panel object and register
// the current cm object as a listener for button events.
p.add (update = new JButton ("Update"));
update.addActionListener (this);
// The Update button should be disabled until there is at
// least one contact to update.
update.setEnabled (false);
// Add a Finish button to the Panel object and register
// the current cm object as a listener for button events.
p.add (b = new JButton ("Finish"));
b.addActionListener (this);
// Add the panel object to the frame window container.
getContentPane().add ("South", p);
// Set the background of the frame window container to
// lightGray (to give a pleasing effect).
setBackground (Color.lightGray);
// Set the size of the frame window container to 400
// pixels horizontally by 200 pixels vertically.
setBounds (50, 100, 400, 200);
// Do not allow the user to resize the frame window.
loadCustomers ();
// Load all contacts.
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Make sure that the frame window is visible.
setVisible (true);
public void actionPerformed (ActionEvent e)
if (e.getActionCommand ().equals ("Delete"))
delete ();
else
if (e.getActionCommand ().equals ("Finish"))
saveCustomers ();
System.exit (0);
else
if (e.getActionCommand ().equals ("Insert"))
insert ();
else
update ();
public Insets getInsets ()
// Return an Insets object that describes the number of
// pixels to reserve as a border around the edges of the
// frame window.
return new Insets (10, 10, 10, 10);
public static void main (String [] args)
// Create a new cm object and let it do its thing.
new pp ();
private void delete ()
// Obtain index of selected customer item from the names
// component.
int index = names.getSelectedIndex ();
// If no item was selected, index is -1. We cannot update
// a contact if no contact item in the names component was
// selected - because we would have nothing to work with.
if (index != -1)
// Remove the customer item from the names component.
names.remove (index);
// Remove the Customer object from the contacts Vector
// object.
customers.remove (index);
// If there are no more customers ...
if (customers.size () == 0)
delete.setEnabled (false);
update.setEnabled (false);
else
// Make sure that the first contact item in the names
// list is highlighted.
names.select (0);
private void insert ()
// Create an Insert data entry form to enter information
// for a new contact.
DataEntryForm def = new DataEntryForm (this, "Insert");
// If the bOk Boolean flag is set, this indicates the user
// exited the form by pressing the Ok button.
if (def.bOk)
// Create a Customer object and assign information from
// the form to its fields.
Customer temp = new Customer ();
temp.name = new String (def.name.getText ());
temp.publication = new String (def.publication.getText ());
temp.address = new String (def.address.getText ());
temp.round = new String (def.round.getText ());
temp.phone = new String
          (def.phone.getText ());
// Add a new customer item to the names component.
names.add (temp.publication + ", " + temp.address);
// Add the Customer object to the contacts Vector
// object.
customers.add (temp);
// Make sure that the Delete and Update buttons are
// enabled.
delete.setEnabled (true);
update.setEnabled (true);
// Destroy the dialog box.
def.dispose ();
// Make sure that the first customer item in the names list
// is highlighted.
names.select (0);
// ===========================================================
// Load all customers from customers.dat into the customers
// Vector object. Also, make sure that the last name/first
// name from each contact is combined into a String object and
// inserted into the names component - as a contact item.
// ===========================================================
private void loadCustomers ()
FileInputStream fis = null;
try
fis = new FileInputStream ("customers.dat");
DataInputStream dis = new DataInputStream (fis);
int nCustomers = dis.readInt ();
for (int i = 0; i < nCustomers; i++)
Customer temp = new Customer ();
temp.name = dis.readUTF ();
temp.publication = dis.readUTF ();
temp.address = dis.readUTF ();
temp.round = dis.readUTF ();
temp.phone = dis.readUTF ();
names.add (temp.publication + ", " + temp.address);
customers.add (temp);
if (nCustomers > 0)
delete.setEnabled (true);
update.setEnabled (true);
catch (IOException e)
finally
if (fis != null)
try
fis.close ();
catch (IOException e) {}
// Make sure that the first customer item in the names list
// is highlighted.
names.select (0);
// ========================================================
// Save all customer objects from the contacts Vector object
// to customers.dat. The number of contacts are saved as an
// int to make it easy for loadCustomers () to do its job.
// ========================================================
private void saveCustomers ()
FileOutputStream fos = null;
try
fos = new FileOutputStream ("customers.dat");
DataOutputStream dos = new DataOutputStream (fos);
dos.writeInt (customers.size ());
for (int i = 0; i < customers.size (); i++)
Customer temp = (Customer) customers.elementAt (i);
dos.writeUTF (temp.name);
dos.writeUTF (temp.publication);
dos.writeUTF (temp.address);
dos.writeUTF (temp.round);
dos.writeUTF (temp.phone);
catch (IOException e)
MsgBox mb = new MsgBox (this, "PP Error",
e.toString ());
mb.dispose ();
finally
if (fos != null)
try
fos.close ();
catch (IOException e) {}
private void update ()
// Obtain index of selected customer item from the names
// component.
int index = names.getSelectedIndex ();
// If no item was selected, index is -1. We cannot update
// a customer if no customer item in the names component was
// selected - because we would have nothing to work with.
if (index != -1)
// Obtain a reference to the Customer object (from the
// customer Vector object) that is associated with the
// index.
Customer temp = (Customer) customers.elementAt (index);
// Create and display an update entry form.
DataEntryForm def = new DataEntryForm (this, "Update",
temp.name,
temp.publication,
temp.address,
temp.round,
temp.phone);
// If the user pressed Ok...
if (def.bOk)
// Update the customer information in the customers
// Vector object.
temp.name = new String (def.name.getText ());
temp.publication = new String (def.publication.getText ());
temp.address = new String (def.address.getText ());
temp.round = new String (def.round.getText ());
temp.phone = new String (def.phone.getText ());
// Make sure the screen reflects the update.
names.replaceItem (temp.publication + ", " + temp.address,
index);
// Destroy the dialog box.
def.dispose ();
// Make sure that the first customer item in the names
// list is highlighted.
names.select (0);
// ========================================================
// Class: Customer
// This class describes the contents of a business customer.
// ========================================================
class Customer
public String name;
public String publication;
public String address;
public String round;
public String phone;
// ==========================================================
// Class: DataEntryForm
// This class provides a data entry form for entering customer
// information.
// ==========================================================
class DataEntryForm extends JDialog implements ActionListener
// bOk is a boolean flag. When true, it indicates that
// the Ok button was pressed to terminate the dialog box
// (as opposed to the Cancel button).
public boolean bOk;
// The following components hold the text that the user
// entered into the visible text fields.
public JTextField name;
public JTextField publication;
public JTextField address;
public JTextField round;
public JTextField phone;
public void actionPerformed (ActionEvent e)
// If the user pressed the Ok button, indicate this
// by assigning true to bOk.
if (e.getActionCommand ().equals ("Ok"))
bOk = true;
// Destroy the dialog box and return to the point
// just after the creation of the DataEntryForm object.
dispose ();
public DataEntryForm (JFrame parent, String title)
// Call the other constructor. The current constructor
// is used for insert operations. The other constructor
// is used for update operations.
this (parent, title, "", "", "", "", "");
public DataEntryForm (JFrame parent, String title,
String name, String publication,
String address, String round,
String phone)
// Initialize the superclass layer.
super (parent, title, true);
// Choose a grid bag layout so that components can be more
// accurately positioned. (It looks nicer.)
setLayout (new GridBagLayout ());
// Add appropriate first name, last name, phone, fax, and
// email components to the current DataEntryForm container.
// (Remember, DataEntryForm is a subclass of Dialog.
// Dialog is a container. Therefore, DataEntryForm
// inherits the ability to be a container.)
addComponent (this, new JLabel ("Name: "), 0, 0, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.WEST);
this.name = new JTextField (15);
addComponent (this, this.name, 1, 0, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.CENTER);
if (title.equals ("Update"))
this.name.setText (name);
addComponent (this, new JLabel ("Publications: "), 0, 1, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.WEST);
this.publication = new JTextField (15);
addComponent (this, this.publication, 1, 1, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.CENTER);
if (title.equals ("Update"))
this.publication.setText (publication);
addComponent (this, new JLabel ("Address "), 0, 2, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.WEST);
this.address = new JTextField (15);
addComponent (this, this.address, 1, 2, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.CENTER);
if (title.equals ("Update"))
this.address.setText (address);
addComponent (this, new JLabel ("Round No "), 0, 3, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.WEST);
this.round = new JTextField (15);
addComponent (this, this.round, 1, 3, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.CENTER);
if (title.equals ("Update"))
this.round.setText (round);
addComponent (this, new JLabel ("Phone Number "), 0, 4, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.WEST);
this.phone = new JTextField (15);
addComponent (this, this.phone, 1, 4, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.CENTER);
if (title.equals ("Update"))
this.phone.setText (phone);
addComponent (this, new JLabel (""), 0, 5, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.CENTER);
addComponent (this, new JLabel (""), 1, 5, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.CENTER);
JButton b;
// Add an Ok button to this container.
addComponent (this, b = new JButton ("Ok"), 0, 6, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.CENTER);
b.addActionListener (this);
// Add a Cancel button to this container.
addComponent (this, b = new JButton ("Cancel"), 1, 6, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.CENTER);
b.addActionListener (this);
// Set the size of the dialog window to 250 pixels
// horizontally by 200 pixels vertically.
setSize (250, 200);
// Do not allow users to resize the dialog window.
setResizable (false);
// Make sure that the dialog window is visible.
setVisible (true);
private void addComponent (Container con, Component com,
int gridx, int gridy,
int gridw, int gridh, int fill,
int anchor)
// Get the current layout manager. It is assumed to
// be a GridBagLayout object.
LayoutManager lm = con.getLayout ();
// Create a GridBagConstraints object to make it
// possible to customize component positioning.
GridBagConstraints gbc = new GridBagConstraints ();
// Assign the x and y grid positions.
gbc.gridx = gridx;
gbc.gridy = gridy;
// Assign the number of grid blocks horizontally and
// vertically that are occupied by the component.
gbc.gridwidth = gridw;
gbc.gridheight = gridh;
// Specify the component's resize policy (fill) and
// the direction in which the component is positioned
// when its size is smaller than available space (anchor).
gbc.fill = fill;
gbc.anchor = anchor;
// Set the new constraints that the grid bag layout
// manager will use.
((GridBagLayout) lm).setConstraints (com, gbc);
// Add the component to the container.
con.add (com);
// ===========================================================
// Class: MsgBox
// This class displays a message box to the user. The message
// is usually an error message. The user must press the Ok
// button to terminate the message box.
// ===========================================================
class MsgBox extends JDialog implements ActionListener
public void actionPerformed (ActionEvent e)
// Terminate the dialog box in response to the user
// pressing the Ok button.
dispose ();
public MsgBox (JFrame parent, String title, String msg)
// Initialize the superclass layer.
super (parent, title, true);
// Store the msg argument in a Label object and add
// this object to the center part of the dialog window.
JLabel l = new JLabel (msg);
add ("Center", l);
// Create a Button object and add it to the south part
// of the dialog window.
JButton b = new JButton ("Ok");
add ("South", b);
// Make the current object a listener to events that
// occur as a result of the user pressing the Ok
// button.
b.addActionListener (this);
// Make sure that the Ok button has the focus.
b.requestFocus ();
// Do not allow users to resize the dialog window.
setResizable (false);
// Allow the layout manager to choose an appropriate
// size for the dialog window.
pack ();
// Make sure that the dialog window is visible.
setVisible (true);
}

Similar Messages

  • Difference between awt ang Swing Interview Question n other Question

    hi every one i use to think that i know java atlest so much that i can crack a lolcal comp interview but ........................
    i ansered few Question but was speachlees when was asked few of this i do not remember all of them
    1] difference between awt and swing.
    2]System.out.println();
    System is a class out is a variable so who come a variable calling a method.
    3]are constractor inherateed in java.

    1] difference between awt and swing.AWT is based on an abstraction of platform-specific, heavy-weight components. Swing is written entirely in java.
    >
    2]System.out.println();
    System is a class out is a variable so who come a
    variable calling a method.Do you mean how come?
    In that case, the answer is simple: Because out is a variable, it can be redirected/compared against, etc much easier
    3]are constractor inherateed in java.Kind of a trick question, as the answer is yes and no. Constructors are not inherited, but every constructor in the subclass must call one and exactly one constructor of the superclass

  • What are the differences between Applet and Swings

    Please let me know the differences between Applet and Swings.

    Quit cross-posting.
    http://forum.java.sun.com/thread.jspa?threadID=755100
    http://forum.java.sun.com/thread.jspa?threadID=755099
    http://forum.java.sun.com/thread.jspa?threadID=755006

  • Difference Between Applet and Swing

    Difference Between Applet and Swing

    The advantages and disadvantages of both applets and Swing are the small fluffy elephants you get inside of every box. They're quite well trained and can skeletonize your neighbors' annoying pets upon command.

  • Difference between AWT,Swing and swt

    Hello,
    I am giving a seminar about swing in which I need to point out differences between AWT,Swing and SWT(Software Widget Tool).
    I have two questions:
    1)I read that-A heavyweight component is one that is associated with its own native screen resource (commonly known as a peer). A lightweight component is one that "borrows" the screen resource of an ancestor-which makes it lighter.Can anybody explain What native screen resource is and how it is borrowed?
    2)I read that SWT uses native widgets and how can it be better than swing?If it is in what way?

    Use Swing for new projects. AWT is the rendering layer underneath Swing in many cases, and AWT provides utility things like Graphics. SWT is an alternative to Swing which used more native rendering, but actually with Java 6, Swing is using a lot of native rendering.
    Fire up NetBeans and use Matisse. Build an application. Run it under Windows, and then under Linux, and then realize how great it is.

  • Difference between JFrame and JApplet

    i would like to create a GUI using java. as what i know, either i can use the normal applet or java swing. may i know what is the difference between 2 of them??
    thanks

    Hello thanku,
    You have asked two completely different questions:
    1) What is the difference between JFrame and JApplet?
    2) What is the difference between Applet and JApplet?
    A Java applet is a program that adheres to a set of conventions that allows it to run within a Java-compatible browser. To create a Java applet you may either use Applet or JApplet. If you are not running with in a browser, that is, if you are creating an application, you need to use a Frame or JFrame.
    Applet is the old way of creating a Java applet. It is better to use JApplet, since JApplet has all the functionality of Applet and more. Please note that you should not mix AWT components with Swing components.
    -Merwyn,
    Developer Technical Support,
    http://www.sun.com/developers/support.

  • What's the difference between paint and paintComponent?

    can any body tell me the difference between paint and paintComponent?and when i should use paint and when use paintComponent?
    I know that when I use repaint,it will clear all the objects and then paint again?
    is there a method similar to repaint?
    thanks in advance!

    and when i should use paint and when use paintComponent?Simple answer:
    a) override paint() when doing custom painting on an AWT component
    b) override paintComponent() when doing custom painting on a Swing component
    Detailed answer:
    Read the article on [url http://java.sun.com/products/jfc/tsc/articles/painting/index.html]Painting in AWT and Swing.
    Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/14painting/index.html]Custom Painting.

  • What's the difference between jsp and jsf?

    who can tell me what's the difference between jsp and jsf?
    I'm puzzled when I found some of the technology in jsp is so similar to the ones in jsp( javaserver page)

    Hi,
    Find the difference between JSP and JSF
    1. A developer has more control with JSP, but (should) get easier development with JSF
    2. Event handling is done differently in JSP (HTTP) and JSF (Java)
    3. The UI is designed differently (or should be at least) with JSP (markup) and JSF (components).
    4. The end product should also be defined differently - JSP page versus a JSF application.
    Is this the only thing that is need to make a decision for either or? Probably not. There are other pieces that need to be taken in account when deciding which technology to use - tools support, enough components, type of application etc.... At this point there are not enough JSF components (although there are some interesting projects underway - Ajaxfaces, Myfaces, ADF Faces, and WebChart 3d) and enterprise tools support is still limited to a few tools vendor. Looking at our ADF Faces components they are currently available as early access (not production) and demands for these components are stacking up, literally, outside my office doorstep. Although I would love to make them production - now! - it is not a viable solution since we are still checking features and fixing critical bugs.
    All this combined - not enough enterprise level components in production, lacking tools support etc... - leave customers in a vacuum where the decision is either to continue with JSP, since it is mature and has a wide developer base, or move forward with JSF not sure if the support, or the developers will be there. This is particularly sensitive to customers that need to get started now and be production by summer.
    If you are in this vacuum here are some key points promoting JSF:
    1. Fundamental unit is the Component
    2. Built in event and state management
    3. Component sets can be provided by any vendor
    4. Closer to ASP.Net or Swing development
    5. Choice of UI technology
    6. Scale up (rich clients)
    7. Scale down (mobile devices)
    8. Built into J2EE containers in J2EE 5.0 (tentative)

  • Difference between J2SE and J2EE...

    Hi all. I was wondering what the difference between J2SE and J2EE were. I mean in the code structure. Are the packages the same, like Swing, IO, things like that. I'm a bit of a beginner in Java, only been messing around with it for about 6 months now kind of in my spare time, and I know I'm in now way ready for J2EE, but it's something I think I'd like to maybe look into. I know it's for Enterprise Applications, much bigger scale than I'm used to, but fundamentally, how is it different? Different coding conventions? New packages not in J2SE? I hope what I want is coming across okay. Thanks for all the input.
    James

    J2EE defines a large number of specifications, in addition to J2SE. Examples are the Servlet, JSP, JMS, and EJB specifications. Most of those specifications are designed to have implementations running inside an Application Server. There are free implementations available such as JBoss (combined with for example Tomcat), and I think youre best bet to learn is to download one of those and go from there. Servlets and JSP are a good beginning, and then maybe move on to EJB and the rest.
    Br - J

  • Difference between implements and extends

    Hi all,
    what is the difference between implements and extends. i am sorry to ask this silly question, but i am new to JAVA.
    Thanks
    Balaji

    when you extend a class, your class that you are coding inherits every method and field from the extending class. For example:
    public class CustomFrame extends JFrame {
    //Your class's methods will be in here, but so will all of JFrame's methods.
    }You can override (most) methods from extended classes if you want them to do different things than they normally do. The most commonly overriden methods when using swing are stuff like paint(Graphics g). It needs to be overriden to repaint all of the components.
    When you imlpement something, you have to specify an interface. Interfaces have methods in them with no code. If you implement an interface, all methods in in must be defined. If not, the code will not compile. Some interfaces like ActionListener extend other classes to perform stuff. The actionPerformed(ActionEvent e) method will perform an action when a button is pressed, etc.

  • Sync Performance difference between AWT & JSP MI application

    Hello,
    I would like to know, if there are any performance differences, when I sync from AWT Smart Sync MI application compared to JSP Smart Sync Mi Application?
    Thanks & regards,
    Purnima

    Hi Purnima,
    the sync logic for the MI AWT client and the JSP client is identical, so the performance is expected to be equal.
    During the sync the "sand clock" page is displayed. This is done in the corresponding UI technology and here a slight differnce of resource consumption is there between AWT and JSP (JSP --> Browser rendering, periodic pull;). The resources consumed by this user interaction (processor time, memory) can not be used for inbound data processing etc. and therefore a slight difference in synchronization performance could come up. Though I do not expect recognizable differences (from an end user perspective...) due to this.
    Rgds Thomas

  • Difference between Null and null?

    What is the difference between null and NULL?
    When is each used?
    Thanks,

    veryConfused wrote:
    There is a null in java, but no NULL. null means no value. However, when assigning value, the following is different:Although the empty String has no special role. Null means, the referential type is not assigned (doesn't refer) to a specific object. The empty String is just another object though, so seeing it or pointing it out as something special when it actually isn't at all (no more special than new Integer(0) or new Object[0]) just adds to the confusion.

  • Difference between GUI_UPLOAD and WS_UPLOAD

    Hi,
    Please make me clear about the difference between GUI_UPLOAD and WS_UPLOAD. In which cases we need to use these modules...??
    Thanks,
    Satish

    I would suggest to always use the GUI_UPLOAD.  I say this because this is the function module which is used in the GUI_UPLOAD method of the class CL_GUI_FRONTEND_SERVICES.   Really, you should probably use the class/method instead of the function module.
      data: filename type string.
      filename = p_file.
      call method cl_gui_frontend_services=>gui_upload
             exporting
                  filename                = filename
                  filetype                = 'ASC'
             changing
                  data_tab                = iflatf
             exceptions
                  file_open_error         = 1
                  file_read_error         = 2
                  no_batch                = 3
                  gui_refuse_filetransfer = 4
                  no_authority            = 6
                  unknown_error           = 7
                  bad_data_format         = 8
                  unknown_dp_error        = 12
                  access_denied           = 13
                  others                  = 17.
    Regards,
    Rich Heilman

  • Difference between char and varchar, also the difference between varchar2

    Hi,
    Can anyone explain me the difference between char and varchar, and also the difference between varchar and varchar2...

    Varchar2 is variable width character data type, so if you define column with width 20 and insert only one character to tis column only, one character will be stored in database. Char is not variable width so when you define column with width 20 and insert one character to this column it will be right padded with 19 spaces to desired length, so you will store 20 characters in the dattabase (follow the example 1). Varchar data type from Oracle 9i is automaticlly promoted to varchar2 (follow example 2)
    Example 1:
    SQL> create table tchar(text1 char(10), text2 varchar2(10))
    2 /
    Table created.
    SQL> insert into tchar values('krystian','krystian')
    2 /
    1 row created.
    SQL> select text1, length(text1), text2, length(text2)
    2 from tchar
    3 /
    TEXT1 LENGTH(TEXT1) TEXT2 LENGTH(TEXT2)
    krystian 10 krystian 8
    Example 2:
    create table tvarchar(text varchar(10))
    SQL> select table_name,column_name,data_type
    2 from user_tab_columns
    3 where table_name = 'TVARCHAR'
    4 /
    TABLE_NAME COLUMN_NAME DATA_TYPE
    TVARCHAR TEXT VARCHAR2
    Best Regards
    Krystian Zieja / mob

  • The difference between Lion and Mountain Lion

    Can some one explain to me the difference between Lion and Mtn Lion? I'm currently 10.6.8 Is it beneficiall for me to upgrade?

    Mountain Lion is an enhanced version of previous OS X and so that is Mavericks.
    About upgrading it all depends on what your needs are and if your hardware supports it.
    System requirements for OS X Lion
    System requirements for OS X Mountain Lion
    OS X Mavericks: System Requirements
    Please check also applications compatibility. From Lion onward, you cannot run PPC application.

Maybe you are looking for

  • No sticker with license number Windows XP to Toshiba NB100

    I lost sticker with license number Windows XP to Toshiba NB100. I have an invoice. How can I retrieve licence number? Authorized service refused to support this topic.

  • Itune wont open different prob.

    well on the other thread i tryed everything and stuff and now i got dis ...i also done malware scan and other things u guys say to do here a screenie of the messenge i got http://img40.imageshack.us/img40/4300/itune9gt.png plz help

  • Pre Order Issue Madden 15 - no preorder bonus

    I did not receive the pre order bonus for madden 15. What are my options when the CS rep messed up the transaction. I picked up the game instore (4hrs ago) and the bonus did not show up on the recepit and i have not recieved an email. I originally  t

  • How to use MAF libraries

    Dear, I'm going to replace controls by MAF in my android application. I import libraries: - mafuicomponents-1.2.1.jar - maftreeview-1.2.1.jar - mafsettingscreen-1.2.1.jar - maflocaleawarecontrols-1.2.1.jar - mafcalendar-1.2.1.jar I created an simple

  • IMac - can it work with 2 people using different user names?

    My wife and I each have IPhone and IPad.  We are buying a new IMac.  We have different user names.  Will we both be able to download pictures but keep our email and messages separate?