Shortcut on Button in swing

Dear Sir,
Can i get help from you any one to create shortcut on button in swing like press ENTER to process.
I am so worried that how do it.
I am waiting so anxiously for u reply.
Regards,
Shah Jehan

If it is not a default button - use mnemonic.
Default button reacts on "Enter" key press. Use JRootPane.setDefaultButton(), and JButton.requestFocusInWindow() if needed.

Similar Messages

  • I want to make the keyboards numerical keys shortcuts for buttons.

    I want to make the keyboards numerical keys shortcuts for buttons, without a modifier key is this possible ? e.g. press '1' on the keyboard button 1 is pressed on the GUI.

    The number keys are not valid hot keys for our controls. The easiest workaround would be to use fhe F keys instead (F1 for button 1, etc.) However, if you are set on the number keys you could implement this with a panel callback. You could have a panel callback that monitors all keypress events and then, depending on the key pressed, calls the code that would be called with a button press of the button for that key.
    Best Regards,
    Chris Matthews
    Measurement Studio Support Manager

  • How to pop a virtual calendar with a click of button in swing applications

    How to pop a virtual calendar with a click of button in swing applications
    Does anyone knows how to pop up a virtual calendar in swing applications when there is a click of button. Do u have any components plug in tutorials or free java components download. Does java allows to used Microsoft calendar active x to plug into java applications. Thanks

    If you want a simple date picker, try this one
    http://forum.java.sun.com/thread.jspa?threadID=620699&messageID=3497753its a stand alone, but can be easily modified to include in a popup, and,
    instead of displaying the date:
    - passing the 'date picked' back to the calling object
    - close the popup

  • How do I change the color of a button in swing?

    I'm using swing to create an interface and it's made up mainly of buttons. Gray isn't exactly the prettiest of colors and I'd love if I could change the color.
    Cheers,
    elmicko

    Hi!
    You can set the color of each button independently using:
    JButton1.setBackground(Color.BLUE); // for the background
    JButton1.setForeground(Color.CYAN); // for the text displayedOr if you want all the button to have the same color you can overwrite the look and feel of the application using:
    javax.swing.UIManager.put("Button.background", new Color(230, 230, 230));

  • Loading and displaying other  form on click of a button using swing

    hi,
    i've just started with my first ever swing program. i want to load another UI form on click of a button . how can i do that.

    Sorry for posting last message
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class MainCl extends JFrame
    public MainCl()
    this.setBounds(100,100,400,300);
    btn = new JButton("Click me to show another fframe");
    btn.setBounds(10, 20, 250, 30);
    this.getContentPane().setLauout(null)
    this.getContentPane().add(btn);
    btn..addActionListener(new ActionListener()
    JFrame frm2 = new SecondFrame();
    frm2.setVisible(true);
    public static void main(String [] args)
    JFrame frm1 = new MainCl();
    frm1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frm1.setVisible(true);
    JButton btn;
    class SecondFrame extends JFrame
    public SecondFrame()
    this.setBounds(200,200,200,100)
    this.getContentPane().add(new JLabel("This is NEW FORM"));
    }

  • Button exiting swing ..closing

    hi i want to close or hide a jpanel attached into another
    i have a Jframe1 inserted into another by using:
    myPanel1 = new javax.swing.JPanel();
    JPanel param =(JPanel) new JFrame1().getContentPane();
    myPanel1 .add(param);
    So i see "param" panel attached into mypanel1.
    Now param panel have a button that say : "CLOSE"
    but i cant close param panel using setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); as a actionperform method
    What can i do?
    Thanks for helping!!
    greetings!!

    You're doing a very strange thing there: by adding the frame's content pane to your other panel (where do you put that?) you're removing the content pane from the frame.
    I suspect you want to do this:
    JPanel myPanel = createMyPanel();
    JFrame f = new JFrame();
    f.getContentPane().add(myPanel); // or, f.setContentPane(myPanel);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);...but I'm not sure I fully understand what you're trying to do.

  • How can I set up tablet shortcut menu button for the middle button my X230T?

    I think I have a faulty X230T, there are now only three tablet buttons and the middle does not do anything. I have installed 7wg737.exe (tablet short menu for Win7), but it does nothing.
    When I go into Tablet PC setting>buttons, only one button shows up and that's the screen rotation button. 
    Is there a way to assign the middle button to shortcut menu? Otherwise I'm unable to change brightness or volumn during tablet mode which would make this tablet unusable.

    Hi Susan,
    Try Butler...
    http://www.versiontracker.com/dyn/moreinfo/macosx/20035

  • How to create a BRowse button using Swing?

    I want to create a browse button with the help og which i want to browse a file..
    please can anyone help me

    Bookmark the API (or search the downloads section if you want to get an offline set)
    {color:0000ff}http://java.sun.com/javase/6/docs/api/{color}
    JFileChooser:
    {color:0000ff}http://java.sun.com/javase/6/docs/api/javax/swing/JFileChooser.html{color}
    db

  • Save the contents into hard disk on click of Save As button in Swing

    Hi,
    I have a JButton "Save As". On clicking the button, the contents in the JTextArea should be saved in the local hard disk by opening a Save As dialog box and allowing the user to save in any location.
    Is it possible to do this? If so, please inform me how it could be done.

    Hi,
    Please find the code below.
    try{
    File f = new File("Out.txt");
    FileInputStream fis = new FileInputStream(f);
    BufferedInputStream bis = new BufferedInputStream(fis); DataInputStream dis = new DataInputStream(bis); String stb = null;
    JDialog w = null;
    stb = new String();
    stb = dis.readLine();
    if(stb != null){
    w = new JDialog();
    final Container c = w.getContentPane();
    c.setLayout(null);
    w.setContentPane(c);
    w.setResizable(true);
    w.setTitle("Log Window");
    w.setSize(330,500);
    final JTextArea jt = new JTextArea();
    JScrollPane jsp = new JScrollPane(jt);
    jt.setLineWrap(true);
    jt.setText("Records not available for the id's"+"\n"+stb);
    jt.setBounds(10,10,285,500);
    final JButton jbSave = new JButton("Save File As");
    JPanel spacer = new JPanel();
    spacer.setMinimumSize(new Dimension(50, 18));
    spacer.setPreferredSize(new Dimension(50, 18));
    JPanel jpButtons = new JPanel();
    jpButtons.add(jbSave);
    jpButtons.add(spacer);
    jpButtons.setBorder(BorderFactory.createEtchedBorder());
    JScrollPane scroll = new JScrollPane();
    c.setLayout(new BorderLayout());
    c.add(jt,BorderLayout.CENTER);
    c.add(jpButtons, BorderLayout.SOUTH);
    jbSave.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    JFileChooser fileChooser = new JFileChooser();
    int userOption = fileChooser.showSaveDialog(null);
    if(userOption == JFileChooser.APPROVE_OPTION)
    //*******************STATEMENTS TO BE ADDD****************** }
    jt.getText()-----This is how I can get the contents from JTextArea.
    But how I can save the contents. i.e on click of Save As button, Save dialog box opens, and I can choose the location and give the name. but if I go to the location I don't find the file....
    Please guide me to finish this....
    Thanks in Advance.....

  • Question about  Buttons in swing

    How i can have circular button in GUI program.

    This code will get u through :
    JButton button = new JButton(new ImageIcon("roundImage.gif"));
    button.setBorderPainted(false);
    button.setContentAreaFilled(false);
    button.addActionListener(......);
    [email protected]

  • I have this shortcut  home button on my screen that you can move all over the screen that I want it gone.

    this button is a little white circle in a black square that you can move all over you screen on your phone if you tap it it gives you home, favorites, voice control, device, a shortbut button that is suppose to save your buttons on your phone by you using this button on the screen. I hate it. Anyone know how to get rid of it??

    Go to Settings, General, Accessibility and turn off Adaptive touch.

  • Using Mouse Scroll Button In Swing

    Hi all, here's my question:
    When using a JScrollPane, how is it possible to use the mouse scroll button found in the middle of the mouse to scroll up or down?

    Hi,
    if you are using JDK1.4 it should work. If not you would need a native implementation to catch the wheel.
    Regards
    Andre

  • Compound button in swing

    hi
    anyone can suggest way to implement the compound/dual action button in toolbar of common software like mozilla firefox , outlook express ......
    plzz help ..............
    thanxs in advance

    compound/dual action buttonWill you give the definition?

  • Default buttons in Swing

    I've done this before but can't remember how now. How can I make a JButton the "default" button in a JFrame, such that if I hit enter while keyboard focus is on any component in the frame (that doesn't intercept the Enter keystroke itself), it's the same as clicking the button with the mouse?

    hi,
    if you are working with keyboard you need to have a keytyped-method. So if the return-key is pressed just only work with this button.
    example:// ...
    JButton jb=new JButton("Press Return");
    public void keyTyped(KeyEvent e){
      if(e.getKeyCode()==// the variable for return)
        // do whatever the button should do
    }regards

  • Accelerator (keyboard shortcut) for Buttons?

    Hi all,
    Is there some way to add an Accelerator (like the one available for Menu controls) or something similar to a Button? I would like to make it possible for the user to press Ctrl+S and save her current work, or Ctrl+Z to undo etc.

    jsmith wrote:
    On Windows you need to hold down the Alt key to get the Mnemonic to arm (underlines the Mnemonic key, e.g. the P in _Print), then press the mneomnic key, so Alt+P activated your button for me.I know, but I still couldn't get it to work (and I like Ctrl better :) ) so I went with the EventFilter:
            rootBorderPane.addEventFilter(KeyEvent.ANY, new javafx.event.EventHandler<KeyEvent>() {
                @Override
                public void handle(KeyEvent ke) {
                    if(ke.getCode()==KeyCode.S && ke.isShortcutDown())
                        //TODO Save
                    else if(ke.getCode()==KeyCode.W && ke.isShortcutDown())
                        printPreviewMisljenjePsihologa();
                    else if(ke.getCode()==KeyCode.P && ke.isShortcutDown())
                        printMisljenjePsihologa();
                    else if(ke.getCode()==KeyCode.Z && ke.isShortcutDown())
                        //TODO Undo
                    else if(ke.getCode()==KeyCode.Z && ke.isShiftDown() && ke.isShortcutDown())
                        //TODO Redo
            });Performance? Who cares about performance... 8-)

Maybe you are looking for

  • ALV Report: How to pass the variable in Work area to the FM ? Please help !

    I want to pass the field in the work area which contains the floating point numbers to FM 'FLTP_CHAR_CONVERSION_FROM_SI'. This the correct FM, I have tested. If I specify the field with Tab name in FM , It says its not an internal table with header l

  • Switching back to U.S. store from U.K. Store?

    How do I?

  • ICal not displayed correctly.

    I have a few odd problems with my iCal. This seemed to happen when I upgraded to Leopard and I can't fix it. First the icon does not display correctly in the dock. The month and day is there but the calendar part of the icon is transparent, however,

  • Can't see shared iPhoto library

    Computer A can't see Computer B's shared iPhoto library, but B can see A's. Both are running identical versions of iPhoto. Both can see each other's iTunes library. Both can connect to each other over the network and transfer files to and fro (they'r

  • Is it possible to obtain the src of pet store 2.0 without CVS?

    Is there any way I could obtain the petstore 2,0 as a zip file like it used to be in pet store 1.3.2? Please, let me know where I can get it? It is amazing, all the download button in Sun link to yet another place of blueprints. previous sites with d