JFileChooser - mnemonics for buttons

Hi,
is it possible to set your own mnemonics for the buttons save/open and cancel in JFileChooser? If so, how does it work??
thanks
sicki

All properties have standard names; I don't know those of the mnemonics and if they're not in the list, I'm afraid you can't change them.
You maybe could try to make our own properties file with a non-existent locale and define what you need in that, if the mnemonics exist and it doesn't work by doing "UIManager.put(propertyname, propertyvalue)". Then you set your Locale before the call to the new Locale and it should work.
Hope this explanation helps you out anyway.
Greetings,
Silkje

Similar Messages

  • JFileChooser's approve button text changes when file

    I have a JFileChooser used for loading some XML file(s). We want the approve button's text to be "Load". When I bring up the dialog, the button text initially reads "Load", when I select a directory, it reads "Open", if I select a file again, it goes back to "Load". So far, so good.
    The problem comes when using it in a non-English language. When I bring up the dialog, the button text initially reads the appropriately translated "Load". However, when I select a directory, it changes to the English "Open". I do not see a method to use to adjust this text. Am I missing something, or is this a bug?
    Any help is greatly appreciated.
    Jamie

    Here's some code I'll put into the public domain:
    package com.graphbuilder.desktop;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.Stack;
    import java.util.Vector;
    import java.util.StringTokenizer;
    import java.io.File;
    <p>Attempt to improve the behaviour of the JFileChooser.  Anyone who has used the
    the JFileChooser will probably remember that it lacks several useful features.
    The following features have been added:
    <ul>
    <li>Double click to choose a file</li>
    <li>Enter key to choose a file after typing the filename</li>
    <li>Enter key to change to a different directory after typing the filename</li>
    <li>Automatic rescanning of directories</li>
    <li>A getSelectedFiles method that returns the correct selected files</li>
    <li>Escape key cancels the dialog</li>
    <li>Access to common GUI components, such as the OK and Cancel buttons</li>
    <li>Removal of the useless Update and Help buttons in Motif L&F</li>
    </ul>
    <p>There are a lot more features that could be added to make the JFileChooser more
    user friendly.  For example, a drop-down combo-box as the user is typing the name of
    the file, a list of currently visited directories, user specified file filtering, etc.
    <p>The look and feels supported are Metal, Window and Motif.  Each look and feel
    puts the OK and Cancel buttons in different locations and unfortunately the JFileChooser
    doesn't provide direct access to them.  Thus, for each look-and-feel the buttons must
    be found.
    <p>The following are known issues:  Rescanning doesn't work when in Motif L&F.  Some
    L&Fs have components that don't become available until the user clicks a button.  For
    example, the Metal L&F has a JTable but only when viewing in details mode.  The double
    click to choose a file does not work in details mode.  There are probably more unknown
    issues, but the changes made so far should make the JFileChooser easier to use.
    public class FileChooserFixer implements ActionListener, KeyListener, MouseListener, Runnable {
         Had to make new buttons because when the original buttons are clicked
         they revert back to the original label text.  I.e. some programmer decided
         it would be a good idea to set the button text during an actionPerformed
         method.
         private JFileChooser fileChooser = null;
         private JButton okButton = new JButton("OK");
         private JButton cancelButton = new JButton("Cancel");
         private JList fileList = null;
         private JTextField filenameTextField = null;
         private ActionListener actionListener = null;
         private long rescanTime = 20000;
         public FileChooserFixer(JFileChooser fc, ActionListener a) {
              fileChooser = fc;
              actionListener = a;
              fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
              okButton.setMnemonic('O');
              cancelButton.setMnemonic('C');
              JButton oldOKButton = null;
              JButton oldCancelButton = null;
              JTextField[] textField = getTextFields(fc);
              JButton[] button = getButtons(fc);
              JList[] list = getLists(fc);
              String laf = javax.swing.UIManager.getLookAndFeel().getClass().getName();
              if (laf.equals("javax.swing.plaf.metal.MetalLookAndFeel")) {
                   oldOKButton = button[0];
                   oldCancelButton = button[1];
                   filenameTextField = textField[0];
                   fileList = list[0];
              else if (laf.equals("com.sun.java.swing.plaf.windows.WindowsLookAndFeel")) {
                   oldOKButton = button[0];
                   oldCancelButton = button[1];
                   filenameTextField = textField[0];
                   fileList = list[0];
              else if (laf.equals("com.sun.java.swing.plaf.motif.MotifLookAndFeel")) {
                   oldOKButton = button[0];
                   oldCancelButton = button[2];
                   button[1].setVisible(false); // hides the do-nothing 'Update' button
                   button[3].setVisible(false); // hides the disabled 'Help' button
                   filenameTextField = textField[1];
                   fileList = list[0];
              fix(oldOKButton, okButton);
              fix(oldCancelButton, cancelButton);
              okButton.addActionListener(this);
              cancelButton.addActionListener(this);
              fileList.addMouseListener(this);
              addKeyListeners(fileChooser);
              new Thread(this).start(); // note: rescanning in Motif feel doesn't work
         public void run() {
              try {
                   while (true) {
                        Thread.sleep(rescanTime);
                        Window w = SwingUtilities.windowForComponent(fileChooser);
                        if (w != null && w.isVisible())
                             fileChooser.rescanCurrentDirectory();
              } catch (Throwable err) {}
         public long getRescanTime() {
              return rescanTime;
         public void setRescanTime(long t) {
              if (t < 200)
                   throw new IllegalArgumentException("Rescan time >= 200 required.");
              rescanTime = t;
         private void addKeyListeners(Container c) {
              for (int i = 0; i < c.getComponentCount(); i++) {
                   Component d = c.getComponent(i);
                   if (d instanceof Container)
                        addKeyListeners((Container) d);
                   d.addKeyListener(this);
         private static void fix(JButton oldButton, JButton newButton) {
              int index = getIndex(oldButton);
              Container c = oldButton.getParent();
              c.remove(index);
              c.add(newButton, index);
              newButton.setPreferredSize(oldButton.getPreferredSize());
              newButton.setMinimumSize(oldButton.getMinimumSize());
              newButton.setMaximumSize(oldButton.getMaximumSize());
         private static int getIndex(Component c) {
              Container p = c.getParent();
              for (int i = 0; i < p.getComponentCount(); i++) {
                   if (p.getComponent(i) == c)
                        return i;
              return -1;
         public JButton getOKButton() {
              return okButton;
         public JButton getCancelButton() {
              return cancelButton;
         public JList getFileList() {
              return fileList;
         public JTextField getFilenameTextField() {
              return     filenameTextField;
         public JFileChooser getFileChooser() {
              return fileChooser;
         protected JButton[] getButtons(JFileChooser fc) {
              Vector v = new Vector();
              Stack s = new Stack();
              s.push(fc);
              while (!s.isEmpty()) {
                   Component c = (Component) s.pop();
                   if (c instanceof Container) {
                        Container d = (Container) c;
                        for (int i = 0; i < d.getComponentCount(); i++) {
                             if (d.getComponent(i) instanceof JButton)
                                  v.add(d.getComponent(i));
                             else
                                  s.push(d.getComponent(i));
              JButton[] arr = new JButton[v.size()];
              for (int i = 0; i < arr.length; i++)
                   arr[i] = (JButton) v.get(i);
              return arr;
         protected JTextField[] getTextFields(JFileChooser fc) {
              Vector v = new Vector();
              Stack s = new Stack();
              s.push(fc);
              while (!s.isEmpty()) {
                   Component c = (Component) s.pop();
                   if (c instanceof Container) {
                        Container d = (Container) c;
                        for (int i = 0; i < d.getComponentCount(); i++) {
                             if (d.getComponent(i) instanceof JTextField)
                                  v.add(d.getComponent(i));
                             else
                                  s.push(d.getComponent(i));
              JTextField[] arr = new JTextField[v.size()];
              for (int i = 0; i < arr.length; i++)
                   arr[i] = (JTextField) v.get(i);
              return arr;
         protected JList[] getLists(JFileChooser fc) {
              Vector v = new Vector();
              Stack s = new Stack();
              s.push(fc);
              while (!s.isEmpty()) {
                   Component c = (Component) s.pop();
                   if (c instanceof Container) {
                        Container d = (Container) c;
                        for (int i = 0; i < d.getComponentCount(); i++) {
                             if (d.getComponent(i) instanceof JList)
                                  v.add(d.getComponent(i));
                             else
                                  s.push(d.getComponent(i));
              JList[] arr = new JList[v.size()];
              for (int i = 0; i < arr.length; i++)
                   arr[i] = (JList) v.get(i);
              return arr;
         public File[] getSelectedFiles() {
              File[] f = fileChooser.getSelectedFiles();
              if (f.length == 0) {
                   File file = fileChooser.getSelectedFile();
                   if (file != null)
                        f = new File[] { file };
              return f;
         public void mousePressed(MouseEvent evt) {
              Object src = evt.getSource();
              if (src == fileList) {
                   if (evt.getModifiers() != InputEvent.BUTTON1_MASK) return;
                   int index = fileList.locationToIndex(evt.getPoint());
                   if (index < 0) return;
                   fileList.setSelectedIndex(index);
                   File[] arr = getSelectedFiles();
                   if (evt.getClickCount() == 2 && arr.length == 1 && arr[0].isFile())
                        actionPerformed(new ActionEvent(okButton, 0, okButton.getActionCommand()));
         public void mouseReleased(MouseEvent evt) {}
         public void mouseClicked(MouseEvent evt) {}
         public void mouseEntered(MouseEvent evt) {}
         public void mouseExited(MouseEvent evt) {}
         public void keyPressed(KeyEvent evt) {
              Object src = evt.getSource();
              int code = evt.getKeyCode();
              if (code == KeyEvent.VK_ESCAPE)
                   actionPerformed(new ActionEvent(cancelButton, 0, cancelButton.getActionCommand()));
              if (src == filenameTextField) {
                   if (code != KeyEvent.VK_ENTER) return;
                   fileList.getSelectionModel().clearSelection();
                   actionPerformed(new ActionEvent(okButton, 0, "enter"));
         public void keyReleased(KeyEvent evt) {}
         public void keyTyped(KeyEvent evt) {}
         public void actionPerformed(ActionEvent evt) {
              Object src = evt.getSource();
              if (src == cancelButton) {
                   if (actionListener != null)
                        actionListener.actionPerformed(evt);
              else if (src == okButton) {
                   File[] selectedFiles = getSelectedFiles();
                   Object obj = fileList.getSelectedValue(); // is null when no file is selected in the JList
                   String text = filenameTextField.getText().trim();
                   if (text.length() > 0 && (obj == null || selectedFiles.length == 0)) {
                        File d = fileChooser.getCurrentDirectory();
                        Vector vec = new Vector();
                        StringTokenizer st = new StringTokenizer(text, "\"");
                        while (st.hasMoreTokens()) {
                             String s = st.nextToken().trim();
                             if (s.length() == 0) continue;
                             File a = new File(s);
                             if (a.isAbsolute())
                                  vec.add(a);
                             else
                                  vec.add(new File(d, s));
                        File[] arr = new File[vec.size()];
                        for (int i = 0; i < arr.length; i++)
                             arr[i] = (File) vec.get(i);
                        selectedFiles = arr;
                   if (selectedFiles.length == 0) {
                        Toolkit.getDefaultToolkit().beep();
                        return;
                   if (selectedFiles.length == 1) {
                        File f = selectedFiles[0];
                        if (f.exists() && f.isDirectory() && text.length() > 0 && evt.getActionCommand().equals("enter")) {
                             fileChooser.setCurrentDirectory(f);
                             filenameTextField.setText("");
                             filenameTextField.requestFocus();
                             return;
                   boolean filesOnly = (fileChooser.getFileSelectionMode() == JFileChooser.FILES_ONLY);
                   boolean dirsOnly = (fileChooser.getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY);
                   if (filesOnly || dirsOnly) {
                        for (int i = 0; i < selectedFiles.length; i++) {
                             File f = selectedFiles;
                             if (filesOnly && f.isDirectory() || dirsOnly && f.isFile()) {
                                  Toolkit.getDefaultToolkit().beep();
                                  return;
                   fileChooser.setSelectedFiles(selectedFiles);
                   if (actionListener != null)
                        actionListener.actionPerformed(evt);

  • Type of listener needed for buttons ? please help

    hi
    does anyone know what type of event or listener one should
    include for buttons in a web page which has been downloaded
    into a JEditorPane. i have been able to get a web page
    onto my JEditorPane and can even follow most of the hyper links
    by implemmeting hyperlinklistenter.
    but i am not able to do the same for butttons
    ie for eg in google web site i am not able to get anythinh
    by clicking on button .

    This is not easily dooable, You're talking about form submit buttons, which the Default HTMLEditorKit does not support. Even worse, the LinkController class is not overridable, which is a bad design on sun's part.
    You'd have to create your own EditorKit, me thinks, and use that for text/html.
    Not an easy job, but you could cheat off the HTMLEditorKit source.

  • How to find function code for buttons on toolbar in oops alv

    Hi experts,
    I want to remove some buttons from toolbar in oops alv, i know the procedure like get function code and pass the value in a table and pass that table to IT_TOOLBAR_EXCLUDING of
    method set_table_for_first_display but I WANT TO KNOW HOW TO FIND FUNCTION CODE FOR BUTTONS ON TOOLBAR IN OOPS ALV

    Hi Prakash,
    -->First you have to set the pf status in your alv program by,
    {FORM pf_status USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'FIRST'.
    ENDFORM.                    "PF_STATUS}
    -->Pass this Subroutine name in the Function module, Reuse_alv_grid_display's parameters i.e,
          i_callback_pf_status_set          = 'PF_STATUS'}
    *-->Then doble click on that pf status,
    From the menu bar, select Extras->Adjust Template->List Viewer,
    This will give you the existing statndard gui status of the program*
    ->Then catch that function codes in the User command Parameter of the Function module Reuse.. i.e,
          i_callback_user_command           = 'COMM'
    And make a subroutine of the name 'COMM'i.e,
    FORM comm USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
      DATA: okcode TYPE sy-ucomm.
      okcode = ucomm.
      CASE okcode.
        WHEN 'REF'.
        CALL FUNCTION 'POPUP_TO_INFORM'
          EXPORTING
            titel         = 'MANSI'
            txt1          = 'CREATED BY'
            txt2          = SY-UNAME
          TXT3          = ' '
          TXT4          = ' '
    endcase.
    Hope it helps you
    Regrds
    Mansi

  • Setting icon for buttons in labview 6i

    Hi All,
    Currently i am working on Labview 6i. i created two buttons in my vi one button is used to perform the test, another will be used to exit from the test. i would like to add icons for those buttons. can anyone tell me how to add icons for buttons.
    Thanks,
    kalpana

    You realize that LabVIEW 6.0 is at least 15 years old? That would be almost equivalent to working with a Windows 98 machine nowadays!
    Yes your picture can't be imported in LabVIEW 6.0 on my machine either. I haven't checked about all the details, but the LabVIEW import in 6.0 doesn't seem to work for png and gif images but only for bmp. Newer versions do work for your png file including honoring the transparency at least since version 7.1.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • t:inputFileUpload : problem with styleClass for button

    Hello,
    the component <t:inputFileUpload> has a field and a button. I want to add styleClass for button, but the styleClass into inputFileUpload tag works only for fields. Where can I add styleClass for button?
    Thank you in advance
    Manu

    Hello,
    I tried your suggestion, but it is not working.
    look the code:
    jsf
    <t:panelGroup styleClass="inputFile">
              <t:inputFileUpload value="#{interpreterDataImageHandler.uploadedFile}"
                   storage="file" accept="image/*" size="30"/>
                                  </t:panelGroup>css:
    .inputFile p{
         color:#5d0408;
         width:80px;
         margin-top:20px;
         border:1px solid #cacac4;
         background-color: #f87e39;
         }generated source:
    <span class="inputFile"><input type="file" size="30" accept="image/*" name="imageListForm:subimageUpload:_idJsp7"/></span>

  • Raster / vector option for buttons

    As written in the title, it would be a great improvement to have an option 'raster/vector' for buttons.
    The same we already have for MSO and scrolling contents.

    Well I figured it out on my own. It was my wacom touch-zoom. My hand brushed it while I had hit both option and command by accident. So it WAS a lock like I thought! Sadly nowhere does anyone seem to MENTION THIS.... so here's the fix;
    Option+command+~+e+u+i
    Opt and Cmnd are already on lock so you just need to push the others at once. You don't need shift. I just refer to the ~ since it's more specific visually than the ` since it seems to differ depending on font and may look like a typical comma at times.
    You can also just swipe the zoom since that's it's function. But in case you get stuck and can't, there it is in normal letters.
    The zoom was deactivated and reset with opt+cmnd+8 I managed to find this online which helped me pinpoint the whole problem.
    I hope this helps anyone else who's unlucky enough to accidentally trigger such a ridiculous and basically hidden command.

  • How to create valid values for button

    Hi,all
    I want put valid values to button like copy from or copy to functionality is it possible.
    if u have idea plz post it..?
    by
    Firos.C

    Hi,
    Actually u cannot have valid values for buttons. IN SAP we have Copy to and Copy from but the same kind of button cannot be created in SDK..... so u need to use the combo box and add ur valid values.
    Hope it helps,
    Vasu Natari.

  • How to set Shortcut keys for button in Apex

    Hi
    Could anyone help me on how to set shortcut keys for buttons in Apex.
    I need to use say ALT + S to submit the page.
    The following thread pertaining to HTML DB refered to use ACCESS key. but that couldnt work in my case.
    Re: operation of the app. with the keyboard
    Any pointers on achieving this would be helpful.
    Thanks
    Vijay

    Hi Vijay,
    I’m afraid you must do it using javascript key listener. You can’t use action() on template based buttons because they are actually not HTML buttons but images with hyperlink.
    Key listener checks which key has been pressed down and invoke some JS function. For example, write this code in page header:
    <script>
    document.onkeydown=keyCheck;
    function keyCheck(e){
         var KeyId = (window.event) ? event.keyCode : e.keyCode;
         switch(KeyId){         
              case 113:
                   doSubmit('SAVE');
                   break;                    
              case 118:
                   alert('Hello');
                   break;
    </script>
    This script will submit page with request 'SAVE' if you press F2 or will show alert message if you press F7. Modify it to your issue.
    Regards,
    Przemek

  • How to set the short cut key for buttons

    Hi
    I dont know how to set the short cut keys for the button...can u pls help me out

    Do you mean a short cut key for buttons at client side (web browser)? If yes, you could do it with JavaScript~~~ ^o^

  • Technical names are appearing in OVS pop-up for buttons.

    HI Experts,
    I have used OVS help in my application, I have deployed and tested it on local WAS where everything works fine.
    But, when i access it from portal deployed on staging server, the OVS popup window shows technical names for buttons e.g for Go it shows "view.MainView.gr.c.tc.goSearch.text", same is for Exit button.
    Could you please tell me where can be mistake and what are corrective measures?
    regards,
    abhijeet

    Hi,
       You will need to open an OSS message for the same under BC-WD-JAV-RUN component. This is an issue with the NW WAS version that you are running. You can find a similar issue [here|OVS - Buttons without correct label].
    Regards,
    Satyajit.

  • [svn:fx-trunk] 11602: Fix for Button tooltips.

    Revision: 11602
    Author:   [email protected]
    Date:     2009-11-09 22:35:11 -0800 (Mon, 09 Nov 2009)
    Log Message:
    Fix for Button tooltips. TextBase dispatches an event when _isTruncated is set through the setIsTruncated() function. This allows ButtonBase to listen for the event and set the tooltip as necessary. If an explicit tooltip is set, then ButtonBase will not set a tooltip.
    QE notes: No
    Doc notes: No
    Bugs: SDK-22260, SDK-23474, SDK-23657
    Reviewer: Evtim
    Tests run: checkintests
    Is noteworthy for integration: No
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-22260
        http://bugs.adobe.com/jira/browse/SDK-23474
        http://bugs.adobe.com/jira/browse/SDK-23657
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/Label.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/RichText.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/ButtonBase.a s
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/TextBase.as

  • How to make a shadow for Button or Panel

    Actually I want to show a shadow for Button or Panel.
    How can I do it.

    Hi
    Pls try to look for the Forms On-Line Help for how to create an alert...
    besides this Video Hope it helps....
    Good Luck :)
    Regards,
    Amatu Allah.

  • Condition For Button Display

    Hi All,
    I have new requirement that create push button to reject all line items in complaint page.
    I have done all changes.  Now button is functioning as expected.
    Issue is button display by default in the initial page even we have not entered any order number in that page. Here i need to set some conditon that if item list is not empty then need to display the button.
    Component : ICCMP_BT_BUTTON
    View          : ButtonBar
    Context Node : BTADMINI
    Item List from Another Component & View
    Component : ICCMP_BTITEM
    View          : ItemList
    Context Node : BTADMINI
    How can i set condition in HTM page whether Node(BTADMINI) is empty or not. How can i access here.
    Note : Button Component as well have Contextnode (BTADMINII).
    Hope you got the detailed issue.
    Thank you,
    Cha

    Hi Andreai,
    Thank you, as per your suggestion, created bound in "WD_USGE_INITIALIZE" method, initially in this method for Button usage only  "BTADMINH" bound was there. Now added BTADMINI as well.
    BTADMINI Entity gets populated now. Issue is backend is not updated with the value we are passing from UI.
    We have a button in frontend which is used to reject all items of the order.
    But if we click the button, item (BTADMINI) entity get filled now, using the entity, calling the execute method with the value of "SetRejectReason" but if we look at the beckend item status still in Open and not "Reject".
    Event handle method Code (In Button Component)
    lr_entity ?= me->typed_context->btadmini->collection_wrapper->get_current( ).
    ls_param-name = 'REASON'. "#EC NOTEXT
    ls_param-value = iv_rejection_code.
    APPEND ls_param TO lt_param.
    lr_entity->execute(
    iv_method_name = 'setRejectionReason'
    it_param = lt_param ).
    Button COMP : ICCMP_BT_Button
    Main COMP    : ICCMP_BT_COM ( Which has Item Structure as well, here Button component has been called)
    My assumption, BTADMINI instance only might be populatuing without value. Can you please suggest what is the issue
    Thank you,
    Cha

  • Custom JDialog, waiting for Button Press

    I want to create a custom dialog so i can do the following:
    Color yrColor = MyColorChooser().showDialog();
    I can create the dialog just fine but i cant get it to return a value
    on a button press.
    Here is my code:
    public class MyColorChooser extends JDialog implements ActionListener{
    public MyColorChooser(){
    super(Main.Frame, "Color Chooser", true);
    // Gui Stuff
    public Color showDialog(){
    setVisible(true);
    // ?? how do i have it wait for button press??
    return YourColor;
    public void actionPerformed(ActionEvent e) {
    if( e.getSource() == Button ){
    returnColor()
    public void returnColor(){
    Color YourColor;
    JButton Button = new JButton();
    }Im clueless when it comes to JDialogs.
    I know i am probably approaching this all wrong.
    I need guidance more in the approach rather than the code.
    If anyone has any suggestions id appreciate it.
    Thank you!

    Maybe this simple example can give you some ideas. Note how I make the dialog modal. This will halt the program flow until the dialog is dismissed.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class SimpleTextInputDialog extends JDialog implements ActionListener {
        private JTextField  inputField;
        private JButton     okButton;
        private JButton     cancelButton;
        private String      value;
        private SimpleTextInputDialog() {
            setTitle("Enter a value");
            setModal(true);
            inputField = new JTextField(20);
            JPanel textPanel = new JPanel();
            textPanel.add(inputField);
            getContentPane().add(textPanel, BorderLayout.CENTER);
            okButton = new JButton("OK");
            okButton.addActionListener(this);
            cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(this);
            JPanel buttonPanel = new JPanel(
                    new FlowLayout(FlowLayout.CENTER, 10, 10));
            buttonPanel.add(okButton);
            buttonPanel.add(cancelButton);
            getContentPane().add(buttonPanel, BorderLayout.SOUTH);
            pack();
            setLocationRelativeTo(null);
        public void actionPerformed(ActionEvent e) {
            if( e.getSource() == okButton ) {
                value = inputField.getText();
            dispose();
        public static String getValue() {
            SimpleTextInputDialog dlg = new SimpleTextInputDialog();
            dlg.setVisible(true);
            return dlg.value;
        public static void main(String[] args) {
            String value = SimpleTextInputDialog.getValue();
            System.out.println("Entered value: " + value);
    }And as always, you should study the tutorials:
    "How to Make Dialogs":
    http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html

Maybe you are looking for

  • Problems booting from external drives

    Ever since I got this 6-core 2013 MacPro (January 2015), I have had strange problems and glitches, but for this posting, I am talking about problems being able to boot up from external drives. I took the 4 external drives out of my old 2009 MacPro an

  • Mighty Mouse will scroll down but not up.

    All of a sudden my mighty mouse won't scroll up. It will scroll down, left and right but not up. The mighty mouse is about 6 months old and has worked fine on my old Dual 1GHz G4 MDD.

  • HT4623 help with upgrading iphone 3 or 3g software

    i have the iphone 3g or 3 when i try to update in itunes the software from4.2 to get latest software it says i have the latest update but i know thats not right. i am trying to download facebook app and it wont allow as it says i need to upgrade the

  • From Adobe Workspace+Flex : ArrayCollection to ArrayList

    Hi all I have created a flex application which sends an ArrayCollection to LCDS 3.1 installed on JBoss. This ArrayCollection is converted into ArrayList which successfuly is converted into Array by a server java program. The Problem: I incorporate th

  • Excited, then disappointed

    I had heard of Flash Catalyst ever since I went to Mix09 in Vegas. There our appetites were whetted with the promise that a new interaction design tool would be coming out of Adobe, with the power of Flash but much easier to use. The actual thing was