Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question[code=java]/code
public class InfosPersonne extends JFrame { private JLabel lbl1; private JLabel lbl2; private JLabel lbl3; private JLabel lbl4; private JLabel lbl5; private JLabel lbl6; private JTextField Nom; private JTextField Prenom; private JTextField Tel; private JTextField email; private JTextField depar; private JTextField fonct; private JButton photo; private JButton Annuler; private Liste data; public InfosPersonne() { initComponents(); } private void initComponents() { lbl1=new JLabel(); lbl2=new JLabel(); lbl3=new JLabel(); lbl4=new JLabel(); lbl5=new JLabel(); lbl6=new JLabel(); Nom=new JTextField(); Prenom=new JTextField(); Tel=new JTextField(); email=new JTextField(); depar=new JTextField(); fonct=new JTextField(); photo=new JButton(); Annuler=new JButton("Annuler"); setBackground(Color.lightGray); setLayout(null); //-----lbl1---- lbl1.setText("Nom :"); add(lbl1); lbl1.setBounds(new Rectangle(new Point(20, 175), lbl1.getPreferredSize())); //-----lbl2---- lbl2.setText("Prénom :"); add(lbl2); lbl2.setBounds(new Rectangle(new Point(20, 210), lbl2.getPreferredSize())); //----lbl3--- lbl3.setText("Telephone :"); add(lbl3); lbl3.setBounds(new Rectangle(new Point(20, 240), lbl3.getPreferredSize())); //----lbl4--- lbl4.setText("Email :"); add(lbl4); lbl4.setBounds(new Rectangle(new Point(20, 275), lbl4.getPreferredSize())); //----lbl5--- lbl5.setText("Département :"); add(lbl5); lbl5.setBounds(20, 300, 100, 100); //------lbl6---- lbl6.setText("Fonction :"); add(lbl6); lbl6.setBounds(20, 265, 100, 100); //-----JTextField--- add(Nom); Nom.setBounds(125, 175, 140, 20); add(Prenom); Prenom.setBounds(125, 210, 140, 20); add(Tel); Tel.setBounds(125, 240, 140, 20); add(email); email.setBounds(125, 275, 140, 20); add(fonct); fonct.setBounds(125, 305, 140, 20); add(depar); depar.setBounds(125, 340, 140, 20); //----Photo---- photo.setIcon(new ImageIcon(getClass().getResource("/profilHomme_hg.jpg"))); add(photo); photo.setBounds(320, 10, 155, 100); //-----Annuler--- Annuler.setText("OK"); add(Annuler); Annuler.setBounds(315, 475, 100, 23); Annuler.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(EXIT_ON_CLOSE); } }); { Dimension preferredSize = new Dimension(); for(int i = 0; i < getComponentCount(); i++) { Rectangle bounds = getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; setMinimumSize(preferredSize); setPreferredSize(preferredSize); } } public static void main(String[] args) { InfosPersonne ip = new InfosPersonne(); ip.setTitle("InfosPersonne"); ip.setVisible(true); ip.setSize(495,570); ip.setResizable(false); } }
public InfosPersonne(Vector data) { ID.setText(data.elementAt(0).toString()); Nom.setText(data.elementAt(1).toString()); Prenom.setText(data.elementAt(2).toString()); Tel.setText(data.elementAt(3).toString()); Portable.setText(data.elementAt(4).toString()); email.setText(data.elementAt(5).toString()); depar.setText(data.elementAt(6).toString()); fonct.setText(data.elementAt(7).toString());