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.main;
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.Rectangle;
031: import java.awt.event.ActionEvent;
032: import java.awt.event.ActionListener;
033:
034: import javax.swing.Box;
035: import javax.swing.BoxLayout;
036: import javax.swing.JButton;
037: import javax.swing.JDialog;
038: import javax.swing.JLabel;
039: import javax.swing.JPanel;
040: import javax.swing.JTextField;
041:
042: import org.objectweb.salome_tmf.ihm.languages.Language;
043:
044: /**
045: * Classe qui permet d'afficher une fenêtre demandant d'entrer deux
046: * informations.
047: */
048: public class AskTwoThings extends JDialog {
049:
050: /******************************************************************************/
051: /** CONSTRUCTEUR ***/
052: /******************************************************************************/
053:
054: /**
055: * Constructeur de la fenêtre permettant de demander deux informations.
056: * @param textToBePromptFirst texte pour demander la première information
057: * @param textToBePromptSecond texte pour demander la seconde information
058: */
059: public AskTwoThings(String textToBePromptFirst,
060: String textToBePromptSecond, Frame owner) {
061: super (owner, true);
062:
063: JPanel page = new JPanel();
064:
065: //JLabel text = new JLabel("");
066:
067: JLabel promptFirst = new JLabel(textToBePromptFirst);
068: JLabel promptSecond = new JLabel(textToBePromptSecond);
069:
070: JTextField textFirst = new JTextField(10);
071: JTextField textSecond = new JTextField(10);
072:
073: JPanel onlyTextPanel = new JPanel();
074: onlyTextPanel.setLayout(new BoxLayout(onlyTextPanel,
075: BoxLayout.Y_AXIS));
076: onlyTextPanel.add(Box.createRigidArea(new Dimension(0, 10)));
077: onlyTextPanel.add(promptFirst);
078: onlyTextPanel.add(promptSecond);
079:
080: JPanel onlyTextFieldPanel = new JPanel();
081: onlyTextFieldPanel.setLayout(new BoxLayout(onlyTextFieldPanel,
082: BoxLayout.Y_AXIS));
083: onlyTextFieldPanel.add(Box
084: .createRigidArea(new Dimension(0, 10)));
085: onlyTextFieldPanel.add(textFirst);
086: onlyTextFieldPanel.add(textSecond);
087:
088: JPanel textPanel = new JPanel();
089: textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.X_AXIS));
090: textPanel.add(Box.createRigidArea(new Dimension(0, 10)));
091: textPanel.add(onlyTextPanel);
092: textPanel.add(Box.createRigidArea(new Dimension(10, 10)));
093: textPanel.add(onlyTextFieldPanel);
094:
095: JButton okButton = new JButton(Language.getInstance().getText(
096: "Valider"));
097: okButton.setToolTipText(Language.getInstance().getText(
098: "Valider"));
099: okButton.addActionListener(new ActionListener() {
100: public void actionPerformed(ActionEvent e) {
101: AskTwoThings.this .dispose();
102: }
103: });
104:
105: JButton cancelButton = new JButton(Language.getInstance()
106: .getText("Annuler"));
107: cancelButton.setToolTipText(Language.getInstance().getText(
108: "Annuler"));
109: cancelButton.addActionListener(new ActionListener() {
110: public void actionPerformed(ActionEvent e) {
111: AskTwoThings.this .dispose();
112: }
113: });
114:
115: JPanel buttonPanel = new JPanel();
116: buttonPanel.setLayout(new BorderLayout());
117: buttonPanel.add(okButton, BorderLayout.NORTH);
118: buttonPanel.add(cancelButton, BorderLayout.SOUTH);
119:
120: page.add(textPanel, BorderLayout.WEST);
121: page.add(Box.createRigidArea(new Dimension(40, 10)),
122: BorderLayout.CENTER);
123: page.add(buttonPanel, BorderLayout.EAST);
124:
125: Container contentPaneFrame = this .getContentPane();
126: contentPaneFrame.add(page, BorderLayout.CENTER);
127: //this.setLocation(500,400);
128: this .setTitle(Language.getInstance().getText("Informations"));
129: /*this.pack();
130: this.setLocationRelativeTo(this.getParent());
131: this.setVisible(true);*/
132: centerScreen();
133:
134: } // Fin du constructeur AskTwoThings/2
135:
136: void centerScreen() {
137: Dimension dim = getToolkit().getScreenSize();
138: this .pack();
139: Rectangle abounds = getBounds();
140: setLocation((dim.width - abounds.width) / 2,
141: (dim.height - abounds.height) / 2);
142: this .setVisible(true);
143: requestFocus();
144: }
145:
146: } // Fin de la classe AskTwoThings
|