001: /*
002: * SalomeTMF is a Test Management Framework
003: * Copyright (C) 2005 France Telecom R&D
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *
019: * @author Fayçal SOUGRATI, Vincent Pautret, Marche Mikael
020: *
021: * Contact: mikael.marche@rd.francetelecom.com
022: */
023:
024: package org.objectweb.salome_tmf.ihm;
025:
026: import java.awt.BorderLayout;
027: import java.awt.Container;
028: import java.awt.Dimension;
029: import java.awt.Frame;
030: import java.awt.event.ActionEvent;
031: import java.awt.event.ActionListener;
032:
033: import javax.swing.Box;
034: import javax.swing.BoxLayout;
035: import javax.swing.JButton;
036: import javax.swing.JDialog;
037: import javax.swing.JLabel;
038: import javax.swing.JPanel;
039: import javax.swing.JTextField;
040:
041: import org.objectweb.salome_tmf.ihm.languages.Language;
042:
043: /**
044: * Classe qui permet d'afficher une fenêtre demandant d'entrer deux
045: * informations.
046: */
047: public class AskTwoThings extends JDialog {
048:
049: /******************************************************************************/
050: /** CONSTRUCTEUR ***/
051: /******************************************************************************/
052:
053: /**
054: * Constructeur de la fenêtre permettant de demander deux informations.
055: * @param textToBePromptFirst texte pour demander la première information
056: * @param textToBePromptSecond texte pour demander la seconde information
057: */
058: public AskTwoThings(String textToBePromptFirst,
059: String textToBePromptSecond, Frame owner) {
060: super (owner, true);
061:
062: JPanel page = new JPanel();
063:
064: //JLabel text = new JLabel("");
065:
066: JLabel promptFirst = new JLabel(textToBePromptFirst);
067: JLabel promptSecond = new JLabel(textToBePromptSecond);
068:
069: JTextField textFirst = new JTextField(10);
070: JTextField textSecond = new JTextField(10);
071:
072: JPanel onlyTextPanel = new JPanel();
073: onlyTextPanel.setLayout(new BoxLayout(onlyTextPanel,
074: BoxLayout.Y_AXIS));
075: onlyTextPanel.add(Box.createRigidArea(new Dimension(0, 10)));
076: onlyTextPanel.add(promptFirst);
077: onlyTextPanel.add(promptSecond);
078:
079: JPanel onlyTextFieldPanel = new JPanel();
080: onlyTextFieldPanel.setLayout(new BoxLayout(onlyTextFieldPanel,
081: BoxLayout.Y_AXIS));
082: onlyTextFieldPanel.add(Box
083: .createRigidArea(new Dimension(0, 10)));
084: onlyTextFieldPanel.add(textFirst);
085: onlyTextFieldPanel.add(textSecond);
086:
087: JPanel textPanel = new JPanel();
088: textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.X_AXIS));
089: textPanel.add(Box.createRigidArea(new Dimension(0, 10)));
090: textPanel.add(onlyTextPanel);
091: textPanel.add(Box.createRigidArea(new Dimension(10, 10)));
092: textPanel.add(onlyTextFieldPanel);
093:
094: JButton okButton = new JButton(Language.getInstance().getText(
095: "Valider"));
096: okButton.setToolTipText(Language.getInstance().getText(
097: "Valider"));
098: okButton.addActionListener(new ActionListener() {
099: public void actionPerformed(ActionEvent e) {
100: AskTwoThings.this .dispose();
101: }
102: });
103:
104: JButton cancelButton = new JButton(Language.getInstance()
105: .getText("Annuler"));
106: cancelButton.setToolTipText(Language.getInstance().getText(
107: "Annuler"));
108: cancelButton.addActionListener(new ActionListener() {
109: public void actionPerformed(ActionEvent e) {
110: AskTwoThings.this .dispose();
111: }
112: });
113:
114: JPanel buttonPanel = new JPanel();
115: buttonPanel.setLayout(new BorderLayout());
116: buttonPanel.add(okButton, BorderLayout.NORTH);
117: buttonPanel.add(cancelButton, BorderLayout.SOUTH);
118:
119: page.add(textPanel, BorderLayout.WEST);
120: page.add(Box.createRigidArea(new Dimension(40, 10)),
121: BorderLayout.CENTER);
122: page.add(buttonPanel, BorderLayout.EAST);
123:
124: Container contentPaneFrame = this .getContentPane();
125: contentPaneFrame.add(page, BorderLayout.CENTER);
126: this .setLocation(500, 400);
127: this .pack();
128: this .setVisible(true);
129: this .setTitle(Language.getInstance().getText("Informations"));
130: } // Fin du constructeur AskTwoThings/2
131:
132: } // Fin de la classe AskTwoThings
|