Help needed about DefaultTableModel code

Hi,
Can anybody tell me what is wrong about the construction of my JTable. I create the instance of the below class and add to my JTable:
MyTableModel myModel = new MyTableModel();
JTable costTable = new JTable(myModel);
I can see printouts "MTM_1,2,3,4" then it gives me an exception
Exception caught in Scenegraph: 16 >= 16
The vector IFC_Tree.totalVector has members like:
IFC_Tree.totalVector[0]: [IFCBeam, 4.962499618530273, m3, 0.0, 0.0]
IFC_Tree.totalVector[1]: [IFCColumn, 13.84760570526123, m3, 0.0, 0.0]
IFC_Tree.totalVector[2]: [IFCFloor, 113.82814025878906, m3, 0.0, 0.0]
IFC_Tree.totalVector[3]: [IFCWall, 229.7195587158203, m3, 0.0, 0.0]
IFC_Tree.totalVector[4]: [IFCRoofSlab, 215.8400421142578, m2, 0.0, 0.0]
IFC_Tree.totalVector[5]: [IFCWindow_2.375*2.45, 8.0, number, 0.0, 0.0]
IFC_Tree.totalVector[6]: [IFCWindow_0.6*0.6, 20.0, number, 0.0, 0.0]
IFC_Tree.totalVector[7]: [IFCWindow_3.85*2.45, 3.0, number, 0.0, 0.0]
IFC_Tree.totalVector[8]: [IFCWindow_2.0*2.1, 2.0, number, 0.0, 0.0]
IFC_Tree.totalVector[9]: [IFCDoor_0.9*2.1, 17.0, number, 0.0, 0.0]
IFC_Tree.totalVector[10]: [IFCDoor_1.8*2.45, 2.0, number, 0.0, 0.0]
IFC_Tree.totalVector[11]: [IFCDoor_0.8*2.1, 28.0, number, 0.0, 0.0]
IFC_Tree.totalVector[12]: [IFCDoor_0.9*2.45, 11.0, number, 0.0, 0.0]
IFC_Tree.totalVector[13]: [IFCDoor_2.0*2.1, 2.0, number, 0.0, 0.0]
IFC_Tree.totalVector[14]: [IFCDoor_1.0*2.1, 4.0, number, 0.0, 0.0]
IFC_Tree.totalVector[15]: [null, null, null, TOTAL COST, 0.0]
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.JScrollPane;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.JOptionPane;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
import javax.swing.DefaultCellEditor;
import java.util.Vector;
//public class MyTableModel extends AbstractTableModel
public class MyTableModel extends DefaultTableModel
private boolean DEBUG = true;
static double totalCost = 0.0;
static Vector data = new Vector();
static Vector columnNames = new Vector();
static Vector tmp;
public MyTableModel()
System.out.println("MTM_1");
addColumn("IFCOBJECTS OR PROCESSES");
addColumn("QUANTITY");
addColumn("UNITS");
addColumn("UNIT COST (�)");
addColumn("TOTAL COST (�)");
System.out.println("MTM_2");
for(int i=0; i < IFC_Tree.totalVector.size(); i++)
System.out.println("MTM_3");
tmp = (Vector)(IFC_Tree.totalVector.elementAt(i));
System.out.println("MTM_4");
addRow(tmp);
System.out.println("MTM_5");
System.out.println("MTM_6");
public int getColumnCount()
return columnNames.size();
public int getRowCount()
public String getColumnName(int col)
public Object getValueAt(int row, int col)
public boolean isCellEditable(int row, int col)
public void setValueAt(Object value, int row, int col)
}

I don't understand why you override the methods getRowCount() ... and why there are the static member variables columnNames .... (all this is done by the DefaultTableModel). Your table model initialization in the constructor should suffice.
Pierre

