Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Writing a generic InputBox

Reply
Thread Tools

Writing a generic InputBox

 
 
timasmith@hotmail.com
Guest
Posts: n/a
 
      04-19-2006
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

 
Reply With Quote
 
 
 
 
Chris Smith
Guest
Posts: n/a
 
      04-19-2006
<(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript inputbox and datagrid Reza Alirezaei ASP .Net 1 05-14-2004 07:17 AM
InputBox André Almeida Maldonado ASP .Net 5 05-05-2004 03:57 PM
Stop InputBox prompt loop? Jase Java 1 02-04-2004 11:15 AM
Re: Inputbox with win32api? Bob Gailer Python 1 07-04-2003 05:57 PM
Inputbox with win32api? Anthony_Barker Python 1 06-27-2003 08:15 PM



Advertisments