001: /*
002: * JacORB - a free Java ORB
003: *
004: * Copyright (C) 1997-2004 Gerald Brose.
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Library General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Library General Public License for more details.
015: *
016: * You should have received a copy of the GNU Library General Public
017: * License along with this library; if not, write to the Free
018: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
019: */
020:
021: package org.jacorb.naming.namemanager;
022:
023: import javax.swing.*;
024: import java.awt.*;
025: import java.awt.event.*;
026:
027: /**
028: * A dialog to enter the name and ior for an object binding
029: *
030: * @version $Id: ObjectDialog.java,v 1.3 2004/05/06 12:39:59 nicolas Exp $
031: * @author Gerald Brose, Xtradyne Technologies
032: */
033:
034: public class ObjectDialog extends JDialog implements ActionListener,
035: KeyListener {
036: JTextField nameField;
037: JTextField iorField;
038: JCheckBox rebindCheckBox;
039: boolean isOk;
040:
041: public ObjectDialog(Frame frame) {
042: super (frame, "Bind Object", true);
043:
044: isOk = false;
045: JPanel mainPanel = new JPanel(new BorderLayout());
046:
047: JPanel hiPanel = new JPanel();
048: hiPanel.setLayout(new BoxLayout(hiPanel, BoxLayout.Y_AXIS));
049: JLabel nameLabel = new JLabel("Name:");
050: JLabel objectLabel = new JLabel("IOR:");
051: rebindCheckBox = new JCheckBox("Rebind if name is bound?",
052: false);
053: nameField = new JTextField(40);
054: iorField = new JTextField(40);
055:
056: hiPanel.add(nameLabel);
057: hiPanel.add(nameField);
058: hiPanel.add(objectLabel);
059: hiPanel.add(iorField);
060: hiPanel.add(rebindCheckBox);
061:
062: JButton ok = new JButton("Ok");
063: JButton cancel = new JButton("Cancel");
064:
065: JPanel loPanel = new JPanel();
066: loPanel.add(ok);
067: loPanel.add(cancel);
068:
069: ok.addActionListener(this );
070: cancel.addActionListener(this );
071:
072: mainPanel.add(hiPanel, BorderLayout.CENTER);
073: mainPanel.add(loPanel, BorderLayout.SOUTH);
074: getContentPane().add(mainPanel);
075:
076: pack();
077: show();
078:
079: }
080:
081: public boolean isRebind() {
082: return rebindCheckBox.isSelected();
083: }
084:
085: public String getName() {
086: return nameField.getText();
087: }
088:
089: public String getIOR() {
090: return iorField.getText();
091: }
092:
093: public void actionPerformed(ActionEvent e) {
094: if (e.getActionCommand().equals("Ok")) {
095: try {
096: isOk = true;
097: dispose();
098: } catch (Exception ex) {
099: JOptionPane.showMessageDialog(this , ex.getMessage(),
100: "Input error", JOptionPane.ERROR_MESSAGE);
101: }
102: } else
103: dispose();
104: }
105:
106: public void keyPressed(KeyEvent e) {
107: if (e.getKeyCode() == KeyEvent.VK_ENTER)
108: actionPerformed(new ActionEvent(this , 0, "Ok"));
109: else if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
110: actionPerformed(new ActionEvent(this , 0, "Cancel"));
111: }
112:
113: public void keyReleased(KeyEvent e) {
114: }
115:
116: public void keyTyped(KeyEvent e) {
117: }
118: }
|