Writing a generic InputBox

Discussion in 'Java' started by timasmith@hotmail.com, Apr 19, 2006.

  1. Guest

    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
     
    , Apr 19, 2006
    #1
    1. Advertising

  2. Chris Smith Guest

    <> 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
     
    Chris Smith, Apr 19, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. André Almeida Maldonado

    InputBox

    André Almeida Maldonado, May 5, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    5,380
    Kevin Spencer
    May 5, 2004
  2. Reza Alirezaei

    javascript inputbox and datagrid

    Reza Alirezaei, May 14, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    948
    Natty Gur
    May 14, 2004
  3. Jase

    Stop InputBox prompt loop?

    Jase, Feb 4, 2004, in forum: Java
    Replies:
    1
    Views:
    454
    Thomas Kellerer
    Feb 4, 2004
  4. Anthony_Barker

    Inputbox with win32api?

    Anthony_Barker, Jun 27, 2003, in forum: Python
    Replies:
    1
    Views:
    1,085
    John J. Lee
    Jun 27, 2003
  5. Bob Gailer

    Re: Inputbox with win32api?

    Bob Gailer, Jun 27, 2003, in forum: Python
    Replies:
    1
    Views:
    1,186
    Anthony_Barker
    Jul 4, 2003
Loading...

Share This Page