package action; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.Box; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import cXML.node; public class actTitrePrincipal extends AbstractAction{ /** * */ private static final long serialVersionUID = 1L; { putValue( Action.NAME, "Titre principal" ); putValue( Action.SHORT_DESCRIPTION, "Titre principal" ); } @Override public void actionPerformed(ActionEvent e) { node nod = (node) fenetres.create.getSelectNode().getUserObject(); String titre = ""; if(nod.getAttributs().get("titre")!=null) { titre = nod.getAttributs().get("titre"); } JTextField xField = new JTextField(30); xField.setText(titre); JPanel myPanel = new JPanel(); myPanel.add(new JLabel("Titre :")); myPanel.add(Box.createHorizontalStrut(2)); // a spacer myPanel.add(xField); int result = JOptionPane.showConfirmDialog(null,myPanel,"Saisissez votre titre principal", JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { nod.titre(xField.getText()); fenetres.create.getTextNodeSelect().refreshAffichage(nod); } } }