2 GNU Lesser General Public License
5 Copyright (C) 2000 Howard Kistler
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 package com
.hexidec
.ekit
.component
;
24 import com
.hexidec
.ekit
.EkitCore
;
25 import java
.awt
.Container
;
26 import java
.awt
.Frame
;
27 import java
.awt
.event
.ActionEvent
;
28 import java
.awt
.event
.ActionListener
;
29 import javax
.swing
.border
.*;
30 import javax
.swing
.BorderFactory
;
31 import javax
.swing
.BoxLayout
;
32 import javax
.swing
.JButton
;
33 import javax
.swing
.JDialog
;
34 import javax
.swing
.JLabel
;
35 import javax
.swing
.JOptionPane
;
36 import javax
.swing
.JPanel
;
37 import javax
.swing
.JTextField
;
38 import javax
.swing
.SwingConstants
;
39 import javax
.swing
.WindowConstants
;
41 public class UserInputAnchorDialog
extends JDialog
implements ActionListener
43 private EkitCore parentEkit
;
44 private String inputText
= null
;
45 private final JTextField jtxfInput
= new JTextField(32);
47 public UserInputAnchorDialog(EkitCore peKit
, String title
, boolean bModal
, String defaultAnchor
)
49 super(peKit
.getFrame(), title
, bModal
);
51 jtxfInput
.setText(defaultAnchor
);
55 public void actionPerformed(ActionEvent e
)
57 if(e
.getActionCommand().equals("accept"))
59 inputText
= jtxfInput
.getText();
62 if(e
.getActionCommand().equals("cancel"))
67 else if(e
.getActionCommand().equals("files"))
69 String selectedFile
= parentEkit
.insertFile();
70 if(selectedFile
!= null
)
72 jtxfInput
.setText(selectedFile
);
79 Container contentPane
= getContentPane();
80 contentPane
.setLayout(new BoxLayout(contentPane
, BoxLayout
.Y_AXIS
));
81 setBounds(100,100,400,300);
82 setDefaultCloseOperation(WindowConstants
.HIDE_ON_CLOSE
);
84 JPanel centerPanel
= new JPanel();
85 centerPanel
.setLayout(new BoxLayout(centerPanel
, BoxLayout
.X_AXIS
));
86 JLabel anchorLabel
= new JLabel("Anchor:", SwingConstants
.LEFT
);
87 centerPanel
.add(anchorLabel
);
88 centerPanel
.add(jtxfInput
);
90 JPanel buttonPanel
= new JPanel();
91 buttonPanel
.setBorder(new SoftBevelBorder(BevelBorder
.LOWERED
));
93 JButton saveButton
= new JButton("Accept");
94 saveButton
.setActionCommand("accept");
95 saveButton
.addActionListener(this);
97 JButton cancelButton
= new JButton("Cancel");
98 cancelButton
.setActionCommand("cancel");
99 cancelButton
.addActionListener(this);
101 JButton filesButton
= new JButton("Server Files...");
102 filesButton
.setActionCommand("files");
103 filesButton
.addActionListener(this);
105 buttonPanel
.add(saveButton
);
106 buttonPanel
.add(cancelButton
);
107 buttonPanel
.add(filesButton
);
109 contentPane
.add(centerPanel
);
110 contentPane
.add(buttonPanel
);
113 this.setVisible(true
);
116 public String
getInputText()
121 public void setAnchor(String anchor
)
123 jtxfInput
.setText(anchor
);