Help Plz! AWT to Swing Conversion

Hey everyone, I'm new to java and trying to convert this AWT program to Swing, I got no errors, the menu shows but they dont work !! Could somebody please help me? thanks alot!
Current Under-Construction Code: (no errors)
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class zipaint extends JFrame implements ActionListener,      ItemListener,
MouseListener, MouseMotionListener, WindowListener {
static final int WIDTH = 800;     // Sketch pad width
static final int HEIGHT = 600;     // Sketch pad height
int upperLeftX, upperLeftY;     // Rectangle upper left corner coords.
int width, height;          // Rectangle size
int x1, y1, x2, y2, x3, y3, x4, y4; // Point coords.
boolean fillFlag = false; //default filling option is empty
boolean eraseFlag = false; //default rubber is off
String drawColor = new String("black"); //default drawing colour is black
String drawShape = new String("brush"); //default drawing option is brush
Image background; //declear image for open option
private FileDialog selectFile = new FileDialog( this,
"Select background (.gif .jpg)",
FileDialog.LOAD );
// Help
String helpText = "Draw allows you to sketch different plane shapes over a " +
"predefined area.\n" + "A shape may be eother filled or in outline, " +
"and in one of eight different colours.\n\n" + "The position of the " +
"mouse on the screen is recorded in the bottom left-hand corner of the " +
"drawing area. The choice of colour and shape are disoplayed also in the " +
"left-habnd corner of the drawing area.\n\n" + "The size of a shape is " +
"determined by the mouse being dragged to the final position and " +
"released. The first click of the mouse will generate a reference dot on " +
"the screen. This dot will disapear after the mouse button is released.\n\n" +
"Both the square and the circle only use the distance measured along the " +
"horizontal axis when determining the size of a shape.\n\n" + "Upon " +
"selecting erase, press the mouse button, and move the mouse over the " +
"area to be erased. releasing the mouse button will deactivate erasure.\n\n" +
"To erase this text area choose clearpad from the TOOLS menu.\n\n";
// Components
JTextField color = new JTextField();
JTextField shape = new JTextField();
JTextField position = new JTextField();
CheckboxGroup fillOutline = new CheckboxGroup();
JTextArea info = new JTextArea(helpText,0,0/*,JTextArea.JSCROLLBARS_VERTICAL_ONLY*/);
JFrame about = new JFrame("About Zi Paint Shop");
// Menues
String[] fileNames = {"Open","Save","Save as","Exit"};
String[] colorNames = {"black","blue","cyan","gray","green","magenta","red","white","yellow"};
String[] shapeNames = {"brush","line","square","rectangle","circle","ellipse"};
String[] toolNames = {"erase","clearpad"};
String[] helpNames = {"Help","about"};
public zipaint(String heading) {
super(heading);
getContentPane().setBackground(Color.white);
getContentPane().setLayout(null);
/* Initialise components */
initialiseTextFields();
initializeMenuComponents();
initializeRadioButtons();
addWindowListener(this);
addMouseListener(this);
addMouseMotionListener(this);
/* Initialise Text Fields */
private void initialiseTextFields() {
// Add text field to show colour of figure
color.setLocation(5,490);
color.setSize(80,30);
color.setBackground(Color.white);
color.setText(drawColor);
getContentPane().add(color);
// Add text field to show shape of figure
shape.setLocation(5,525);
shape.setSize(80,30);
shape.setBackground(Color.white);
shape.setText(drawShape);
getContentPane().add(shape);
// Add text field to show position of mouse
position.setLocation(5,560);
position.setSize(80,30);
position.setBackground(Color.white);
getContentPane().add(position);
// Set up text field for help
info.setLocation(150,250);
info.setSize(500,100);
info.setBackground(Color.white);
info.setEditable(false);
private void initializeMenuComponents() {
// Create menu bar
JMenuBar bar = new JMenuBar();
// Add colurs menu
JMenu files = new JMenu("Files");
for(int index=0;index < fileNames.length;index++)
files.add(fileNames[index]);
bar.add(files);
files.addActionListener(this);
// Add colurs menu
JMenu colors = new JMenu("COLORS");
for(int index=0;index < colorNames.length;index++)
colors.add(colorNames[index]);
bar.add(colors);
colors.addActionListener(this);
// Add shapes menu
JMenu shapes = new JMenu("SHAPES");
for(int index=0;index < shapeNames.length;index++)
shapes.add(shapeNames[index]);
bar.add(shapes);
shapes.addActionListener(this);
// Add tools menu
JMenu tools = new JMenu("TOOLS");
for(int index=0;index < toolNames.length;index++)
tools.add(toolNames[index]);
bar.add(tools);
tools.addActionListener(this);
// Add help menu
JMenu help = new JMenu("HELP");
for(int index=0;index < helpNames.length;index++)
help.add(helpNames[index]);
bar.add(help);
help.addActionListener(this);
// Set up menu bar
setJMenuBar(bar);
/* Initilalise Radio Buttons */
private void initializeRadioButtons() {
// Define checkbox
Checkbox fill = new Checkbox("fill",fillOutline,false);
Checkbox outline = new Checkbox("outline",fillOutline,true);
// Fill buttom
fill.setLocation(5,455);
fill.setSize(80,30);
getContentPane().add(fill);
fill.addItemListener(this);
// Outline button
outline.setLocation(5,420);
outline.setSize(80,30);
getContentPane().add(outline);
outline.addItemListener(this);
/* Action performed. Detects which item has been selected from a menu */
public void actionPerformed(ActionEvent e) {
Graphics g = getGraphics();
String source = e.getActionCommand();
// Identify chosen colour if any
for (int index=0;index < colorNames.length;index++) {
if (source.equals(colorNames[index])) {
drawColor = colorNames[index];
color.setText(drawColor);
return;
// Identify chosen shape if any
for (int index=0;index < shapeNames.length;index++) {
if (source.equals(shapeNames[index])) {
drawShape = shapeNames[index];
shape.setText(drawShape);
return;
// Identify chosen tools if any
if (source.equals("erase")) {
eraseFlag= true;
return;
else {
if (source.equals("clearpad")) {
remove(info);
g.clearRect(0,0,800,600);
return;
if (source.equals("Open")) {
selectFile.setVisible( true );
if( selectFile.getFile() != null )
String fileLocation = selectFile.getDirectory() + selectFile.getFile();
background = Toolkit.getDefaultToolkit().getImage(fileLocation);
paint(getGraphics());
if (source.equals("Exit")) {
System.exit( 0 );
// Identify chosen help
if (source.equals("Help")) {
getContentPane().add(info);
return;
if (source.equals("about")) {
displayAboutWindow(about);
return;
public void paint(Graphics g)
super.paint(g);
if(background != null)
Graphics gc = getGraphics();
gc.drawImage( background, 0, 0, this.getWidth(), this.getHeight(), this);
/* Dispaly About Window: Shows iformation aboutb Draw programme in
separate window */
private void displayAboutWindow(JFrame about) {
about.setLocation(300,300);
about.setSize(350,160);
about.setBackground(Color.cyan);
about.setFont(new Font("Serif",Font.ITALIC,14));
about.setLayout(new FlowLayout(FlowLayout.LEFT));
about.add(new Label("Author: Zi Feng Yao"));
about.add(new Label("Title: Zi Paint Shop"));
about.add(new Label("Version: 1.0"));
about.setVisible(true);
about.addWindowListener(this);
// ----------------------- ITEM LISTENERS -------------------
/* Item state changed: detect radio button presses. */
public void itemStateChanged(ItemEvent event) {
if (event.getItem() == "fill") fillFlag=true;
else if (event.getItem() == "outline") fillFlag=false;
// ---------------------- MOUSE LISTENERS -------------------
/* Blank mouse listener methods */
public void mouseClicked(MouseEvent event) {}
public void mouseEntered(MouseEvent event) {}
public void mouseExited(MouseEvent event) {}
/* Mouse pressed: Get start coordinates */
public void mousePressed(MouseEvent event) {
// Cannot draw if erase flag switched on.
if (eraseFlag) return;
// Else set parameters to 0 and proceed
upperLeftX=0;
upperLeftY=0;
width=0;
height=0;
x1=event.getX();
y1=event.getY();
x3=event.getX();
y3=event.getY();
Graphics g = getGraphics();
displayMouseCoordinates(x1,y1);
public void mouseReleased(MouseEvent event) {
Graphics g = getGraphics();
// Get and display mouse coordinates
x2=event.getX();
y2=event.getY();
displayMouseCoordinates(x2,y2);
// If erase flag set to true reset to false
if (eraseFlag) {
eraseFlag = false;
return;
// Else draw shape
selectColor(g);
if (drawShape.equals("line")) g.drawLine(x1,y1,x2,y2);
else if (drawShape.equals("brush"));
else drawClosedShape(drawShape,g);
/* Display Mouse Coordinates */
private void displayMouseCoordinates(int x, int y) {
position.setText("[" + String.valueOf(x) + "," + String.valueOf(y) + "]");
/* Select colour */
private void selectColor(Graphics g) {
for (int index=0;index < colorNames.length;index++) {
if (drawColor.equals(colorNames[index])) {
switch(index) {
case 0: g.setColor(Color.black);break;
case 1: g.setColor(Color.blue);break;
case 2: g.setColor(Color.cyan);break;
case 3: g.setColor(Color.gray);break;
case 4: g.setColor(Color.green);break;
case 5: g.setColor(Color.magenta);break;
case 6: g.setColor(Color.red);break;
case 7: g.setColor(Color.white);break;
default: g.setColor(Color.yellow);
/* Draw closed shape */
private void drawClosedShape(String shape,Graphics g) {
// Calculate correct parameters for shape
upperLeftX = Math.min(x1,x2);
upperLeftY = Math.min(y1,y2);
width = Math.abs(x1-x2);
height = Math.abs(y1-y2);
// Draw appropriate shape
if (shape.equals("square")) {
if (fillFlag) g.fillRect(upperLeftX,upperLeftY,width,width);
else g.drawRect(upperLeftX,upperLeftY,width,width);
else {
if (shape.equals("rectangle")) {
if (fillFlag) g.fillRect(upperLeftX,upperLeftY,width,height);
else g.drawRect(upperLeftX,upperLeftY,width,height);
else {
if (shape.equals("circle")) {
if (fillFlag) g.fillOval(upperLeftX,upperLeftY,width,width);
else g.drawOval(upperLeftX,upperLeftY,width,width);
else {
if (fillFlag) g.fillOval(upperLeftX,upperLeftY,width,height);
else g.drawOval(upperLeftX,upperLeftY,width,height);
/* Mouse moved */
public void mouseMoved(MouseEvent event) {
displayMouseCoordinates(event.getX(),event.getY());
/* Mouse dragged */
public void mouseDragged(MouseEvent event) {
Graphics g = getGraphics();
x2=event.getX();
y2=event.getY();
x4=event.getX();
y4=event.getY();
displayMouseCoordinates(x1,y1);
if (eraseFlag) g.clearRect(x2,y2,10,10);
else {
selectColor(g);
if(drawShape.equals("brush")) g.drawLine(x3,y3,x4,y4);
x3 = x4;
y3 = y4;
// ---------------------- WINDOW LISTENERS -------------------
/* Blank methods for window listener */
public void windowClosed(WindowEvent event) {}
public void windowDeiconified(WindowEvent event) {}
public void windowIconified(WindowEvent event) {}
public void windowActivated(WindowEvent event) {}
public void windowDeactivated(WindowEvent event) {}
public void windowOpened(WindowEvent event) {}
/* Window Closing */
public void windowClosing(WindowEvent event) {
if (event.getWindow() == about) {
about.dispose();
return;
else System.exit(0);
Code End
Thanks again!
class ziapp {
/* Main method */
public static void main(String[] args) {
zipaint screen = new zipaint("Zi Paint Shop");
screen.setSize(zipaint.WIDTH,zipaint.HEIGHT);
screen.setVisible(true);

First of all use the [url http://forum.java.sun.com/features.jsp#Formatting]Formatting Tags when posting code to the forum. I'm sure you don't code with every line left justified so we don't want to read unformatted code either.
Hey everyone, I'm new to java and trying to convert this AWT program to SwingInstead of converting the whole program, start with something small, understand how it works and then convert a different part of the program. You can start by reading this section from the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html]How to Use Menus.
From a quick glance of your code it looks like you are not adding an ActionListener to your JMenuItems. You are adding them to the JMenu.
Other observations:
1) Don't mix AWT with Swing components. You are still using CheckBox
2) Don't override paint(). When using Swing you should override paintComponent();
3) Use LayoutManagers. Using a null layout does not allow for easy maintenance of the gui. Right now you are using 800 x 600 as your screen size. Most people are probably using at least 1024 x 768 screen sizes. When using LayoutManagers you would suggest component sizes by using setPreferredSize(), not setSize().

Similar Messages

  • AWT to SWING conversion - i am so lost!!!

    Hi,
    i am hoping somebody's expertise can help me. i am still relatively new to java and have created this class in java which has an AWT gui, that enables a user to click a "load" button, which the user can then select the jpeg they want to load and the class loads the picture in the canvas. Once i had created it i realised that i actually need to do it in SWING, but the problem is that i dont know how to convert this AWT class to a SWING based class. I have included the code below, and would really appreciate it if somebody can show me how to convert my code so that it is in SWING instead.
    Thank you for your help.
    kind regards,
    Very Confused One
    --------------------------START OF CODE [ImageDicer.java] --------------------------
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.util.*;
    public class ImageDicer extends Frame
    public static void main(String[] args)
    String fileName = "default";
    if (args.length > 0) fileName = args[0];
    new ImageDicer(fileName);
    private static final String kBanner = "ImageDicer v1.0";
    public ImageDicer(String fileName)
    super(kBanner);
    createUI();
    loadImage(fileName);
    setVisible(true);
    private Panel mControlPanel;
    private void createUI()
    setFont(new Font("Serif", Font.PLAIN, 12));
    setLayout(new BorderLayout());
    final Label statusLabel = new Label("Welcome to " + kBanner + ".");
    Button loadButton = new Button("Load...");
    loadButton.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    FileDialog fd = new FileDialog(ImageDicer.this);
    fd.show();
    if (fd.getFile() == null) return;
    String path = fd.getDirectory() + fd.getFile();
    loadImage(path);
    mControlPanel = new Panel();
    mControlPanel.add(loadButton);
    mControlPanel.add(statusLabel);
    add(mControlPanel, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent e)
    dispose();
    System.exit(0);
    private void adjustToImageSize()
    if (!isDisplayable()) addNotify(); // Do this to get valid Insets.
    Insets insets = getInsets();
    int w = mBufferedImage.getWidth() + insets.left + insets.right;
    int h = mBufferedImage.getHeight() + insets.top + insets.bottom;
    h += mControlPanel.getPreferredSize().height;
    setSize(w, h);
    private void center()
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension d = getSize();
    int x = (screen.width - d.width) / 2;
    int y = (screen.height - d.height) / 2;
    setLocation(x, y);
    private BufferedImage mBufferedImage;
    private void loadImage(String fileName)
    Image image = Toolkit.getDefaultToolkit().getImage(fileName);
    MediaTracker mt = new MediaTracker(this);
    mt.addImage(image, 0);
    try { mt.waitForID(0); }
    catch (InterruptedException ie) { return; }
    if (mt.isErrorID(0)) return;
    mBufferedImage = new BufferedImage(image.getWidth(null),
    image.getHeight(null),
    BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = mBufferedImage.createGraphics();
    g2.drawImage(image, null, null);
    adjustToImageSize();
    center();
    validate();
    repaint();
    setTitle(kBanner + ": " + fileName);
    public void paint(Graphics g)
    if (mBufferedImage == null) return;
    Insets insets = getInsets();
    g.drawImage(mBufferedImage, insets.left, insets.top, null);
    --------------------------END OF CODE [ImageDicer.java] --------------------------

    Thanks again for your assistance. The class manages to compile now but there seems to be a bug in the program. Everytime i run the class, the window loads, but the load button does not appear. It only appears when you click aimlessly at the bottom of the window until u luckily click on it. i cannot understand why this is happening :s
    Again i am greatful for your help.
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.io.*;
    import java.util.*;
    import javax.imageio.ImageIO;
    import java.net.*;
    import javax.swing.filechooser.*;
    public class ImageDicer extends JFrame
    String kBanner = "ImageDicer v1.0";
    JPanel mControlPanel;
    JLabel statusLabel;
    JButton loadButton;
    public BufferedImage mBufferedImage;
    public ImageDicer(String fileName)
    { Container pane=getContentPane();
         setTitle(kBanner);
         pane.setLayout(new BorderLayout());
    statusLabel = new JLabel("Welcome to " + kBanner + ".");
    loadButton = new JButton("Load...");
    loadButton.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    {  JFileChooser fd = new JFileChooser();
         int returnVal=fd.showOpenDialog(ImageDicer.this);
              if(returnVal==JFileChooser.APPROVE_OPTION)
                   {if (fd.getSelectedFile() == null)
                              {return;}
                                  File file=fd.getSelectedFile();
                                  String path=(String)file.getPath();
                                  loadImage(path);
    mControlPanel = new JPanel();
         mControlPanel.add(loadButton);
         mControlPanel.add(statusLabel);
    pane.add( BorderLayout.SOUTH, mControlPanel);
    public void adjustToImageSize()
    if (!isDisplayable()) addNotify(); // Do this to get valid Insets.
    Insets insets = getInsets();
    int w = mBufferedImage.getWidth() + insets.left + insets.right;
    int h = mBufferedImage.getHeight() + insets.top + insets.bottom;
    h += mControlPanel.getPreferredSize().height;
    setSize(w, h);
    public void center()
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension d = getSize();
    int x = (screen.width - d.width) / 2;
    int y = (screen.height - d.height) / 2;
    setLocation(x, y);
    public void loadImage(String fileName)
    Image image = Toolkit.getDefaultToolkit().getImage(fileName);
    MediaTracker mt = new MediaTracker(this);
    mt.addImage(image, 0);
    try { mt.waitForID(0); }
    catch (InterruptedException ie) { return; }
    if (mt.isErrorID(0)) return;
    mBufferedImage = new BufferedImage(image.getWidth(null),
    image.getHeight(null),
    BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = mBufferedImage.createGraphics();
    g2.drawImage(image, null, null);
    adjustToImageSize();
    center();
    validate();
    repaint();
    setTitle(kBanner + ": " + fileName);
    public void paint(Graphics g)
    if (mBufferedImage == null) return;
    Insets insets = getInsets();
    g.drawImage(mBufferedImage, insets.left, insets.top, null);
    public static void main(String[] args)
    String fileName = "default";
    if (args.length > 0) fileName = args[0];
    ImageDicer img=new ImageDicer(fileName);
    img.setSize(800,600);
    img.show();
    }

  • Run Time error!!!Help plz

    hi ..
    every time i run my application i get this error which i can't understand where exactly the error is
    can any one help plz
    )at javax.swing.JLayeredPane.paint(JLayeredPane.java:546
    )at javax.swing.JComponent.paintChildren(JComponent.java:498
    )at javax.swing.JComponent.paint(JComponent.java:669
    )at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:23
    :at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java
    )54
    at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:91
    )at java.awt.Container.paint(Container.java:960
    )at javax.swing.JFrame.update(JFrame.java:329
    )at sun.awt.RepaintArea.update(RepaintArea.java:337
    )at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:200
    )at java.awt.Component.dispatchEventImpl(Component.java:2663
    )at java.awt.Container.dispatchEventImpl(Container.java:1213
    )at java.awt.Window.dispatchEventImpl(Window.java:914
    )at java.awt.Component.dispatchEvent(Component.java:2497
    )at java.awt.EventQueue.dispatchEvent(EventQueue.java:339
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
    )read.java:131
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
    )ad.java:98
    )at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93
    )at java.awt.EventDispatchThread.run(EventDispatchThread.java:85
    this is part of the code:
      public void actionPerformed(ActionEvent e)
        FileInputStream fis = null;
        if (e.getSource() == add) //The ADD button.
          //User has not populated all the input fields.
          if(name.getText().equals("")|| address.getText().equals("")|| phone.getText().equals("")|| sex.getText().equals("")|| dob.getText().equals("")|| photo.getText().equals(""))
            JOptionPane.showMessageDialog(null, "Please fill in all the fields","Missing Fields",JOptionPane.INFORMATION_MESSAGE);
          else
            // save the new customer:
            try
              //1. take the customer's data and photo:
              int    userId          = Integer.parseInt(id.getText());
              String userName      = name.getText();
              String userAddress      = address.getText();
              String userPhone      = phone.getText();
              String userSex      = sex.getText();
              String userDateBirth      = dob.getText();
              //String userDateBirth=Date.parse(dob);
              String photoName      = photo.getText();
              String audioName=   audio.getText();
              File   file           = new File(photoName);
              int    fileLength      = (int)file.length();
              //2. Set the user's photo into the photoHolder:
              photoHolder.setVisible(false);
              photoHolder = null;
              comments.setVisible(false);
              comments = null;
              Icon[] custPhotos = {new ImageIcon(photoName)};
              JList photosList = new JList(custPhotos);
              photosList.setFixedCellHeight(100);
              photosList.setFixedCellWidth(80);
              photoHolder = new JPanel();
              photoHolder.add(photosList);
              makeComments();
              //3. Insert the data and photo into the database:
              if(fileLength > 0)
                fis = new FileInputStream(file);
                String query = " INSERT INTO CUSTOMER VALUES('"+userId+"', '"+ userName+ "', '"+ userAddress+ "', " +" '"+ userPhone+ "', '"+ userSex+ "', '"+ userDateBirth+ "', ?,?,? ) ";
                PreparedStatement pstmt = conn.prepareStatement(query);
                pstmt.setBinaryStream(1, fis, fileLength);
                  pstmt.setString(2,photoName);
                  pstmt.setString(3,audioName);
                pstmt.executeUpdate();
                comments.setText(userName+", added.");
              else
                String query = " INSERT INTO CUSTOMER (id, name, address, phone, sex, dob) VALUES('"+userId+"', '"+userName+"', '"+userAddress+"', '"+userPhone+"', '"+userSex+"', '"+userDateBirth+"') ";
                stat.executeUpdate(query);
                comments.setText("Customer saved without a photo.");
              backPanel.add(photoHolder);
              backPanel.add(comments);
              updateTable();
              //AddScroll();
            } //try
            catch (Exception ee)
               //The danger of putting creating the JOptionPane in here is that it will show the same message regardless of the error.
                JOptionPane.showMessageDialog(null, "Customers CPR already exits!!Please enter another CPR","Invalid",JOptionPane.INFORMATION_MESSAGE);
              System.out.println("Caught exception in add action: " + ee);
              ee.printStackTrace();
            } //catch
          } //if
        }//add button

    hi...
    i got where the error is..
    now i have another problem..
    Connecting to database..
    Valid Login
    Caught updateTable exception: java.lang.ArrayIndexOutOfBoundsException
    java.lang.ArrayIndexOutOfBoundsException
    at UtilityMethods.updateTable(UtilityMethods.java:305)
    (which is this line:
    tableData[currentRow] = fieldString;)-----> i did this because one of the fields will be a Date and the others are strings
    at UtilityMethods.updateTable(UtilityMethods.java:429)
    at Login.validLogin(Login.java:114)
    at Login.actionPerformed(Login.java:80)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:14
    50)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
    ctButton.java:1504)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
    .java:378)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
    istener.java:216)
    at java.awt.Component.processMouseEvent(Component.java:3715)
    at java.awt.Component.processEvent(Component.java:3544)
    at java.awt.Container.processEvent(Container.java:1164)
    at java.awt.Component.dispatchEventImpl(Component.java:2593)
    at java.awt.Container.dispatchEventImpl(Container.java:1213)
    at java.awt.Component.dispatchEvent(Component.java:2497)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
    at java.awt.Container.dispatchEventImpl(Container.java:1200)
    at java.awt.Window.dispatchEventImpl(Window.java:914)
    at java.awt.Component.dispatchEvent(Component.java:2497)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:339)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
    read.java:131)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
    ad.java:98)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
    this is the code :
    void updateTable()
          ResultSet results = null;
          ResultSet results1 = null;
          try
            //Get the number of rows in the table so we know how big to make the data array..
            int rowNumbers  = 0;
            int columnCount = 6;
            results = stat.executeQuery("SELECT COUNT(*) FROM CUSTOMER ");
            if(results.next())
              rowNumbers = results.getInt(1);
            } //if
            if(rowNumbers == 0)
            rowNumbers = 1;
            tableData = new String[rowNumbers][columnCount];
            //Initialize the data array with "" so we avoid possibly having nulls in it later..
            for(int i =0;i<tableData.length;i++)
              for(int j=0;j<tableData[0].length;j++)
              tableData[i][j] = "";
            //Populate the data array with results of the query on the database..
            int currentRow = 0;
             SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
            results1 = stat.executeQuery("SELECT * FROM CUSTOMER ORDER BY ID");
            while (results1.next())
              for(int i = 0; i < columnCount; i++){
              Object field = results1.getObject(i + 1);
              // actually this next line should be put outside your loop so you don't keep creating this object
              // or whatever format you want
              String fieldString;
              if (field instanceof Date)
                     fieldString = sdf.format((Date) field);
                     else
                          fieldString = field.toString();
                          tableData[currentRow] = fieldString;
    //tableData[currentRow][i] = results1.getString(i + 1);
    currentRow++;
    } //while
    }//for
    final String[] colName = { "CPR", "Name", "Address", "Phone", "Sex", "Date OF Birth" };
    TableModel pageModel = new AbstractTableModel()
    public int getColumnCount()
    return tableData[0].length;
    } //getColumnCount
    public int getRowCount()
    return tableData.length;
    } //getRowCount
    public Object getValueAt(int row, int col)
    return tableData[row][col];
    } //getValueAt
    public String getColumnName(int column)
    return colName[column];
    } //getcolName
    public Class getColumnClass(int col)
    return getValueAt(0, col).getClass();
    } //getColumnClass
    public boolean isCellEditable(int row, int col)
    return false;
    } //isCellEditable
    public void setValueAt(String aValue, int row, int column)
    tableData[row][column] = aValue;
    } //setValueAt
    //dataTable.setValue( new JScrollBar(JScrollBar.HORIZONTAL), 2,1 );
    }; //pageModel
    //Create the JTable from the table model:
    JTable dataTable = new JTable(pageModel);
    // dataTable.setModel();

  • Im new to the 5g ipod help plz

    will the ipod turn off if i leave it on pause? i know i have a really stupid question but help plz thx

    Yes.

  • My Apple TV is not working. On tv display, I'm getting unsupported signal. Check your device output. Can anyone help plz.

    My Apple TV is not working. On tv display, I'm getting a message 'unsupported signal. Check your device output. ' Can anyone help plz.

    connect it to a tv which support full hd and go into the settings and lower the resolution as much as possible and then connect it with your tv once more

  • I have just getting a new phone and I have forgot my password an Apple ID what I made new for the new phone now I cannot get on it because asking for id and password what should I do help plz thank u

    I have just getting a new phone and I have forgot my password an Apple ID what I made new for the new phone now I cannot get on it because asking for id and password what should I do help plz thank u

    Try
    https://iforgot.apple.com

  • I lost my phone and i got an unlocked 4s from my gf she used it before an its still connected to her icloud is there a way i can restore my icloud back up to replace hers without messing up the unlock also my latest backup isnt showing on my pc help plz!!

    i lost my phone and i got an unlocked 4s from my gf she used it before an its still connected to her icloud is there a way i can restore my icloud back up to replace hers without messing up the unlock also my latest backup isnt showing on my pc help plz!!

    Please please help me, if you know how.

  • I cant get voice over to work on my 4G shuffle it clicks off every time help plz

    i need help plz it wont work

    Hello,
    Welcome to Adobe Forums.
    Try uninstalling Adobe Flash Player from Flash Player uninstaller : http://helpx.adobe.com/flash-player/kb/uninstall-flash-player-mac-os.html#main_uninstall
    Try a clean installation using this KB : http://helpx.adobe.com/content/help/en/flash-player/kb/installation-problems-flash-player- mac.html
    Thanks,
    Vikram

  • Help Plz.......!!!!its urgent

    hi nokia users
    flash lite on my 5530 only plays youtube videos,and when tried to play videos on other sites then it says flash player is required............do ui use any software that supports web videos...???
    help plz.....
    thanks in advance

    Falshplayer vedio cant acces in your device?

  • Help plz so my gf said she block me and we txt back to back but later on i sent her a messages and it said it was read so am I blocked  a

    help plz so my gf said she block me and we txt back to back but later on i sent her a messages and it said it was read so am I blocked 

    The proper way to close Firefox is through the File menu "Exit" or the equivalent with the Firefox button.
    More detail in item '''#38 Firefox already running '''
    of
    [http://dmcritchie.mvps.org/firefox/firefox-problems.htm#fx4interface Fix Firefox 4.0 toolbar user interface, problems (Make Firefox 4.0 look like 3.6) (#fx4interface)]
    Firefox already running, to properly shutdown Firefox when closing the last window use File → Exit/Quit (or Firefox button → Exit). Closing Firefox with the [X] in the upper right corner closes the window ("Ctrl+W") but that does not necessarily close Firefox if it has subtasks running. If you want to close and reopen Firefox use the "Restart" within Add-ons if you made a change requiring a restart, or install "[https://addons.mozilla.org/firefox/addon/restartless-restart/ Restartless Restart]" ("Ctrl+Alt+R") which will allow you to take Firefox down and restart without having to check the Windows Task Manager to see if Firefox first actually ended. [http://kb.mozillazine.org/Firefox_hangs Firefox hangs]

  • Help plz, i need back up my phone

    Help plz, i have iphone 4 i still have icloud  on my itunes and i need to update it to the new one but i dont want to lose any of my pictues of my kids im not sure if ive backed it up before if i have it would of been a long time ago plz help me thanks

    jennyspeedy* wrote:
    i dont want to lose any of my pictues of my kids im not sure if ive backed it up before if i have it would of been a long time ago plz help me thanks
    Then use the device as designed.  Copy the pictures off the device to the computer.  For any pictures that you desire to keep on the device, simply sync them via iTunes.
    Failure to copy the pictures off the device is only asking for problems.  If the device is ever lost/stolen or simply fails to work, without a backup they would be gone as well.

  • Help Plz i've blank LCD in Lenovo G530

    Help Plz i've blank LCD in Lenovo G530
    the unit is working and the power & wireless indicators is  on but the LCD is blank
    i've allready unpluged the battery and powered the unit with the charger only and plug the battery again but still have the same problem.
    so plz advice what to do ?????

    Try to plug in external monitor and look if anything shows. Then try to check monitor configuration. Maybe it is switched off...
    Regards,
    Publius
    Lenovo 3000 V200

  • I forgot my password, and i want to unlock it without losing my data, can anyone help plz???

    i forgot my password, and i want to unlock it without losing my data, can anyone help plz???

    You can't. It is a good security feature. You have to connect the iPod to yur computer and restore via iTunes.

  • Itunes help plz respond asap

    ok so when i try to play my songs on itunes no matter where it was downloaded from (itunes or another source) it wont play. it will act like it was going to play and then freeze at 00:00. i tried re-installing it and deleting my itunes library and putting it back on but nothing has worked. my sound is fine because it makes that noise when i turn on the computer and such. help plz.

    You can get iTunes here: http://www.apple.com/itunes/
    You will also need the iPod Updater:http://www.apple.com/ipod/download/

  • How can we create a Collective search help  plz tell me with steps

    How can we create a Collective search help  plz tell me with steps
    thanks,
    basu

    Hi
    1) Elementary search helps describe a search path. The elementary search help must define where the data of the hit list should be read from (selection method), how the exchange of values between the screen template and selection method is implemented (interface of the search help) and how the online input help should be defined (online behavior of the search help).
    2) Collective search helps combine several elementary search helps. A collective search help thus can offer several alternative search paths.
    3)An elementary search help defines the standard flow of an input help.
    4) A collective search help combines several elementary search helps. The user can thus choose one of several alternative search paths with a collective search help.
    5)A collective search help comprises several elementary search helps. It combines all the search paths that are meaningful for a field.
    6)Both elementary search helps and other search helps can be included in a collective search help. If other collective search helps are contained in a collective search help, they are expanded to the level of the elementary search helps when the input help is called.
    CREATION:
    Go to SE11  Tcode
    select search help
    give the 'z' search help name and create
    select the selection method ur table name eg : 'mara'
    dialog module 'display value immediately'.
    add the field whatever u want and lpos = 1 and spos = 1 and check import and export parameter.
    where left position when displaying and spos = search position
    and then save and activate ..
    See the links:
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee38446011d189700000e8322d00/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee45446011d189700000e8322d00/content.htm
    pls go through this for search help creation
    http://help.sap.com/saphelp_nw2004s/helpdata/en/41/f6b237fec48c67e10000009b38f8cf/content.htm
    Search Help Exits:
    Re: dynamic values for search help
    Re: Dynamic search  help
    Reward points for useful Answers
    Regards
    Anji

Maybe you are looking for