java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
java.lang.IndexOutOfBoundsException
- All Implemented Interfaces:
- Serializable
- Direct Known Subclasses:
- ArrayIndexOutOfBoundsException, StringIndexOutOfBoundsException
- See Also:
- Top Examples, Source Code
public IndexOutOfBoundsException() - Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1960]incompatabletypes By visalacute { at } gmail { dot } com on 2008/03/25 01:16:42 Rate
if ( mtime==null ) mtime=""; if ( etime==null ) etime=""; String tim=""; if ( mtime.equals ( "selected-selected" ) ) mtime+=mtime+","; if ( etime.equals ( "selected-selected" ) ) etime+=etime; int time=tim.substring ( 0,tim.length ( ) -1 ) ; [1995]Getting values from personList (its not working is anybody help me) By shakeel { dot } ibd { dot } pk { at } gmail { dot } com on 2009/05/05 00:07:14 Rate
import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.*; public class ProgramDAO { JFrame frame; JLabel lblId, lblName, lblFname, lblSex, lblAddress, lblPhone; JTextField txtId, txtName, txtFname, txtSex, txtAddress, txtPhone; JButton cmdAdd, cmdSearch, cmdDelete, cmdExit; JPanel panel,panelTwo; public void initGUI ( ) { JFrame.setDefaultLookAndFeelDecorated ( false ) ; lblId = new JLabel ( " ID: " ) ; lblName = new JLabel ( " Name: " ) ; lblFname = new JLabel ( " Father Name: " ) ; lblSex = new JLabel ( " Sex " ) ; lblAddress = new JLabel ( " Address: " ) ; lblPhone = new JLabel ( " Phone # " ) ; txtId = new JTextField ( ) ; txtName = new JTextField ( ) ; txtFname = new JTextField ( ) ; txtSex = new JTextField ( ) ; txtAddress = new JTextField ( ) ; txtPhone = new JTextField ( ) ; cmdAdd = new JButton ( " Add Record " ) ; cmdSearch = new JButton ( " Search " ) ; cmdDelete = new JButton ( " Delete " ) ; cmdExit = new JButton ( " Exit " ) ; panel = new JPanel ( new GridLayout ( 8,7 ) ) ; panel.add ( lblId ) ; panel.add ( txtId ) ; panel.add ( lblName ) ; panel.add ( txtName ) ; panel.add ( lblFname ) ; panel.add ( txtFname ) ; panel.add ( lblSex ) ; panel.add ( txtSex ) ; panel.add ( lblAddress ) ; panel.add ( txtAddress ) ; panel.add ( lblPhone ) ; panel.add ( txtPhone ) ; panelTwo = new JPanel ( new GridLayout ( 1,4 ) ) ; panelTwo.add ( cmdAdd ) ; panelTwo.add ( cmdSearch ) ; panelTwo.add ( cmdDelete ) ; panelTwo.add ( cmdExit ) ; frame = new JFrame ( ) ; frame.setLocationRelativeTo ( null ) ; frame.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE ) ; Container con = frame.getContentPane ( ) ; con.setLayout ( new BorderLayout ( ) ) ; con.add ( panel, BorderLayout.CENTER ) ; con.add ( panelTwo, BorderLayout.SOUTH ) ; WindowHandler wHandler = new WindowHandler ( ) ; frame.addWindowListener ( wHandler ) ; KeyHandler kHandler = new KeyHandler ( ) ; cmdAdd.addActionListener ( kHandler ) ; cmdSearch.addActionListener ( kHandler ) ; cmdDelete.addActionListener ( kHandler ) ; cmdExit.addActionListener ( kHandler ) ; frame.pack ( ) ; frame.setSize ( 500,200 ) ; frame.setVisible ( true ) ; } private class KeyHandler implements ActionListener { public void actionPerformed ( ActionEvent event ) { if ( event.getSource ( ) == cmdExit ) { JOptionPane.showConfirmDialog ( null," *** are you sure! *** " ) ; System.exit ( 0 ) ; } String vid = txtId.getText ( ) ; String vnm = txtName.getText ( ) ; String vfn = txtFname.getText ( ) ; String vsx = txtSex.getText ( ) ; String add = txtAddress.getText ( ) ; String ph = txtPhone.getText ( ) ; PersonInfor person = new PersonInfor ( vid, vnm, vfn, vsx, add, ph ) ; if ( event.getSource ( ) == cmdAdd ) { try { DAO dao = new DAO ( ) ; dao.insert ( person ) ; JOptionPane.showMessageDialog ( null, " &&& This record has been inserted! &&& " ) ; } catch ( Exception ex ) { System.out.println ( ex ) ; } } //String vid = txtId.getText ( ) ; //System.out.println ( vid ) ; ArrayList personList = new ArrayList ( ) ; if ( event.getSource ( ) == cmdSearch ) { try { DAO dao = new DAO ( ) ; personList = dao.search ( vid ) ; if ( personList.isEmpty ( ) ) { JOptionPane.showMessageDialog ( null, " Array List is empty! " ) ; } for ( int i=0; i < = personList.size ( ) ; i++ ) { PersonInfor p = ( PersonInfor ) personList.get ( i ) ; System.out.println ( p ) ; System.out.println ( "," ) ; } System.out.println ( ) ; System.out.println ( personList.size ( ) ) ; //String v1.setText ( personList.get ( 0 ) ) ; //String v2.setText ( personList.get ( 1 ) ) ; //v1 = personList.get ( 0 ) ; //v2 = personList.get ( 1 ) ; //txtId.setText ( personList.get ( 0 ) ) ; //txtName.setText ( personList.get ( 1 ) ) ; //txtFname.setString ( personList.get ( 2 ) ) ; //txtSex.setString ( personList.get ( 3 ) ) ; //txtAddress.setString ( personList.get ( 4 ) ) ; //txtPhone.setString ( personList.get ( 5 ) ) ; } catch ( Exception ex ) { System.out.println ( ex ) ; } } if ( event.getSource ( ) == cmdDelete ) { try { DAO dao = new DAO ( ) ; dao.removeRecord ( vid ) ; JOptionPane.showMessageDialog ( null, " &&& This record has been removed! &&& " ) ; } catch ( Exception ex ) { System.out.println ( ex ) ; } } } } public ProgramDAO ( ) { initGUI ( ) ; } public static void main ( String args [ ] ) { ProgramDAO prgDAO = new ProgramDAO ( ) ; } }
public IndexOutOfBoundsException(String s) - Geek's Notes:
- Description Add your codes or notes Search More Java Examples
| Popular Tags |