Writing a generic InputBox  
Author Message
timasmith





PostPosted: 2006-4-19 9:24:00 Top

java-programmer, Writing a generic InputBox Hi,

I wont tell my old way but I have rewritten my InputBox class as having
the following important snippets:

public class InputBox extends JDialog {
private ActionListener okAction;

public InputBox(ActionListener a, JFrame f, String label, String
title, String defaultText) {
okAction = a;
getMyOkButton().addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
okAction.actionPerformed(e);
dispose();
}
});
public String inputText() {
return control.getText();
}
}

Code uses it as follows

ActionListener okAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
myObject.setURLName(hyperlinkInputBox.getInputText());
} catch (Exception ex) {
Debug.LogException(this, ex);
}
}
};
hyperlinkInputBox = new UIInputBox(okAction, "Insert
Hyperlink",parentFrame,"URL:",null,300);
hyperlinkInputBox.setVisible(true);

I dislike having to make hyperlinkInputBox a private variable in the
calling class in order to reference it within the okAction
ActionListener. Same goes for myObject.

I guess it is not *too* shabby but can anyone improve my architecture?

thanks

Tim

 
Chris Smith





PostPosted: 2006-4-19 11:56:00 Top

java-programmer >> Writing a generic InputBox <email***@***.com> wrote:
> I dislike having to make hyperlinkInputBox a private variable in the
> calling class in order to reference it within the okAction
> ActionListener. Same goes for myObject.
>
> I guess it is not *too* shabby but can anyone improve my architecture?

Are we allowed to make your architecture unnecessary, rather than
improving it? Look up javax.swin.JOptionPane.showInputDialog in the API
documentation.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation