Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. IT & Infrastructure
  4. kindly reply what is focuslost and its funcn

kindly reply what is focuslost and its funcn

Scheduled Pinned Locked Moved IT & Infrastructure
javadatabasequestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    keshava shukla
    wrote on last edited by
    #1

    :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.

    D R 2 Replies Last reply
    0
    • K keshava shukla

      :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.

      D Offline
      D Offline
      Dan Neely
      wrote on last edited by
      #2

      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.

      M 1 Reply Last reply
      0
      • K keshava shukla

        :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.

        R Offline
        R Offline
        Rob Graham
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • D Dan Neely

          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.

          M Offline
          M Offline
          Muhammad Khalid Latif
          wrote on last edited by
          #4

          What is System Requirements of Mobile Pc sharing(pc mouse ,keyboard throug mobile) khalid

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups