Tabbing on swing...

Hi,
I am trying to use a Gui piece that uses a Jframe in whihc there is a Jpanel and other stuff. Now this is a piece that was used in someother application and everything works fine and ifyou want to tab through different components like buttons and JTextfields it does go through and you can move aorund using the Tab key.. now i dont think i have changed much in the GUI part and just tried to fix it with the new appliction and now the tabbing doesnt work..
does any body have any idea.
i woul really appreciate ur help.
tell me is this method has anything to do with it
public boolean isManagingFocus()
        return true;
    }

sorry for the late reply altyhough its my need..
Ok here was the problem followed by the solution:
The GUI peice was originally working on jdk1.3 i guess and was working fine..
wat happened was a that in jdk 1.4 the focus thing on the component changed
Solution..
well this is what i did:
after each
someswingcompnent.setEnabled(true);i added
someswingcomponent.setFocusable(true);and the tabbing started working.. now i can move around the whole gui peice with the tab key...

Similar Messages

  • Moowing focus with the tab key (swing)

    Hi. I have a JFrame with 4 text areas in. I want to be able to "hop" to the next text area by pressing the tab key. Most internet pages says this is default, but when I press tab, I get a tab space inside the text area I'm in.. Any ideas on how to do this? (i use Java 1.5)

    HashSet focusForward = new HashSet();
    HashSet focusBackward = new HashSet();
    focusForward.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB,0));
    focusBackward.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB,InputEvent.SHIFT_DOWN_MASK));
        myTextArea.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,focusForward);
    myTextArea.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,focusBackward);

  • How to find name of tab in a JTabbedPane?

    I have some panels added to different tabs in a JTabbedPane. I want to get the name associated to the tab that the user clicks on. I tried a search on the forum but couldn't find anything.
    I have the below method that will tell me when I changed tabs, but what now?
    tabbedPane.addChangeListener(new javax.swing.event.ChangeListener() {
      public void stateChanged(javax.swing.event.ChangeEvent event) {
        System.out.println("Changed tabs.");
    });Thanks for any/all help!

    Thank you for your reply. Although I could have done without the smart ass comment, I still appreciate your help!
    For those of you comming across this thread in a search, here is the solution:
    tabbedPane.addChangeListener(new javax.swing.event.ChangeListener() {
      public void stateChanged(javax.swing.event.ChangeEvent event) {
        javax.swing.JTabbedPane tab = (javax.swing.JTabbedPane)event.getSource();
        String strTabName = tab.getTitleAt(tab.getSelectedIndex());
        System.out.println(strTabName);
    });

  • Create tabs without JTabbedPane?

    Hello,
    I am currently trying to code a little editor with Swing on Mac OS X Leopard. To edit multiple files at once, a tabbed layout would be very useful. So far, the only way to create tabs in Swing I found is by using a JTabbedPane.
    But using a JTabbedPane doesn't result in what I'm looking for.
    Instead of the [JTabbedPane-tabs|http://i40.tinypic.com/2dv0w7b.jpg], I'm looking for native-looking, browser-style tabs, like these, or these .
    I think I once read something about these kind of tabs on the Apple Developer website, but I cannot find the text anymore.
    Is there any way to make such browser-style tabs in Swing?
    EDIT: Maybe [this page|http://code.google.com/p/macbeans/source/browse/trunk/src/org/behrang/macbeans/tab/?r=5] gives the answer? It's the source code for a Netbeans plugin, which also changes the Netbeans tabbar. I don't understand the code though...

    Have you tried setting a native lookAndFeel?
    http://www.tutorialized.com/view/tutori … Java/10062
    though from what I can remember, the linux 'native' look is fairly lame. Does it have to be swing? Iirc SWT looks more native in many cases.

  • Integrate a close button with tabbed pane?

    I like FireFox and I like using parts of its design concepts. How do I put a close button on the right corner of a tab using swing? Maybe I need a "cross" image? Maybe I just put an "X" character there?
    I tried tabProcessToBeClosed.close() or tabProcessToBeClosed.exit(), but it does not close the tab. Is there any other ways?

    I found the following to be extremely useful for constructing a tabbed pane with or without a close button.
    [http://weblogs.java.net/blog/alexfromsun/archive/2005/11/tabcomponents_i_1.html|http://weblogs.java.net/blog/alexfromsun/archive/2005/11/tabcomponents_i_1.html]

  • Problem In Deleting file

    When I call fileone.exists()
    It is returning true.
    But I am unable to delete file even after calling fileone.delete();
    There are some tabs in Swings. From deletion tab I am trying to delete. But I am unable to delete.
    I tried to delete the same file from a simple Java file I am able to delete it.
    Is there any lock preventing me from deleting the file ?
    Any help is appreciated.............

    As you can see in many threads, people talks about a bug in some JVM implementations preventing files to be deleted even if you have closed any stream related to it. I tried many times to delete files to no success until I read some posts advising to use the System.gc() method to destroy any object previously closed (but presumably still existing).
    I tried
    System.gc();
    for(File iterator: arrayOfFiles)
    iterator.delete();
    but the result I obtained wasn't totally satisfactory, because the first files from the array of files weren't delete while the last ones were. So I thought that maybe the problem is the garbage collector had no time to "act" before the first files were deleted. My (not quite elegant, but effective) solution was to introduce a delay of 500ms between the garbage collector request and the first delete statement. I know you have no warranty about the garbage collector acting when you ask it to, but... Anyway, this is my code:
    System.gc();
    Thread.sleep(500); // delay to allow the garbage collector to do its work before any deletion is attempted
    for(File iterator: arrayOfFiles)
    iterator.delete();
    As I could see, it works 100% the times I tested it.
    I don't know if this "solution" was mentioned before or not but, in either case, I hope this helps someone.
    Regards

  • Design Mode Problem

    Every time I go to the Design mode with my Application JDEV crashs !
    Some time I get this message.
    JniPortal for C:\Program Files\Oracle\JDeveloper 3.1.1.2\java1.2\jre\bin\OJVM\jvm.dll reported
    javax/swing/JMenu
    java.lang.NoClassDefFoundError: javax/swing/JMenu
    void javax.swing.SwingUtilities.updateComponentTreeUI0(java.awt.Component)
    void javax.swing.SwingUtilities.updateComponentTreeUI(java.awt.Component)
    boolean borland.jbuilder.uidesigner.DesignerAddin.activate(borland.jbuilder.cmt.CmtComponentModel, borland.jbuilder.cmt.CmtModelNode, borland.jbuilder.cmt.CmtModelNode, borland.jbuilder.designer.DesignContext)
    borland.jbuilder.designer.Designer borland.jbuilder.designer.DesignContext.edit(borland.jbuilder.cmt.CmtModelNode)
    void borland.jbuilder.designer.DesignContext.open(borland.jbuilder.addin.Url, boolean)
    void borland.jbuilder.designer.DesignContext.changeUrl(borland.jbuilder.addin.Url)
    void oracle.jdeveloper.addin.impl.JavaMasterViewerImpl.changeViewerUrl(java.lang.String)
    void oracle.jdeveloper.addin.CustomViewer.changeUrl(java.lang.String)
    void oracle.jdeveloper.addin.JavaMasterViewer_JavaDispatch.invoke(int, borland.javaport.JavaCallStack)
    null

    "java.lang.NoClassDefFoundError: javax/swing/JMenu"
    Did you add the swing library to the list of libraries used by the project? (double click on the .jpr file in the upper navigator window, click on the library tab)
    Is swing 1.1.1 there? If you, add it via the Add button.

  • How does SWING handle HTML in Tabs (labels, etc)

    Hello,
    I've got a class ("UnderlinedTabbedPane") that extends JTabbedPane and (you guessed it!) underlines the current selection. It does this by just changing the title to <html><u>[title]</u></html>.
    All well and good.
    The trick is that when our customers use a screen reader, this reader speaks out "Title left-slash html greater." I've played around with the accessibility framework and accessible context (which never gets any HTML put into it) but the screen reader kept at it.
    So then I just changed the title to "<html><u>[title]."
    Sure enough, that worked. The next tabs (and other items) don't underline, and the reader is happy. Is SWING just appending a </html> onto my title (so that I'd get two of them, which may be what the screen reader was keying off)? What's going on under the hood with HTML labels?
    Thanks

    Ok, got it. So i´ll answer it myself – of course html and all assets will be integrated if you import your html-folder as an article.
    So, next question – it appears that DPS can´t display .php-files, especially something like this <?php include("menu.html");?>
    won´t be displayed correctly. Any hints on that topic?
    Thanks,
    André

  • TAB key isn't available in swing applications on Linux

    Hello,
    I have a small Swing application, everything works fine except that TAB key isn't available within java
    application. I tried several JVM (IBM and Sun JVM from 1.2.2 to 1.4.0_b92) and two Red Hat release (6.2 and 7.2), I had no success with TAB key. The same application works perfectly on Windows for example. Can this problem have something to do with a bad Xmodmap file? I tried with a standard Xmodmap file (/usr/X11R6/lib/X11/etc/xmodmap.std), but TAB key was still unavailable. On non-java application, TAB key is available normally.
    Any suggestion would be appreciated.
    Thanks in advance.

    Do you mean that
    (1) when you are running a swing application and you press the tab key expecting focus traversal, nothing happens?
    OR
    (2) when you are listening for KeyEvent within your application, tab key doesn't give you KeyEvent.VK_TAB?
    OR
    (3) something else?
    I have no Linux but would try to offer suggestions if I understood better.

  • Swing Tabbed Pane Event

    Does anyone know how to put an event listenter/handeller etc on the event for selecting a tabbed pane from a tab.
    What type of listener is used and what event?
    I want to change the caption on a label when a tab is selected using the setText() method
    thanks

    Here is a link to a section in the Swing tutorial titled "Listeners Supported by Swing Components"
    http://java.sun.com/docs/books/tutorial/uiswing/events/eventsandcomponents.html
    The tutorial also shows you how to write a listener. Keep this link for future reference.

  • Tab index settings in swings

    hi
    i am working on swings i am using gridbaglayout.
    when ever i am adding components to grid it is automatically setting some default tab settings in an order but if we want to set our own tab settings then how can we do that.
    can any one help me out.
    thanks in advance
    siri

    Hi Martin,
    A two-character indent is the default indent level. If you want to change the width of the tab indent, you will need to modify the registry. Add a string value under the node
    HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE called
    DE_PREFS_TABSIZE. Change the value to the number of characters that the tab key should indent.
    Check out the book 'Oracle Developer Advanced Forms and Reports' published by Oracle Press for more info.
    Hope this helps.
    Ramesh

  • Can swing handle Tab Character?

    I output a Message Box using swing like this:
    String s = new String("Sun \tMon \tTue \tWed \tThu \tFri \tSat\n");
    JOptionPane.showMessageDialog(null, s, "The Date!", JOptionPane.PLAIN_MESSAGE);But seems like it cannot print the Tab Character.

    JTextAreas can read tab characters, you might try
    JTextArea textArea = new JTextArea("Sun \tMon \tTue \tWed \tThu \tFri \tSat\n");
    JOptionPane.showMessageDialog(null, textArea, "The Date!", JOptionPane.PLAIN_MESSAGE);

  • How to provide space between two tabs in a tabbed pane using Swings?

    I want to place two tabs on a tabbed pane with a specified gap in between. How to give the space between them. Please suggest me how to implment this.
    Thanks in advance.

    set your own UI, overriding paintTab(..) to add 5 (or whatever gap) to each of rects.x

  • Creating mouse rollover events on tab selectors in Swing

    Hi,
    I have a jTabbedPane on which I have placed several panels to make tabs.
    Here are the two problems.
    1.How can I control the background color of the tab selector(where the title of the tab resides) when its tab is selected. I have been able to set dynamically the unselected ones.
    2. How can I change the color of the text in the title of the tab when the mouse rollovers the tab selector. When a mouse goes over the selector, the text in the selector needs to change to blue. When the mouse leaves the selector the text color needs to go back to black. I need to capture the event for the selector part only.
    I have been able to do it with buttons but how can I do it with tab selectors?
    Thanks for your help.

    I just did this quick but hopefully it should help you with the mouse events, simply get the rectangles that are associated with the tabs, and dectect when the mouse is inside of one, or not inside of one
    public class TabbedPaneExample {
         JTabbedPane tabbedPane;
         Rectangle r[];
         public TabbedPaneExample() {
              tabbedPane = new JTabbedPane();
              tabbedPane.addTab("PANEL1", new JPanel());
              tabbedPane.addTab("PANEL2", new JPanel());
              tabbedPane.addTab("PANEL3", new JPanel());
              JFrame frame = new JFrame("TabbedExample");
              frame.setSize(400, 400);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.getContentPane().add(tabbedPane);
              frame.setVisible(true);
              //Get the rectangles associated with each tab
              TabbedPaneUI ui = tabbedPane.getUI();
              r = new  Rectangle[3];
              for (int j = 0; j < 3; j++)
                   r[j] = ui.getTabBounds(tabbedPane, j);
              //add a MouseMotionListener to detect when a mouse enters a tab
              tabbedPane.addMouseMotionListener(
                   new MouseMotionAdapter() {
                        public void mouseMoved(MouseEvent e) {
                             for (int j = 0; j < 3; j++)
                             if (r[j].contains(e.getPoint()))
                                  //put your code for changes here
                                  System.out.println("inside a tab");
         public static void main(String args[]) {
              TabbedPaneExample tp = new TabbedPaneExample();
    }Hope that helps

  • Using Shift+Tab With in JTable (Swing)

    My Jtable have 4 columns , one of the column that is third one is setEditable fale , now im using SHIFT+TAB to travel the cells in this situation i cant travell from 4th cell to 2nd one because the third one is non editable , is ther any work around ??

    Raggy,
    Actually my problem is like this.No. Why tab INTO a cell which can't be edited... the tab key "moves to the next active control"... an uneditable cell isn't "active", so don't risk wearing-out the users precious nail polish by making them hit the tab key an extra time.
    Sometimes this job scares me... the time, effort, thought, and talent which goes into such innanities. Sheesh!
    Go ask your users which they'd prefer.
    Keith.

Maybe you are looking for