Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextArea never looses focus  RSS feed

 
Philip Pross
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple gui that is giving me problems, for some reason when I reset the componments one of my JTextAreas still has focus. If I go and click to write in JTextArea B, theres still another cusor in the A ..... ??? And when I go back to the A, and try to write in A, it appends in the B. Why would the cusor still thinks its in the other JTextArea, Basically now, I have two cusors in my Frame ......... Can any one help me ??? As for these two JTextAreas, I'm also using ScrollPanes, setLineWrap, setWrapStyleWord, and
getViewport().
Thanks
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the code? I never had this problem. Which OS do you use?
 
Philip Pross
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heres a sample of my code, cause the whole thing is way too long ....
JPanel pEdit = new JPanel();

static Document EDtaProbDoc;
static Document EDtaInteDoc;
static JScrollPane EDspProb = new JScrollPane();
static JScrollPane EDspInte = new JScrollPane();
static JLabel EDlbNoAppel = new JLabel();
static JLabel EDlbContact = new JLabel();
static JLabel EDlbNoCon = new JLabel();
static JLabel EDlbCli = new JLabel();
static JLabel EDlbTel = new JLabel();
static JLabel EDlbPost = new JLabel();
static JLabel EDlbDetEquip = new JLabel();
static JLabel EDlbDetProb = new JLabel();
static JLabel EDlbDetInte = new JLabel();
static JComboBox EDchNoAppel = new JComboBox();
static JTextField EDtfContact = new JTextField();
static JTextField EDtfTel = new JTextField();
static JTextField EDtfPost = new JTextField();
static JTextField EDtfAutre = new JTextField();
static JTextField EDtfCli = new JTextField();
static JTextField EDtfNoCon = new JTextField();

static JComboBox EDchDetEquip = new JComboBox();
static JTextArea EDtaDetProb = new JTextArea();
static JTextArea EDtaDetInte = new JTextArea();

static JButton EDbtSau = new JButton();


ADDING TO PANEL
pEdit.setLayout(null);
EDlbNoAppel.setText("Number call");
EDlbNoAppel.setBounds(new Rectangle(75, 38, 125, 23));
EDlbContact.setText("Contact");
EDlbContact.setBounds(new Rectangle(426, 38, 125, 23));
EDlbNoCon.setText("No Contrat");
EDlbNoCon.setBounds(new Rectangle(75, 75, 125, 23));
EDlbCli.setText("Client");
EDlbCli.setBounds(new Rectangle(75, 57, 125, 23));
EDlbTel.setText("T�l�phone");
EDlbTel.setBounds(new Rectangle(426, 58, 125, 23));
EDlbPost.setText("Post");
EDlbPost.setBounds(new Rectangle(426, 76, 125, 23));
EDlbDetEquip.setText("Equipement");
EDlbDetEquip.setBounds(new Rectangle(75, 110, 125, 23));
EDlbDetProb.setText("Problem ");
EDlbDetProb.setBounds(new Rectangle(75, 145, 125, 23));
EDlbDetInte.setText("Intervention");
EDlbDetInte.setBounds(new Rectangle(75, 300, 125, 23));
EDchNoAppel.setBounds(new Rectangle(149, 41, 235, 20));
EDtfContact.setBounds(new Rectangle(500, 44, 235, 20));
EDtfNoCon.setBounds(new Rectangle(149, 79, 235, 20));
EDtfCli.setBounds(new Rectangle(149, 61, 235, 20));
EDtfTel.setBounds(new Rectangle(500, 62, 235, 20));
EDtfTel.setToolTipText("Format (###)###-####");
EDtfPost.setBounds(new Rectangle(500, 80, 235, 20));
EDchDetEquip.setBounds(new Rectangle(186, 110, 550, 20));
EDtaDetProb.setBounds(new Rectangle(77, 170, 657, 115));
EDtaDetProb.setLineWrap(true);
EDtaDetProb.setWrapStyleWord(true);
EDspProb.setBounds(new Rectangle(77, 170, 657, 115));
EDspProb.getViewport().add(EDtaDetProb, null);
EDtaDetInte.setBounds(new Rectangle(77, 325, 657, 115));
EDtaDetInte.setLineWrap(true);
EDtaDetInte.setWrapStyleWord(true);
EDspInte.setBounds(new Rectangle(77, 325, 657, 115));
EDspInte.getViewport().add(EDtaDetInte, null);
EDtaInteDoc = EDtaDetInte.getDocument();
EDtaProbDoc = EDtaDetProb.getDocument();
KeyStroke key = KeyStroke.getKeyStroke("ENTER");
EDtaDetInte.getInputMap().put(key,"none");
KeyStroke key1 = KeyStroke.getKeyStroke("ENTER");
EDtaDetProb.getInputMap().put(key1,"none");
EDbtSau.setText("Sauvegarder");
EDbtSau.setToolTipText("Mise � jour de cet appel");
EDbtSau.setBounds(new Rectangle(615, 450, 118, 30));
EDbtSau.addActionListener(this);
EDbtSau.setEnabled(false);
EDtfCli.setEditable(false);
EDtfNoCon.setEditable(false);
EDchNoAppel.addItemListener(this);
EDchDetEquip.addItemListener(this);

pEdit.add(EDchNoAppel, null);
pEdit.add(EDtfContact, null);
pEdit.add(EDtfNoCon, null);
pEdit.add(EDlbNoCon, null);
pEdit.add(EDlbContact, null);
pEdit.add(EDlbNoAppel, null);
pEdit.add(EDtfCli, null);
pEdit.add(EDtfPost, null);
pEdit.add(EDlbPost, null);
pEdit.add(EDlbTel, null);
pEdit.add(EDlbCli, null);
pEdit.add(EDtfTel, null);
pEdit.add(EDchDetEquip, null);
pEdit.add(EDlbDetEquip, null);
pEdit.add(EDlbDetProb, null);
pEdit.add(EDtaDetProb, null);
pEdit.add(EDtaDetInte, null);
pEdit.add(EDbtSau, null);
pEdit.add(EDlbDetInte, null);




public void actionPerformed(ActionEvent e)
{
Object obj = e.getSource();
if (obj== EDbtSau)
{
setCursor(new Cursor(Cursor.WAIT_CURSOR));
if (ASGestAdm.SaveAs() == true)
{
emptyPanel("edit");
EDbtSau.setEnabled(false);
}
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
}

public void emptyPanel(String str)
{

if (str.trim().equals("edit") )
{
EDtfCli .setText("");
EDtfContact.setText("");
EDtfNoCon.setText("");

EDchNoAppel.setSelectedIndex(0);

EDtfTel.setText("");
EDtfPost.setText("");

EDchDetEquip.removeItemListener(this);

EDchDetEquip.removeAllItems();

EDchDetEquip.addItemListener(this);

EDtaDetProb.setText("");

EDtaDetInte.setText("");

}
}


PLUS I'M ONLY HAVING THIS PROBLEM ON THE RESET, THEN ON THE THIRD TIME THERE ARE CURSORS
IN BOTH TEXTAREA ....

THANKS AGAIN
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!