help plz ... Building GUI

can you help me please?

My code Purpose witch allows me to store keys and objects In the hashtable

A dealer maintains a list (hash table) of cars for sale. The first column in the table will contain VRN numbers and the second column Car4Sale objects

here is the code:

import javax.swing.*;

import java.io.*;

import java.awt.*;

import java.awt.event.*;

import javax.swing.border.*;

import java.util.*;

publicclass BuyCarextends JFrameimplements ActionListener

{

JPanel panel;

JTextField jt_IName,jt_ICode,jt_Price,jt_color,jt_Sprice;//TEXT BOXES

JButton btn_Add,btn_Cancel;//BUTTONS

JLabel lbl_IName,lbl_ICode,lbl_Price,lbl_color,lbl_Sprice;// LABELS

public BuyCar()

{

super("Buy-New Car");// WINDOW TITLE

panel=new JPanel();

panel.setLayout(null);

//LABELS DEFINITIONS

lbl_IName=new JLabel("VRN No :");

lbl_ICode=new JLabel("Manufacturer :");

lbl_Price=new JLabel("Engine Size :");

lbl_color=new JLabel("Color :");

lbl_Sprice=new JLabel("Price :");

//TEXTBOXES DEFINITION

jt_IName=new JTextField();

jt_ICode=new JTextField();

jt_Price=new JTextField();

jt_color=new JTextField();

jt_Sprice=new JTextField();

//BUTTONS DEFINITION

btn_Add=new JButton("ADD");

btn_Add.addActionListener(this);

btn_Cancel=new JButton("CANCEL");

btn_Cancel.addActionListener(this);

//SET THE SIZE & LOCATION

lbl_IName.setBounds(15,20,180,20);

jt_IName.setBounds(100,20,150,20);

lbl_ICode.setBounds(15,45,180,20);

jt_ICode.setBounds(100,45,150,20);

lbl_Price.setBounds(15,70,180,20);

jt_Price.setBounds(100,70,150,20);

lbl_color.setBounds(15,95,180,20);

jt_color.setBounds(100,95,150,20);

lbl_Sprice.setBounds(15,120,180,20);

jt_Sprice.setBounds(100,120,150,20);

btn_Add.setBounds(80,180,60,20);

btn_Cancel.setBounds(150,180,80,20);

//ADD ALL FIELDS TO PANEL

panel.add(lbl_IName);

panel.add(jt_IName);

panel.add(lbl_ICode);

panel.add(jt_ICode);

panel.add(lbl_Price);

panel.add(jt_Price);

panel.add(lbl_color);

panel.add(jt_color);

panel.add(lbl_Sprice);

panel.add(jt_Sprice);

panel.add(btn_Add);

panel.add(btn_Cancel);

//SET PANEL PROPERTIES

panel.setBackground(new Color(169,202,223));

panel.setBorder(new BevelBorder(BevelBorder.RAISED));

//SET WINDOW PROPERTIES

getContentPane().add(panel,BorderLayout.CENTER);

setLocation(200,200);

setSize(400,300);

setVisible(true);

setResizable(false);

}

publicvoid actionPerformed(ActionEvent e)

{

Object comm=e.getSource();

// CLICK ADD BUTTON

if(comm==btn_Add)

{

String str_SName,str_SCode,str_SPrice;

//ASSIGN THE VALUES TO VARIABLES

str_SName=jt_IName.getText();

str_SCode=jt_ICode.getText();

str_SPrice=jt_Price.getText();

//CHECK WHETHER THE VALUE IS NULL OR NOT

if(str_SName.equals(""))

{

JOptionPane.showMessageDialog(null,"Enter Var Number","ERROR",JOptionPane.ERROR_MESSAGE);

jt_IName.requestFocus();

}

elseif(str_SCode.equals(""))

{

JOptionPane.showMessageDialog(null,"Enter Manuacrer Name","ERROR",JOptionPane.ERROR_MESSAGE);

jt_ICode.requestFocus();

}

elseif(str_SPrice.equals(""))

{

JOptionPane.showMessageDialog(null,"Enter Engine Size","ERROR",JOptionPane.ERROR_MESSAGE);

jt_Price.requestFocus();

}

else

{

try

{}

catch(Exception se)

{

//System.out.print(se.toString());

}

}

}

elseif(comm==btn_Cancel)

{

dispose();// CLOSE THE WINDOW

}

}

publicstaticvoid main (String [] args){

new BuyCar();

}

}

when I click the Add "button", the Var No and Car object shoud be added to the hashtable which consist a list of cars and thier Var No...

the Var No will be the Key.

I should add another button "View". When I click this button the car list (hashtable) should

be displayed on the screen

How can I do the hashtable in the GUI...

How can I Add and delete from hashtable.

thanks

[7590 byte] By [Zaabio_dubaia] at [2007-11-26 19:56:42]
# 1

If you need to use Hashtable, use the Adapter design pattern to wrap it as a TableModel, then display it in a JTable. Otherwise, just use a DefaultTableModel instead of a Hashtable.

Googling for any of the above, plus the phrase "how to use tables," should give you plenty of information.

itchyscratchya at 2007-7-9 22:50:58 > top of Java-index,Desktop,Core GUI APIs...
# 2
please, Can I have more replies......!!!!!!!!
Zaabio_dubaia at 2007-7-9 22:50:58 > top of Java-index,Desktop,Core GUI APIs...
# 3
you have the answer, if you're after someone to write it for you, try rent-a-coder
Michael_Dunna at 2007-7-9 22:50:58 > top of Java-index,Desktop,Core GUI APIs...
# 4
> please, Can I have more replies......!!!!!!!! You have already been given a good answwer so why do you need more replies?
camickra at 2007-7-9 22:50:58 > top of Java-index,Desktop,Core GUI APIs...