kindly reply what is focuslost and its funcn
-
:doh: is it so important to use focus gained and focuslost in program actually i had to make an entry in my data base that is of word meanin antonyms and synonyms amd i am nto getting it correctly pls explain me the work of focuslost and focusgained if possible or just send me a link i am giving u the code part where i am using it import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; public class AddWord extends JInternalFrame implements ActionListener, FocusListener { private JPanel pWord = new JPanel (); private JLabel lbWord, lbMean, lbSynonym, lbAntonym; private JTextField txtWord, txtMean, txtSynonym ,txtAntonym; private JButton btnOk, btnCancel; private ButtonGroup bg; private String[] cn =new String[100]; private Statement st; //Statement for Getting the Required Table. private long id = 0; //To Hold the Word. private int i,j,ref=0; public AddWord (Connection con) { //super (Title, Resizable, Closable, Maximizable, Iconifiable) super ("Add New Word", false, true, false, true); setSize (325, 250); //Setting the Form's Labels. lbWord = new JLabel ("Word :"); lbWord.setForeground (Color.black); lbWord.setBounds (15, 15, 100, 20); lbMean = new JLabel ("Meaning:"); lbMean.setForeground (Color.black); lbMean.setBounds (15, 45, 100, 20); lbSynonym = new JLabel ("Synonym:"); lbSynonym.setForeground (Color.black); lbSynonym.setBounds (15, 75, 100, 20); lbAntonym = new JLabel ("Antonym:"); lbAntonym.setForeground (Color.black); lbAntonym.setBounds (15, 105, 100, 20); txtWord = new JTextField (); txtWord.setHorizontalAlignment (JTextField.RIGHT); txtWord.addFocusListener (this); txtWord.setBounds (120, 15, 175, 25); txtMean = new JTextField (); txtMean.setBounds (120, 45, 175, 25); txtSynonym = new JTextField (); txtSynonym.setBounds (120, 75, 175, 25); txtAntonym = new JTextField (); txtAntonym.setBounds (120, 75, 175, 25); btnOk = new JButton ("OK"); btnOk.setBounds (50, 175, 100, 25); btnOk.addActionListener (this); btnCancel = new JButton ("Cancel"); btnCancel.setBounds (170, 175, 100, 25); btnCancel.addActionListener (this); txtWord.addKeyListener (new KeyAdapter () { public void keyTyped (KeyEvent ke) { char c = ke.getKeyChar (); if (! ((Character.isLetter (c)) || (c == KeyEvent.VK_BACK_SPACE))) { getToolkit().beep (); ke.consume (); } } } ); txtMean.
-
:doh: is it so important to use focus gained and focuslost in program actually i had to make an entry in my data base that is of word meanin antonyms and synonyms amd i am nto getting it correctly pls explain me the work of focuslost and focusgained if possible or just send me a link i am giving u the code part where i am using it import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; public class AddWord extends JInternalFrame implements ActionListener, FocusListener { private JPanel pWord = new JPanel (); private JLabel lbWord, lbMean, lbSynonym, lbAntonym; private JTextField txtWord, txtMean, txtSynonym ,txtAntonym; private JButton btnOk, btnCancel; private ButtonGroup bg; private String[] cn =new String[100]; private Statement st; //Statement for Getting the Required Table. private long id = 0; //To Hold the Word. private int i,j,ref=0; public AddWord (Connection con) { //super (Title, Resizable, Closable, Maximizable, Iconifiable) super ("Add New Word", false, true, false, true); setSize (325, 250); //Setting the Form's Labels. lbWord = new JLabel ("Word :"); lbWord.setForeground (Color.black); lbWord.setBounds (15, 15, 100, 20); lbMean = new JLabel ("Meaning:"); lbMean.setForeground (Color.black); lbMean.setBounds (15, 45, 100, 20); lbSynonym = new JLabel ("Synonym:"); lbSynonym.setForeground (Color.black); lbSynonym.setBounds (15, 75, 100, 20); lbAntonym = new JLabel ("Antonym:"); lbAntonym.setForeground (Color.black); lbAntonym.setBounds (15, 105, 100, 20); txtWord = new JTextField (); txtWord.setHorizontalAlignment (JTextField.RIGHT); txtWord.addFocusListener (this); txtWord.setBounds (120, 15, 175, 25); txtMean = new JTextField (); txtMean.setBounds (120, 45, 175, 25); txtSynonym = new JTextField (); txtSynonym.setBounds (120, 75, 175, 25); txtAntonym = new JTextField (); txtAntonym.setBounds (120, 75, 175, 25); btnOk = new JButton ("OK"); btnOk.setBounds (50, 175, 100, 25); btnOk.addActionListener (this); btnCancel = new JButton ("Cancel"); btnCancel.setBounds (170, 175, 100, 25); btnCancel.addActionListener (this); txtWord.addKeyListener (new KeyAdapter () { public void keyTyped (KeyEvent ke) { char c = ke.getKeyChar (); if (! ((Character.isLetter (c)) || (c == KeyEvent.VK_BACK_SPACE))) { getToolkit().beep (); ke.consume (); } } } ); txtMean.
-
:doh: is it so important to use focus gained and focuslost in program actually i had to make an entry in my data base that is of word meanin antonyms and synonyms amd i am nto getting it correctly pls explain me the work of focuslost and focusgained if possible or just send me a link i am giving u the code part where i am using it import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; public class AddWord extends JInternalFrame implements ActionListener, FocusListener { private JPanel pWord = new JPanel (); private JLabel lbWord, lbMean, lbSynonym, lbAntonym; private JTextField txtWord, txtMean, txtSynonym ,txtAntonym; private JButton btnOk, btnCancel; private ButtonGroup bg; private String[] cn =new String[100]; private Statement st; //Statement for Getting the Required Table. private long id = 0; //To Hold the Word. private int i,j,ref=0; public AddWord (Connection con) { //super (Title, Resizable, Closable, Maximizable, Iconifiable) super ("Add New Word", false, true, false, true); setSize (325, 250); //Setting the Form's Labels. lbWord = new JLabel ("Word :"); lbWord.setForeground (Color.black); lbWord.setBounds (15, 15, 100, 20); lbMean = new JLabel ("Meaning:"); lbMean.setForeground (Color.black); lbMean.setBounds (15, 45, 100, 20); lbSynonym = new JLabel ("Synonym:"); lbSynonym.setForeground (Color.black); lbSynonym.setBounds (15, 75, 100, 20); lbAntonym = new JLabel ("Antonym:"); lbAntonym.setForeground (Color.black); lbAntonym.setBounds (15, 105, 100, 20); txtWord = new JTextField (); txtWord.setHorizontalAlignment (JTextField.RIGHT); txtWord.addFocusListener (this); txtWord.setBounds (120, 15, 175, 25); txtMean = new JTextField (); txtMean.setBounds (120, 45, 175, 25); txtSynonym = new JTextField (); txtSynonym.setBounds (120, 75, 175, 25); txtAntonym = new JTextField (); txtAntonym.setBounds (120, 75, 175, 25); btnOk = new JButton ("OK"); btnOk.setBounds (50, 175, 100, 25); btnOk.addActionListener (this); btnCancel = new JButton ("Cancel"); btnCancel.setBounds (170, 175, 100, 25); btnCancel.addActionListener (this); txtWord.addKeyListener (new KeyAdapter () { public void keyTyped (KeyEvent ke) { char c = ke.getKeyChar (); if (! ((Character.isLetter (c)) || (c == KeyEvent.VK_BACK_SPACE))) { getToolkit().beep (); ke.consume (); } } } ); txtMean.
The focusLost event is triggered whenever the focus (control with attention) is moved out of the active control to another control (making the other control the active one) - for example, if you are typing in a textbox and then click elsewhere on the form (another textbox or a button or a scrollbar...) the original textbox loses focus and it's lostfucus event will be raised. In your code, it appearears that you expect a numeric ID to bye typed, then whien fucus is moved you query for a record containing that value for the BId field. A couple of problems: 1. if there is no such record, the rs.next will likely throw an exception (no record to move to). You should check for EOF first. 2. you never close the recordset. You should add a finally block that calls rs.Close(). You never explained what "doen't work" means, so I hope this helps Absolute faith corrupts as absolutely as absolute power Eric Hoffer All that is necessary for the triumph of evil is that good men do nothing. Edmund Burke
-
Firstly noone is going to do your homework for you. Secondly, you're much more likely to get a response on a java site than an MS centric one.
What is System Requirements of Mobile Pc sharing(pc mouse ,keyboard throug mobile) khalid