Similar Messages

  • Help needed in this code

    Hi guys, I need help in debugging this code I made, which is a GUI minesweeper. Its extremely buggy...I particularly need help fixing the actionListener part of the code as everytime I press a button on the GUI, an exception occurs.
    help please!
    package minesweeperGUI;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MinesweeperGUI implements ActionListener
         //Declaration of attributes
         static int length = 0;
         JMenuItem menuItemNew = new JMenuItem();
         JRadioButtonMenuItem rbEasy = new JRadioButtonMenuItem();
         JRadioButtonMenuItem rbHard = new JRadioButtonMenuItem();
         JMenuItem menuItemExit = new JMenuItem();
         JButton buttonReset = new JButton();
         JButton buttonGrid[][] = null;
         JFrame frame = new JFrame();
         int getBombsTotal = 0;
         JLabel setBombsLabel = new JLabel();
         int a = 0;
         int b = 0;     
         //No constructor created. Uses default constructor
         //Create the menu bar
         public JMenuBar newMenuBar()
              //Sets up the menubar
              JMenuBar menuBar = new JMenuBar();
              //Sets up the Game menu with choice of new, grid size, and exit
              JMenu menu = new JMenu ("Game");
              menuBar.add (menu);
              menuItemNew = new JMenuItem ("New");
              menuItemNew.addActionListener (this);
              menu.add (menuItemNew);
              menu.addSeparator();
              //Sets up sub-menu for grid size with choice of easy and hard radio buttons
              JMenu subMenu = new JMenu ("Grid Size");
              rbEasy = new JRadioButtonMenuItem ("Easy: 5x5 grid");
              rbEasy.addActionListener (this);
              subMenu.add (rbEasy);
              rbHard = new JRadioButtonMenuItem ("Hard: 10x10 grid");
              rbHard.addActionListener (this);
              subMenu.add (rbHard);
              menu.add (subMenu);
              menu.addSeparator();
              menuItemExit = new JMenuItem ("Exit");
              menuItemExit.addActionListener (this);
              menu.add (menuItemExit);
              return menuBar;
         //Setting up of Bomb Grid
         public int [][] setGrid (int length)
              int grid[][] = null;
              grid = new int[length][length];
              for (int i = 0; i < length; i++)
                   for (int j = 0; j < length; j++)
                        grid[i][j] = ((int)Math.round(Math.random() * 10))% 2;
              return grid;     
         //Setting up of the of the graphical bomb grid
         public JButton[][] setButtonGrid (int length)
              JButton buttonGrid[][] = null;
              buttonGrid = new JButton[length][length];
              for (int i = 0; i < length; i++)
                   for (int j = 0; j < length; j++)
                        buttonGrid[i][j] = new JButton();
              return buttonGrid;
         //Setting up of a way to count the total number of bombs in the bomb grid
         public int getBombsTotal (int length, int setGrid[][])
              int bombsTotal = 0;
              for (int i = 0; i < length; i++)
                   for (int j = 0; j < length; j++)
                        if (setGrid[i][j] == 1)
                             bombsTotal += 1;
              return bombsTotal;
         //Create a label for number of bombs left
         public JLabel setBombsLabel (int getBombsTotal)
              JLabel bombsLabel = new JLabel(String.valueOf (getBombsTotal) + " Bombs Left");
              return bombsLabel;
         //Setting up a way to count the number of bombs around a button
         public String setBombs (int length, int setGrid[][], int x, int y)
              int bombs[][] = new int[length][length];
              String bombsString = null;
              for (int i = 0; i < length; i++)
                   for (int j = 0; j < length; j++)
                        if (i == 0 && j == 0)
                             bombs[i][j] = setGrid[i][j+1] + setGrid[i+1][j] +
                                  setGrid[i+1][j+1];
                        else if (i ==0 && j == (length - 1))
                             bombs[i][j] = setGrid[i][j-1] + setGrid[i+1][j-1] +
                                  setGrid[i+1][j];
                        else if (i == (length - 1) && j == 0)
                             bombs[i][j] = setGrid[i-1][j] + setGrid[i-1][j+1] +
                                  setGrid[i][j+1];
                        else if (i == (length - 1) && j == (length - 1))
                             bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
                                  setGrid[i][j-1];
                        else if (i == 0 && j != 0 && j != (length - 1))
                             bombs[i][j] = setGrid[i][j-1] + setGrid[i][j+1] +
                                  setGrid[i+1][j-1] + setGrid[i+1][j] +
                                  setGrid[i+1][j+1];
                        else if (i == (length - 1) && j != 0 && j != (length - 1))
                             bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
                                  setGrid[i-1][j+1] + setGrid[i][j-1] +
                                  setGrid[i][j+1];
                        else if (i != 0 && i != (length - 1) && j == 0)
                             bombs[i][j] = setGrid[i-1][j] + setGrid[i-1][j+1] +
                                  setGrid[i][j+1] + setGrid[i+1][j] +
                                  setGrid[i+1][j+1];
                        else if (i != 0 && i != (length - 1) && j == (length - 1))
                             bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
                                  setGrid[i][j-1] + setGrid[i+1][j-1] +
                                  setGrid[i+1][j];
                        else
                             bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
                                  setGrid[i-1][j+1] + setGrid[i][j-1] +
                                  setGrid[i][j+1] + setGrid[i+1][j-1] +
                                  setGrid[i+1][j] + setGrid[i+1][j+1];
              bombsString = String.valueOf (bombs[x][y]);
              return bombsString;
         //create the panel for the bombs label and reset button
         public JPanel newTopPanel(int length)
              int setGridNew [][] = null;
              setGridNew = new int[length][length];
              int getBombsTotalNew = 0;
              JLabel setBombsLabelNew = new JLabel();
              setGridNew = setGrid (length);
              getBombsTotalNew = getBombsTotal (length, setGridNew);
              setBombsLabelNew = setBombsLabel (getBombsTotalNew);
              JPanel topPanel = new JPanel ();
              topPanel.setLayout (new BorderLayout (50,50));
              JLabel bombsLabel = new JLabel ();
              bombsLabel = setBombsLabelNew;     
              topPanel.add (bombsLabel, BorderLayout.WEST);
              buttonReset = new JButton("Reset");
              buttonReset.addActionListener (this);
              topPanel.add (buttonReset, BorderLayout.CENTER);
              return topPanel;
         //create the panel for the play grids
         public JPanel newBottomPanel(int length)
              JButton setButtonGridNew[][] = null;
              setButtonGridNew = new JButton [length][length];
              setButtonGridNew = setButtonGrid (length);
              JPanel bottomPanel = new JPanel ();
              bottomPanel.setLayout (new GridLayout (length, length));
              buttonGrid = new JButton[length][length];          
              for (a = 0; a < length; a++)
                   for (b = 0; b < length; b++)
                        buttonGrid[a] = setButtonGridNew[a][b];
                        buttonGrid[a][b].addActionListener (this);
                        bottomPanel.add (buttonGrid[a][b]);
              return bottomPanel;
         //Overiding of abstract method actionPerformed
         public void actionPerformed(ActionEvent e)
              if (e.getSource() == menuItemNew)
                   launchFrame(length);
              else if (e.getSource() == menuItemExit)
                   frame.setVisible (false);
                   System.exit(0);
              else if (e.getSource() == rbEasy)
                   length = 5;
                   launchFrame(length);
              else if (e.getSource() == rbHard)
                   length = 10;
                   launchFrame(length);     
              else if (e.getSource() == buttonReset)
                   launchFrame(length);
              else if (e.getSource() == buttonGrid[a][b])
                   int setGridNew [][] = null;
                   setGridNew = new int[length][length];               
                   JButton bombButton [][] = null;
                   bombButton = new JButton [length][length];
                   String bombString [][] = null;
                   bombString = new String[length][length];
                   setGridNew = setGrid (length);               
                   bombString[a][b] = setBombs (length, setGridNew, a, b);
                   bombButton[a][b] = new JButton (bombString[a][b]);
                   if (setGridNew[a][b] == 0)
                        buttonGrid[a][b] = bombButton[a][b];
                        getBombsTotal--;
                        JLabel setBombsLabelNew = new JLabel();
                        setBombsLabelNew = setBombsLabel (getBombsTotal);
                   else if (setGridNew[a][b] == 1 )
                        buttonGrid[a][b] = new JButton("x");
                        JOptionPane.showMessageDialog (null, "Game Over. You hit a Bomb!");
                        System.exit(0);     
         //create the content pane
         public Container newContentPane(int length)
              JPanel topPanel = new JPanel();
              JPanel bottomPanel = new JPanel();          
              topPanel = newTopPanel(length);
              bottomPanel = newBottomPanel (length);
              JPanel contentPane = new JPanel();
              contentPane.setOpaque (true);
              contentPane.setLayout (new BorderLayout(50,50));
              contentPane.add (topPanel, BorderLayout.NORTH);
              contentPane.add (bottomPanel, BorderLayout.CENTER);
              return contentPane;
         public void launchFrame (int length)
              //Makes sure we have nice window decorations
              JFrame.setDefaultLookAndFeelDecorated(true);          
              //Sets up the top-level window     
              frame = new JFrame ("Minesweeper");
              //Exits program when the closed button is clicked
              frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
              JMenuBar menuBar = new JMenuBar();
              Container contentPane = new Container();
              menuBar = newMenuBar();
              contentPane = newContentPane (length);
              //Sets up the menu bar and content pane
              frame.setJMenuBar (menuBar);
              frame.setContentPane (contentPane);
              //Displays the window
              frame.pack();
              frame.setVisible (true);
         public static void main (String args[])
              //Default length is 5
              length = 5;
              MinesweeperGUI minesweeper = new MinesweeperGUI();
              minesweeper.launchFrame(length);

    hi, thanks. that removed the exception; although now the buttons action listener won't work :(
    here is the revised code:
    To anyone out there, can you guys run this code and help me debug it?
    I'm really desperate as this is a school project of mine and the deadline is 7 hours away. I have already been working on it for 3 days, but the program is still very buggy.
    thanks!
    /* Oliver Ian C. Wee 04-80112
    * CS12 MHRU
    * Machine Problem 2
    package minesweeperGUI;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MinesweeperGUI implements ActionListener
         //Declaration of attributes
         static int length = 0;
         JMenuItem menuItemNew = new JMenuItem();
         JRadioButtonMenuItem rbEasy = new JRadioButtonMenuItem();
         JRadioButtonMenuItem rbHard = new JRadioButtonMenuItem();
         JMenuItem menuItemExit = new JMenuItem();
         JButton buttonReset = new JButton();
         JButton buttonGrid[][] = null;
         JFrame frame = new JFrame();
         int getBombsTotal = 0;
         JLabel setBombsLabel = new JLabel();
         int a = 0;
         int b = 0;
         //No constructor created. Uses default constructor
         //Create the menu bar
         public JMenuBar newMenuBar()
              //Sets up the menubar
              JMenuBar menuBar = new JMenuBar();
              //Sets up the Game menu with choice of new, grid size, and exit
              JMenu menu = new JMenu ("Game");
              menuBar.add (menu);
              menuItemNew = new JMenuItem ("New");
              menuItemNew.addActionListener (this);
              menu.add (menuItemNew);
              menu.addSeparator();
              //Sets up sub-menu for grid size with choice of easy and hard radio buttons
              JMenu subMenu = new JMenu ("Grid Size");
              ButtonGroup bg = new ButtonGroup();
              rbEasy = new JRadioButtonMenuItem ("Easy: 5x5 grid");
              bg.add (rbEasy);
              rbEasy.addActionListener (this);
              subMenu.add (rbEasy);
              rbHard = new JRadioButtonMenuItem ("Hard: 10x10 grid");
              bg.add (rbHard);
              rbHard.addActionListener (this);
              subMenu.add (rbHard);
              menu.add (subMenu);
              menu.addSeparator();
              menuItemExit = new JMenuItem ("Exit");
              menuItemExit.addActionListener (this);
              menu.add (menuItemExit);
              return menuBar;
         //Setting up of Bomb Grid
         public int [][] setGrid (int length)
              int grid[][] = null;
              grid = new int[length][length];
              for (int i = 0; i < length; i++)
                   for (int j = 0; j < length; j++)
                        grid[i][j] = ((int)Math.round(Math.random() * 10))% 2;
              return grid;     
         //Setting up of the of the graphical bomb grid
         public JButton[][] setButtonGrid (int length)
              JButton buttonGrid[][] = null;
              buttonGrid = new JButton[length][length];
              for (int i = 0; i < length; i++)
                   for (int j = 0; j < length; j++)
                        buttonGrid[i][j] = new JButton();
              return buttonGrid;
         //Setting up of a way to count the total number of bombs in the bomb grid
         public int getBombsTotal (int length, int setGrid[][])
              int bombsTotal = 0;
              for (int i = 0; i < length; i++)
                   for (int j = 0; j < length; j++)
                        if (setGrid[i][j] == 1)
                             bombsTotal += 1;
              return bombsTotal;
         //Create a label for number of bombs left
         public JLabel setBombsLabel (int getBombsTotal)
              JLabel bombsLabel = new JLabel("  " +String.valueOf (getBombsTotal) + " Bombs Left");
              return bombsLabel;
         //Setting up a way to count the number of bombs around a button
         public String setBombs (int length, int setGrid[][], int x, int y)
              int bombs[][] = new int[length][length];
              String bombsString = null;
              for (int i = 0; i < length; i++)
                   for (int j = 0; j < length; j++)
                        if (i == 0 && j == 0)
                             bombs[i][j] = setGrid[i][j+1] + setGrid[i+1][j] +
                                  setGrid[i+1][j+1];
                        else if (i ==0 && j == (length - 1))
                             bombs[i][j] = setGrid[i][j-1] + setGrid[i+1][j-1] +
                                  setGrid[i+1][j];
                        else if (i == (length - 1) && j == 0)
                             bombs[i][j] = setGrid[i-1][j] + setGrid[i-1][j+1] +
                                  setGrid[i][j+1];
                        else if (i == (length - 1) && j == (length - 1))
                             bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
                                  setGrid[i][j-1];
                        else if (i == 0 && j != 0 && j != (length - 1))
                             bombs[i][j] = setGrid[i][j-1] + setGrid[i][j+1] +
                                  setGrid[i+1][j-1] + setGrid[i+1][j] +
                                  setGrid[i+1][j+1];
                        else if (i == (length - 1) && j != 0 && j != (length - 1))
                             bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
                                  setGrid[i-1][j+1] + setGrid[i][j-1] +
                                  setGrid[i][j+1];
                        else if (i != 0 && i != (length - 1) && j == 0)
                             bombs[i][j] = setGrid[i-1][j] + setGrid[i-1][j+1] +
                                  setGrid[i][j+1] + setGrid[i+1][j] +
                                  setGrid[i+1][j+1];
                        else if (i != 0 && i != (length - 1) && j == (length - 1))
                             bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
                                  setGrid[i][j-1] + setGrid[i+1][j-1] +
                                  setGrid[i+1][j];
                        else
                             bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
                                  setGrid[i-1][j+1] + setGrid[i][j-1] +
                                  setGrid[i][j+1] + setGrid[i+1][j-1] +
                                  setGrid[i+1][j] + setGrid[i+1][j+1];
              bombsString = String.valueOf (bombs[x][y]);
              return bombsString;
         //create the panel for the bombs label and reset button
         public JPanel newTopPanel(int length)
              int setGridNew [][] = null;
              setGridNew = new int[length][length];
              int getBombsTotalNew = 0;
              JLabel setBombsLabelNew = new JLabel();
              setGridNew = setGrid (length);
              getBombsTotalNew = getBombsTotal (length, setGridNew);
              setBombsLabelNew = setBombsLabel (getBombsTotalNew);
              JPanel topPanel = new JPanel ();
              topPanel.setLayout (new BorderLayout (20,20));
              JLabel bombsLabel = new JLabel ();
              bombsLabel = setBombsLabelNew;     
              topPanel.add (bombsLabel, BorderLayout.WEST);
              buttonReset = new JButton("Reset");
              buttonReset.addActionListener (this);
              topPanel.add (buttonReset, BorderLayout.CENTER);
              return topPanel;
         //create the panel for the play grids
         public JPanel newBottomPanel(int length)
              JButton setButtonGridNew[][] = null;
              setButtonGridNew = new JButton [length][length];
              setButtonGridNew = setButtonGrid (length);
              JPanel bottomPanel = new JPanel ();
              bottomPanel.setLayout (new GridLayout (length, length));
              buttonGrid = new JButton[length][length];          
              for (int i = 0; i < length; i++)
                   for (int j = 0; j < length; j++)
                        buttonGrid[i][j] = setButtonGridNew[i][j];
                        buttonGrid[i][j].addActionListener (this);
                        bottomPanel.add (buttonGrid[i][j]);
              return bottomPanel;
         //Overiding of abstract method actionPerformed
         public void actionPerformed(ActionEvent e)
              if (e.getSource() == menuItemNew)
                   closeFrame();
                   launchFrame(length);
              else if (e.getSource() == menuItemExit)
                   frame.setVisible (false);
                   System.exit(0);
              else if (e.getSource() == rbEasy)
                   closeFrame();
                   length = 5;
                   launchFrame(length);
              else if (e.getSource() == rbHard)
                   closeFrame();
                   length = 10;
                   launchFrame(length);     
              else if (e.getSource() == buttonReset)
                   closeFrame();
                   launchFrame(length);
              else if (e.getSource() == buttonGrid[a])
                   int setGridNew [][] = null;
                   setGridNew = new int[length][length];               
                   JButton bombButton [][] = null;
                   bombButton = new JButton [length][length];
                   String bombString [][] = null;
                   bombString = new String[length][length];
                   setGridNew = setGrid (length);               
                   for (int i = 0; i < length; i++)
                        for (int j = 0; j < length; j++)
                             bombString[i][j] = setBombs (length, setGridNew, i, j);
                             bombButton[i][j] = new JButton (bombString[i][j]);
                   if (setGridNew[a][b] == 0)
                        buttonGrid[a][b] = bombButton[a][b];
                        getBombsTotal--;
                        JLabel setBombsLabelNew = new JLabel();
                        setBombsLabelNew = setBombsLabel (" " String.valueOf (getBombsTotal) " Bombs Left");
                   else if (setGridNew[a][b] == 1 )
                        buttonGrid[a][b] = new JButton("x");
                        JOptionPane.showMessageDialog (null, "Game Over. You hit a Bomb!");
                        System.exit(0);     
         //create the content pane
         public Container newContentPane(int length)
              JPanel topPanel = new JPanel();
              JPanel bottomPanel = new JPanel();          
              topPanel = newTopPanel(length);
              bottomPanel = newBottomPanel (length);
              JPanel contentPane = new JPanel();
              contentPane.setOpaque (true);
              contentPane.setLayout (new BorderLayout(5,5));
              contentPane.add (topPanel, BorderLayout.NORTH);
              contentPane.add (bottomPanel, BorderLayout.CENTER);
              return contentPane;
         public void closeFrame ()
              frame = new JFrame ("Minesweeper");
              frame.dispose();
         public void launchFrame (int length)
              //Makes sure we have nice window decorations
              JFrame.setDefaultLookAndFeelDecorated(true);          
              //Sets up the top-level window     
              frame = new JFrame ("Minesweeper");
              //Exits program when the closed button is clicked
              frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
              JMenuBar menuBar = new JMenuBar();
              Container contentPane = new Container();
              menuBar = newMenuBar();
              contentPane = newContentPane (length);
              //Sets up the menu bar and content pane
              frame.setJMenuBar (menuBar);
              frame.setContentPane (contentPane);
              //Displays the window
              frame.pack();
              frame.setVisible (true);
         public static void main (String args[])
              //Default length is 5
              length = 5;
              MinesweeperGUI minesweeper = new MinesweeperGUI();
              minesweeper.launchFrame(length);

  • Help needed in the code

    Hi all,
    I need help in acquiring this
    I have a table control,in which i have 3 columns out of which 2 are input/outfields and one is output field.
    say i have fld1 fld2 fld3
    i entera value for fld1 and fld2 then it bring value in fld3.
    but sometimes i.e certain values of fld1 the fld2 should be NA and the fld3 should open up for input.
    say fld1 = def is exception
    first i enter
    fld1 = abc and fld2 =aaa then it brings fld3 =bbb
    next i enter
    fld1 = def and hit enter then fld2 = NA and fld3 should be available for input.
    I have the following code written for this
    CONTROLS: TABLECONTROL TYPE TABLEVIEW USING SCREEN 9002.
    DATA  W_TABLECONTROL LIKE LINE OF TABLECONTROL-COLS.
    ITAB IS MY TABLE CONTROL INTERNAL TABLE I.E MY TABLE CONTROL FIELDS ARE ITAB-FLD1,ITAB-FLD2,ITAB-FLD3.
    loop at TABLECONTROL-cols into w_TABLECONTROL.
      IF w_cTABLECONTROL-screen-group4 = 'NAM'.
      loop at iTAB.
        IF ITAB-FLD1 EQ 'DEF'.
            w_TABLECONTROL-SCREEN-INPUT = '1'.
         else.
            w_TABLECONTROL-SCREEN-INPUT = '0'.
        ENDIF.
    modify TABLECONTROL-cols from w_TABLECONTROL.
       ENDLOOP.
    ENDIF.
    ENDLOOP.
    WHAT I SEE NOW WITH THIS CODE IS WHEN I ENTER THE FIRST RECORD IN
    ITAB-FLD1 AS DEF AND HIT ENTER THE FLD2 IS NA AND FLD3 IS READY FOR OUTPUT
    NOW THE SECOND ROW FLD3 IS AVAILABLE FOR INPUT WHICH I DON'T WANT BECAUSE MY FLD1 OF SECOND IS NOT YET KNOW AGAIN IFITS DEF THEN IT SHOULD BE AVAILABLE FOR INPUT OTHERWISE IT SHOULD GREY OUT.
    HELP ME IN ACHEIVING THIS.
    THANKS

    Hi,
    Have this code inside the LOOP AT ...ENDLOOP of the PBO..
    PROCESS BEFORE OUTPUT.
    LOOP AT ITAB INTO WA..
      <b>MODULE UPDATE_DATA..</b>
    ENDLOOP.
    MODULE UPDATE_DATA.
      LOOP AT SCREEN.
       IF WA-FIELD1 = 'DEF'.
    Add the group for the field3 in the attributes..    
         IF SCREEN-GROUP1 = 'G1'.
    Enable for input...
            SCREEN-INPUT = '1'.
            MODIFY SCREEN.
         ENDIF.
       ELSE.
         IF SCREEN-GROUP1 = 'G1'.
    disable for input for other values.
            SCREEN-INPUT = '0'.
            MODIFY SCREEN.
         ENDIF.
       ENDIF.
      ENDLOOP.
    ENDLOOP.
    Thanks,
    Naren

  • Help needed to rewrite code so main menus move down to make way for subs

    Can anybody please help me (slightly) alter some code.
    I am working on a vertical menu with sub's and need to alter the AS so that when a sub menu is selected, the main menus below it move down to accommodate the new sub menu.
    This is the code I am currently using is
    GenerateMenu = function(container, name, x, y, depth, node_xml) {
        // variable declarations
        var curr_node;
        var curr_item;
        var curr_menu = container.createEmptyMovieClip(name, depth);
        // for all items or XML nodes (items and menus)
        // within this node_xml passed for this menu
        for (var i=0; i<node_xml.childNodes.length; i++) {
            // movieclip for each menu item
            curr_item = curr_menu.attachMovie("menuitem","item"+i+"_mc", i);
            curr_item._x = x;
            curr_item._y = y + i*curr_item._height;
            curr_item.trackAsMenu = true;
            // item properties assigned from XML
            curr_node = node_xml.childNodes[i];
            curr_item.action = curr_node.attributes.action;
            curr_item.variables = curr_node.attributes.variables;
            curr_item.name.text = curr_node.attributes.name;
            // item submenu behavior for rollover event
            if (node_xml.childNodes[i].nodeName == "menu"){
                // open a submenu
                curr_item.node_xml = curr_node;
                curr_item.onRollOver = curr_item.onDragOver = function(){
                    var x = this._x + this._width -76;
                    var y = this._y + 55;
                    GenerateMenu(curr_menu, "submenu_mc", x, y, 10, this.node_xml);
                    // show a hover color
                    var col = new Color(this.background);
                    col.setRGB(0xf4faff);
            }else{ // nodeName == "item"
                curr_item.arrow._visible = false;
                // close existing submenu
            curr_item.onRollOut = curr_item.onDragOut = function(){
                // restore color
                var col = new Color(this.background);
                col.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});
            // any item, menu opening or not can have actions
            curr_item.onRelease = function(){
                Actions[this.action](this.variables);
                CloseSubmenus();
        } // end for loop
    // create the main menu, this will be constantly visible
    CreateMainMenu = function(x, y, depth, menu_xml){
        // generate a menu list
        GenerateMenu(this, "mainmenu_mc", x, y, depth, menu_xml.firstChild);
        // close only submenus if visible durring a mouseup
        // this main menu (mainmenu_mc) will remain
        mainmenu_mc.onMouseUp = function(){
            if (mainmenu_mc.submenu_mc && !mainmenu_mc.hitTest(_root._xmouse, _root._ymouse, true)){
                CloseSubmenus();
    // closes all submenus by removing the submenu_mc
    // in the main menu (if it exists)
    CloseSubmenus = function(){
        mainmenu_mc.submenu_mc.removeMovieClip();
    // This actions object handles methods for actions
    // defined by the XML called when a menu item is pressed
    Actions = Object();
    Actions.gotoURL = function(urlVar){
        getURL(urlVar, "_blank");
    Actions.message = function(msg){
        message_txt.text = msg;
    Actions.newMenu = function(menuxml){
        menu_xml.load(menuxml);
    // load XML, when done, run CreateMainMenu to interpret it
    menu_xml = new XML();
    menu_xml.ignoreWhite = true;
    menu_xml.onLoad = function(ok){
        // create main menu after successful loading of XML
        if (ok){
            CreateMainMenu(10, 10, 0, this);
            message_txt.text = "message area";
        }else{
            message_txt.text = "error:  XML not successfully loaded";
    // load first XML menu
    menu_xml.load("menu1.xml");
    Any help/feed back - even if its just to tell me Im asking for too much, would be incredibly appriciated.

    onclipevent(load)                                           
    total=_root.getbytestotal();                             
    onclipevent(enterframe)
    loaded=_root.getbytesloaded();
    current=int(loaded/total*100);
    p=""+current+"%";
    if(loaded==total)
    gotoandplay("Scene 2",1);
    sorry for getting the code and coment mixed up.

  • Help me about AS3 code of 24 hour countdown timer.

    Hi,
    I'm a beginner at flash.
    i  just wanna ask about making 24hours countdown clock.
    what i want is to make it only 24hour countdown clock and when it reaches the time it will start again.(every day)
    and The start time is 2 o'clok(2 pm) every single day.(for the pacific time)
    and I found this code from (http://forums.adobe.com/message/4116774 )
    It's similar with what i want but even I tried, I can't change for mind...
    and I want using hundredths too.
    so here is the code.
    Please help me,Thank you.
    var endDate:Date = new Date(new Date().getTime()+24*60*60*1000);
    var countdownTimer:Timer = new Timer(1000);
    countdownTimer.addEventListener(TimerEvent.TIMER, updateTime);
    countdownTimer.start();
    function updateTime(e:TimerEvent):void
              var now:Date = new Date();
    if(now.getTime()>endDate.getTime()){
         time_txt.text = "00:00:00";
    countdownTimer.stop();
    return
              var timeLeft:Number = endDate.getTime() - now.getTime();
              var hundredth:Number = Math.floor(timeLeft / 10);
              var seconds:Number = Math.floor(hundredth / 1000);
              var minutes:Number = Math.floor(seconds / 60);
              var hours:Number = Math.floor(minutes / 60);
              seconds %= 60;
              minutes %= 60;
              var fs:String = hundredth.toString();
              var sec:String = seconds.toString();
              var min:String = minutes.toString();
              var hrs:String = hours.toString();
              if (fs.length < 2) {
                        sec = "0" + fs;
              if (sec.length < 2) {
                        sec = "0" + sec;
              if (min.length < 2) {
                        min = "0" + min;
              if (hrs.length < 2) {
                        hrs = "0" + hrs;
              var time:String = hrs + ":" + min + ":" + sec;
              time_txt.text = time;

    Thank U , and so sorry I have problem.,..
    It Just stop and It was not start again..........What should I do?
    because I wanna auto play every single day.
    It should be end at 2pm,and then the countdown starts again for next day.
    var endDate:Date = new Date();
    endDate.setHours(14);
    endDate.setMinutes(0);
    endDate.setSeconds(0);
    endDate.setMilliseconds(0);
    var countdownTimer:Timer = new Timer(10);
    countdownTimer.addEventListener(TimerEvent.TIMER, updateTime);
    countdownTimer.start();
    function updateTime(e:TimerEvent):void
              var now:Date = new Date();
              if(now.getTime()>endDate.getTime()){
              time_txt.text = "00:00:00:00";
              countdownTimer.stop();
              return
              var timeLeft:Number = endDate.getTime() - now.getTime();
              var milliseconds:Number = Math.floor(timeLeft /10);
              var seconds:Number = Math.floor(milliseconds / 100);
              var minutes:Number = Math.floor(seconds / 60);
              var hours:Number = Math.floor(minutes / 60);
              milliseconds %= 100;
              seconds %= 60;
              minutes %= 60;
              var mil:String = milliseconds.toString();
              var sec:String = seconds.toString();
              var min:String = minutes.toString();
              var hrs:String = hours.toString();
              if (mil.length < 2) {
                        mil = "0" + mil;
              if (sec.length < 2) {
                        sec = "0" + sec;
              if (min.length < 2) {
                        min = "0" + min;
              if (hrs.length < 2) {
                        hrs = "0" + hrs;
              var time:String = hrs + ":" + min + ":" + sec + ":" + mil;
              time_txt.text = time;

  • Help Needed with HTML code for Image Positioning

    Hi All,
    Need a little help with some code for positioning images.
    I initially used the following:
    This is fine, but the border automatically puts a black border around the photo - how do I change it to white? Is there a way to set margins too, to prevent the text butting up against the photo?
    I also used the following code with success:
    <style type="text/css"
    img
    float:right;
    border:2px solid white;
    margin: 0px 0px 15px 20px
    </style>
    This code works, however the problem with it is it is not individual to just one photo - it moved all my photos and on that page, I wanted one photo floated to left and another to the right.
    If I use this code, how can I make it photo specific, so that it only affects the placement, margins and borders of one photo?
    Any help would be great.
    Thanks

    CSS question, not iWeb question. Regardless, use inline CSS styling for the image. You can also wrap the image in its own tag and declare an id or simply declare an id for the img tag, then set the style for the id_name:
    <style type="text/css"
    img#id_name
    float:right;
    border:2px solid white;
    margin: 0px 0px 15px 20px
    </style>
    If you want to control the style of more than one image on a page but not all then use a class instead of an id.
    the border automatically puts a black border around the photo - how do I change it to white? Is there a way to set margins too, to prevent the text butting up against the photo?
    I believe you have discovered a solution for this according to your CSS code. You have set the border to white by looking at the code and adjusting it appropriately. Your margin is declared in the CSS also, adjust the pixels appropriately.
    Read up some more on CSS to educate yourself further. I suggest w3schools.com or a CSS forum instead of the iWeb forum if you have CSS questions. It's kind of like if you drive your auto to the supermarket so you decide to go to the supermarket and ask everyone in the produce section to help when you have car problems. All the supermarket does is provide a place to park your auto. If you have car problems then ask a mechanic. iWeb (and most of its users) doesn't specialize in code, it simply provides an area for you to place it. Granted you might get lucky and find a mechanic in the produce section of the supermarket, but you're more likely to find a specialist at an auto swap meet (or CSS coding forum)!

  • Help needed about regex usage.

    hi all,
    i am kind of new to java.util.regex, and i can't solve this problem:
    i have a big string, that actually represents the text code of a method. in this method, i have an object, called, let's say "visitor" and i call several non static methods of it. i need to search this string and put into an ArrayList<String> all the occurrences of visitor, the method called, and its parameters.
    if i wasn't very clear, here is an example:
    the input string: "public void test_add()
              TemplateTestMethodVisitor visitor = new TemplateTestMethodVisitor(XMLArrayListTest.class);
              XMLArrayListComparer comparer = new XMLArrayListComparer();
              while(visitor.moveNext())
                   fillArrayList(visitor);
                   Exception exception = null;
                   try
                        _testedArray.add(visitor.getParameterAsInt("position"), ValueFactory.getMemberValue(visitor,
                                  visitor.getParameterAsString("type"), "ElementValue"));
                   catch(Exception e)
                        exception = e;
                   ExceptionValidator.validateException(visitor, exception);
                   if(exception != null)
                        continue;
                   VisitorAssert.assertEquals(visitor, "The content of the array list is not as expected.",
                             visitor.getResultAsCollectionData("List"), _testedArray, comparer);
    and i need to obtain an ArrayList<String> with {"visitor.moveNext()", "visitor.getParameterAsInt("position")" , "visitor.getParameterAsString("type")", "visitor.getResultAsCollectionData("List")"}. and it would be very helpful for me to do this using regex, but i can't think of a right pattern...
    thank you all.

    import java.io.*;
    import java.util.regex.*;
    public class TestRegexp {
      public static void main(String[] argv) {
        Pattern p = Pattern.compile("visitor\\..*?\\(.*?\\)");
        try {
          BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
          String line;
          while((line = in.readLine()) != null) {
            Matcher m = p.matcher(line);
            while(m.find()) {
              System.out.println(m.group());
        } catch(IOException e) {
          e.printStackTrace();
    }

  • Help needed about using wifi

    Please can somebody tell me in words of one syllable exactly what I need to start using an ipad for surfing the internet?  I want to use it to access web pages while I'm out and about.  Do I need a contract with a phone carrier?  Does it need to be a mobile phone carrier?  Could I use my landline number if I have broadband access on that?
    I just can't work out whether I can use the ipad straight away without doing anything or whether I need to involve a mobile or landline/broadband supplier.
    Please help - I'm soo confused.

    a Local area network also called LAN network is what most people use in their house
    it's cables you connect 1 or more computers to get Internet and  access files from eachother
    wifi id 100% that!
    just without the cable
    you have wifi router with a password on
    you go into the settings on the ipad and choose the wifi router name on the list and type in the password
    and you're able to go online
    if you are not within reach of your wifi network you need to reply on public wifi networks if any are aviable where you are at the given time some would be free some would require you to pay them for service
    you only need to contact a phone carrier if you don't wish to use wifi because you have an ipad which along side wifi support 3g internet then you need to contact a carrier and get a micro sim and a contract
    if you already have an mobile phone which qualify as a smart phone you may be able to use that as a wifi hotspot to get on the internet using the phone but in some places this require you to pay extre to your phone contract

  • Help needed about thread priority

    Hello, could someone help me with the priorities in java? I got 10 levels in total(1-10), but I do need at least 20 levels for my multiple threads program.
    Thank you for your kind help in advance.

    First, let me apologize if I am incorrect, but it seems that the native Thread implementation restricts you to 10 priorities regardless.
    However, you can do just about anything you envision, but it will require some implementation on your part.
    You could implement a subclass of thread that contains your priority (which could be from 1-20). You could then maintain a ThreadManager that would store all running threads, and would accept requests to start and stop threads. The ThreadManager could make decisions about which threads to run, which to interrupt, which to sleep, etc., based on your priority value.
    This sounds like alot to swallow, but I'm sure it's doable if you understand threads.

  • Help needed with Random code generator

    Hello!
    I need to find a script that allows me to show a 5 letter
    code after 20 mouse clicks.
    The mouse clicks I have sorted out, but now I would like to
    after 20 clicks show a different code from de 5 codes (ex: DRE6U;
    VG4T55, etc.) I have to display.
    Can someone help me please?
    Thanks!

    :

  • Help needed on java code

    Hi all,
    In the below code, if condition is failing. what might be the reason.......??
    String mAmtBaseStr = "-00000000000200.00";
              if (mAmtBaseStr.substring(0).equals("-"))
                   //strip "-" from first char
                   int len1 = mAmtBaseStr.length();
                   mAmtBaseStr = mAmtBaseStr.substring((1 - 0),len1);
                   //put the stripped "-" at last
                   mAmtBaseStr = mAmtBaseStr + "-";
    I tried other options like,
              if (mAmtBaseStr.substring(0,1).equals("-"))  etc etc......

    Hi,
            This code fails because of this reason
    _problem1 _
    String mAmtBaseStr = "-00000000000200.00";
    mAmtBaseStr.substring(0)-------> -00000000000200.00 [as substring(0) returns entire string starting from index zero.]
    when you are writing
    if (mAmtBaseStr.substring(0).equals("-"))
         You are tryring to check if the value mAmtBaseStr.substring(0) [ "-00000000000200.00"] is equal to string "-" or not.
          As you can see the strings are not equal the if condition never returns you true value.
    _Problem2_
    you are nowhere checking whether the inbound string is null or empty. In case the string comes as null or empty java will throw an exception and your mapping will fail. So if input string does not begin with an hyphen you need to pass it as it is
    Thus I would modify your code a little bit to make it work
    public static String removeHyphen(String mAmtBaseStr)
              if (mAmtBaseStr!=null && mAmtBaseStr!="" && mAmtBaseStr.substring(0,1).equals("-"))
                   //strip "-" from first char
                   int len1 = mAmtBaseStr.length();
                   mAmtBaseStr = mAmtBaseStr.substring((1 - 0),len1);
                   //put the stripped "-" at last
                   mAmtBaseStr = mAmtBaseStr + "-";
              return mAmtBaseStr;
    This code works and produces required output
    input: -00000000000200.00
    output: 00000000000200.00-
    Regards
    Anupam

  • Help needed about Nearline storage in BW 3.5.

    Hi Guys,
    Can you please provide me with some documents for implementing Nearline storage scenarios in BW 3.5.
    Thanks,
    Punkuj...

    Hi Punkuj,
    We use Nearline storage to store the data that is never been user or used very rarely.For example we have data for year 1960 in the data targets and now it is 2007.So mostly the management never uses this data or they uses them very rearly.So when we retrive the data from the data targets the DB unnecessarly reads the data every time when a report is generated on those targets.So to avoid this performance issue we store that kind of data in a seperate disk and we access that data using a multi provider when we need that in Report.This data is also known as Dormat data.
    Hope this will help you.
    Thanks and Regards
    SandeepKumar.G

  • Help needed about user exits

    Hi frnds.
    For long time i have been searching for user exits for following txns. If any body have some idea i will appreciate it a lot.
    1.ME01(MAINTAIN SOURCE LIST)
    2.ME11(CREATE INFO RECORD)
    3.MB01(GR for PO)
    4.ME31(CREATE ONLINE AGREEMENT)
    5.ME51(CREATE PURCHASE REQUISITION)
    Waiting for your replies.
    Regards,
    Arpit

    Hi Arpit,
    You can use following code to find user-exits in any SAP standard transactions...
    Finding the user-exits of a SAP transaction code
    Enter the transaction code in which you are looking for the user-exit
    and it will list you the list of user-exits in the transaction code.
    Also a drill down is possible which will help you to branch to SMOD.
    Written by : SAP Basis, ABAP Programming and Other IMG Stuff
                 http://www.sap-img.com
    report zuserexit no standard page heading.
    tables : tstc, tadir, modsapt, modact, trdir, tfdir, enlfdir.
             tables : tstct.
    data : jtab like tadir occurs 0 with header line.
    data : field1(30).
    data : v_devclass like tadir-devclass.
    parameters : p_tcode like tstc-tcode obligatory.
    select single * from tstc where tcode eq p_tcode.
    if sy-subrc eq 0.
       select single * from tadir where pgmid = 'R3TR'
                        and object = 'PROG'
                        and obj_name = tstc-pgmna.
       move : tadir-devclass to v_devclass.
          if sy-subrc ne 0.
             select single * from trdir where name = tstc-pgmna.
             if trdir-subc eq 'F'.
                select single * from tfdir where pname = tstc-pgmna.
                select single * from enlfdir where funcname =
                tfdir-funcname.
                select single * from tadir where pgmid = 'R3TR'
                                   and object = 'FUGR'
                                   and obj_name eq enlfdir-area.
                move : tadir-devclass to v_devclass.
              endif.
           endif.
           select * from tadir into table jtab
                         where pgmid = 'R3TR'
                           and object = 'SMOD'
                           and devclass = v_devclass.
            select single * from tstct where sprsl eq sy-langu and
                                             tcode eq p_tcode.
            format color col_positive intensified off.
            write:/(19) 'Transaction Code - ',
                 20(20) p_tcode,
                 45(50) tstct-ttext.
                        skip.
            if not jtab[] is initial.
               write:/(95) sy-uline.
               format color col_heading intensified on.
               write:/1 sy-vline,
                      2 'Exit Name',
                     21 sy-vline ,
                     22 'Description',
                     95 sy-vline.
               write:/(95) sy-uline.
               loop at jtab.
                  select single * from modsapt
                         where sprsl = sy-langu and
                                name = jtab-obj_name.
                       format color col_normal intensified off.
                       write:/1 sy-vline,
                              2 jtab-obj_name hotspot on,
                             21 sy-vline ,
                             22 modsapt-modtext,
                             95 sy-vline.
               endloop.
               write:/(95) sy-uline.
               describe table jtab.
               skip.
               format color col_total intensified on.
               write:/ 'No of Exits:' , sy-tfill.
            else.
               format color col_negative intensified on.
               write:/(95) 'No User Exit exists'.
            endif.
          else.
              format color col_negative intensified on.
              write:/(95) 'Transaction Code Does Not Exist'.
          endif.
    at line-selection.
       get cursor field field1.
       check field1(4) eq 'JTAB'.
       set parameter id 'MON' field sy-lisel+1(10).
       call transaction 'SMOD' and skip first   screen.
    *---End of Program
    Regards,
    Sriram

  • Help needed about JSTL

    We have tomcat server, in which we are running some jsp files( which consists some bean classes). We want to convert those bean classes into jsp tag libraries.Even we have installed jakarta tag libraries , but we are unable to run jstl files. Help wanted urgently.
    ThanX in advance.

    Your note has two problems in it: (1) Custom tag libraries of your own making, and (2) Running JSTL. I'd like to address the second of the two.
    I'm not sure what you downloaded from Jakarta. I'll assume that you're using JSTL 1.0.3 standard JSTL. (That's what I'm using.) The ZIP file I downloaded has a lib directory with 10 JARs in it. You'll need to put all 10 of them into your WEB-INF/lib directory for your app to use them.
    You don't have to put a <taglib> in your web.xml, and you don't need to dig out any TLD files. The TLD files you need are already inside the standard.jar that you downloaded with the JSTL. You should not be trying to re-create what is already correct.
    The pages that use the JSTL should have a tag like this near the top:
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>The uri attribute value must match the value in the c.tld file located inside standard.jar exactly:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE taglib
      PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
      "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
    <taglib>
      <tlib-version>1.0</tlib-version>
      <jsp-version>1.2</jsp-version>
      <short-name>c</short-name>
      <uri>http://java.sun.com/jstl/core</uri>
    <!-- etc. -->MOD

  • Help needed about Java Threads ?

    Hi,
    I have a p2p java program that contains many classes, A.java, B.java, etc. It works fine when i send or recieve to eachother one at a time, but I would like to be able to send/recieve things at the same time. So i would probably need to use Java Threads. Can somebody please show me how this is done. I would really appriciate it. Thanks!!
    import java.net.*;
    import java.io.*;
    import java.lang.*;
    public class A {
            private static String hostname; //host name
            public A () { }
           public static void send() throws IOException {
                    //send code here
            public static void receive() throws IOException{               
                    //receive code here
            public static void main(String args[]) throws IOException {
                    //do both send/recieve at the same time?
                    send();
                    receieve();
    }

    Well, I think( this is comming out my rear ) that the scope of the recieve() call is not in the main method anymore but instead in class you've created with "new Thread()" and it's throwing from the public void run() instead. This is a good example of complicated code. I would do this:
    (Untested code)
    import java.net.*;
    import java.io.*;
    import java.lang.*;
    public class A implements Runnable { // <--- NEW
            private static String hostname; //host name
            public A () { }
            public static void send() throws IOException {
                    //send code here
            public static void receive() throws IOException{               
                    //receive code here
            public static void main(String args[]) throws IOException {
                    //do both send/recieve at the same time?
                    new Thread( this ).start();
                    send();
            /******** NEW ************/
            public void run()
                while( keepListening )
                    // It's the assumption that recieve() is
                    // throwing the IOException from some net calls
                    try {
                       recieve();
                    } catch( IOException ioe ) {
                       System.out.println( "IOException in run()\n" + ioe.getMessage();
    }

Maybe you are looking for