Salut,
J'utilise le type JtextArea et je c pas trop le manipuler.J'ai crée 2 JtexArea une contient des valeur et l'autre est vide.Lorsque je clique sur un bouton,l'element selectionné sera deplacé dans le JtexArea qui était initialement vide.j'ai developpé ce code mais il ne selectionne pas automatiquement les champs(ça peut se faire mauellement) et avec ça quand je deplace un élément vers le 2eme JtextArea il se deplace mais une copie reste dans le 1er JtextArea,alors que je veux que ça soit deplacé carrément du premier JtextArea:Voici mon code:
J'ai fait rapidement ce bout de code ( désolé pour la structure un peu malade ).
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class TestUI extends JFrame implements WindowListener, ActionListener{
private JTextArea takeArea = new JTextArea();
private JTextArea receiveArea = new JTextArea();
private JButton button = new JButton("Send");
/**
* @param args
*/
public static void main(String[] args) {
TestUI ihm = new TestUI();
ihm.setDefaultCloseOperation(0);
}
public TestUI(){
initGUI();
}
private void initGUI(){
this.setLayout(null);
this.setContentPane(getContentPanel());
this.setSize(665,505);
this.setVisible(true);
this.setLocationRelativeTo(null);
this.setResizable(false);
this.addWindowListener(this);
}
private JPanel getContentPanel(){
JPanel contentPanel = new JPanel();
contentPanel.setLayout(null);
this.takeArea.setBounds(new Rectangle(0,0,100,300));
this.receiveArea.setBounds(new Rectangle(101,0,100,300));
this.button.setBounds(new Rectangle(201,0,30,50));
this.button.addActionListener(this);
contentPanel.add(this.takeArea, null);
contentPanel.add(this.receiveArea, null);
contentPanel.add(this.button, null);
return contentPanel;
}
@Override
public void windowActivated(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowClosed(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
@Override
public void windowDeactivated(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowDeiconified(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowIconified(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowOpened(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void actionPerformed(ActionEvent arg0) {
this.receiveArea.setText(this.takeArea.getText());
this.takeArea.setText("");
}
}
__________________________
La théorie, c'est quand on sait tout et que rien ne fonctionne. La pratique, c'est quand tout fonctionne et que personne ne sait pourquoi. Ici, nous avons réuni théorie et pratique : rien ne fonctionne et personne ne sait pourquoi...