To make TAB out of JTextArea

Hi,
I found someone post the following code inthe forum. It supposes
to trap the tab key and move the focus to the next component, instead
of having the tab in the JTextArea. I got it complied okay, but I
received exception when executing:
java.lang.ClassCastException: javax.swing.KeyStroke
at java.util.TreeMap.compare(TreeMap.java:1081)
at java.util.TreeMap.put(TreeMap.java:459)
at java.util.TreeSet.add(TreeSet.java:205)
The exeception is from the 3rd line of the codes.
Please help!!!
Pin
Codes...
Set forwardTraversalKeys = new TreeSet();
forwardTraversalKeys.add(KeyStroke.getKeyStroke('\t'));
forwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
InputEvent.CTRL_MASK));
textArea.setFocusTraversalKeys
(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
forwardTraversalKeys);
Set backwardTraversalKeys = new TreeSet();
backwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
InputEvent.SHIFT_MASK));
backwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
InputEvent.SHIFT_MASK |InputEvent.CTRL_MASK));
textArea.setFocusTraversalKeys( KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backwardTraversalKeys);

Sorry about my last post. I just cut and pasted some code from an example that uses a background image in the text area and should have deleted the paintComponent() method. Here is the complete code in case you want to try again. This works in JDK1.3. I know focus management has changed in JDK1.4, but you don't mention which version you are using.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
public class BackgroundFloating extends JFrame
     JTextArea textArea;
     JScrollPane scrollPane;
     ImageIcon image;
     public BackgroundFloating()
          image = new ImageIcon("???.jpg");
          textArea = new JTextArea( "one two", 10, 30 )
               public void paintComponent(Graphics g)
                    Point p = scrollPane.getViewport().getViewPosition();
                    g.drawImage(image.getImage(), p.x, p.y, null);
                    super.paintComponent(g);
               //  the tab character is not inserted into the text area
               public boolean isManagingFocus()
                    return false;
          textArea.setOpaque(false);
          textArea.setFont( new Font("monospaced", Font.PLAIN, 12) );
          textArea.setLineWrap( true );
          textArea.setWrapStyleWord( true );
          scrollPane = new JScrollPane( textArea );
          getContentPane().add( scrollPane );
          getContentPane().add( new JTextField(20), BorderLayout.SOUTH );
     public static void main(String[] args)
          BackgroundFloating frame = new BackgroundFloating();
          frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
          frame.pack();
          frame.setVisible(true);
}

Similar Messages

  • How do you tab out of JTextArea?

    When using the tab key to change focus from one
    JComponet to the next, how do you tab out of, and
    into next JComponent when you're in an editable
    JTextArea? Is it possible?

    Move to the bottom of the text in a JTextArea with VK_CONTROL + VK_END.
    Better yet, here is how to find all the input actions that you can trigger when focus is on a JTextArea (or any given JComponent)
    JTextArea text = new JTextArea();
    InputMap im = text.getInputMap();
    KeyStroke[] ks = im.allKeys();
    SortedMap map = new TreeMap();
    for(int i=0; i<ks.length; ++i)
        map.put(im.get(ks), ks[i]);
    for(Iterator i = map.entrySet().iterator(); i.hasNext() ; ) {
    Map.Entry pair = (Map.Entry) i.next();
    System.out.println(pair.getKey() + "\n\t" + pair.getValue());

  • Bug- Dragging tabs out of safari sometimes makes the tab disappear - cool p

    Here's an interesting bug. I started playing a video in a tab and then I tried to drag the tab out of the window. When I let go of the tab the window stayed inside of the original safari window +but not in a tab+. I took a screenshot, notice that no tab is highlighted, so the window shown is not in any tab.
    The only way I could get back to it was by using ctrl-tab.
    http://img.skitch.com/20090903-p8qcnkbs2k1w7f6jx1npckmep9.png

    Here's an interesting bug. I started playing a video in a tab and then I tried to drag the tab out of the window. When I let go of the tab the window stayed inside of the original safari window +but not in a tab+. I took a screenshot, notice that no tab is highlighted, so the window shown is not in any tab.
    The only way I could get back to it was by using ctrl-tab.
    http://img.skitch.com/20090903-p8qcnkbs2k1w7f6jx1npckmep9.png

  • Can't drag a tab out

    The demo video and help both state you can drag a tab out of the current window to the desktop to make a new window with that tab. Does not work on my Windows XP system. Work for anyone else?

    Also important to note, if you want to take a separate window and make it a tab in a different window, make sure the "Show Tab Bar" under the View menu is selected, and as with removing a tab, click on it and drag it downward from the tab bar and drag and drop it onto the tab bar of the other Safari window.

  • When tab out of an autoSubmit field I lose focus.

    Hello all!
    I'm using jDev 11.1.2.1.0
    I'm facing the following situation. In the employees VO there is a transient attribute which is actually the salary * commissionPct.
    In the jspx, in order to make things interactive, salary and commisionPct have autoSubmit=true. When I change either of the fields the transient column refreshes accordingly. Up to here everything is fine.
    The problem is that when I make a change to either of these fields and tab out the focus is lost. This is very annoying. It happens only in salary and commissionPct fields.
    Is there any way to avoid this??
    Thanks a lot!
    -apostolos

    Sudipto thanks for the link. Very useful.
    I actually use PPR in the employee Iterator, and this is because there is a master-detail functionality in the page. Suppose I have a case similar to department-employees case.
    If I remove the PPR then the master and detail are not synchronized.
    At the bottom you see the sums filed which is actually the product of salary and commissionPct.
    <af:table value="#{bindings.EmployeesVO1.collectionModel}"
                              var="row" rows="#{bindings.EmployeesVO1.rangeSize}"
                              emptyText="#{bindings.EmployeesVO1.viewable ? 'No data to display.' : 'Access Denied.'}"
                              fetchSize="#{bindings.EmployeesVO1.rangeSize}"
                              rowBandingInterval="0"
                              selectedRowKeys="#{bindings.EmployeesVO1.collectionModel.selectedRow}"
                              selectionListener="#{bindings.EmployeesVO1.collectionModel.makeCurrent}"
                              rowSelection="single" id="t1">
                        <af:column sortProperty="#{bindings.EmployeesVO1.hints.EmployeeId.name}"
                                   sortable="true"
                                   headerText="#{bindings.EmployeesVO1.hints.EmployeeId.label}"
                                   id="c1">
                            <af:inputText value="#{row.bindings.EmployeeId.inputValue}"
                                          label="#{bindings.EmployeesVO1.hints.EmployeeId.label}"
                                          required="#{bindings.EmployeesVO1.hints.EmployeeId.mandatory}"
                                          columns="#{bindings.EmployeesVO1.hints.EmployeeId.displayWidth}"
                                          maximumLength="#{bindings.EmployeesVO1.hints.EmployeeId.precision}"
                                          shortDesc="#{bindings.EmployeesVO1.hints.EmployeeId.tooltip}"
                                          id="it1">
                                <f:validator binding="#{row.bindings.EmployeeId.validator}"/>
                                <af:convertNumber groupingUsed="false"
                                                  pattern="#{bindings.EmployeesVO1.hints.EmployeeId.format}"/>
                            </af:inputText>
                        </af:column>
                        <af:column sortProperty="#{bindings.EmployeesVO1.hints.FirstName.name}"
                                   sortable="true"
                                   headerText="#{bindings.EmployeesVO1.hints.FirstName.label}"
                                   id="c2">
                            <af:inputText value="#{row.bindings.FirstName.inputValue}"
                                          label="#{bindings.EmployeesVO1.hints.FirstName.label}"
                                          required="#{bindings.EmployeesVO1.hints.FirstName.mandatory}"
                                          columns="#{bindings.EmployeesVO1.hints.FirstName.displayWidth}"
                                          maximumLength="#{bindings.EmployeesVO1.hints.FirstName.precision}"
                                          shortDesc="#{bindings.EmployeesVO1.hints.FirstName.tooltip}"
                                          id="it2">
                                <f:validator binding="#{row.bindings.FirstName.validator}"/>
                            </af:inputText>
                        </af:column>
                        <af:column sortProperty="#{bindings.EmployeesVO1.hints.LastName.name}"
                                   sortable="true"
                                   headerText="#{bindings.EmployeesVO1.hints.LastName.label}"
                                   id="c3">
                            <af:inputText value="#{row.bindings.LastName.inputValue}"
                                          label="#{bindings.EmployeesVO1.hints.LastName.label}"
                                          required="#{bindings.EmployeesVO1.hints.LastName.mandatory}"
                                          columns="#{bindings.EmployeesVO1.hints.LastName.displayWidth}"
                                          maximumLength="#{bindings.EmployeesVO1.hints.LastName.precision}"
                                          shortDesc="#{bindings.EmployeesVO1.hints.LastName.tooltip}"
                                          id="it3">
                                <f:validator binding="#{row.bindings.LastName.validator}"/>
                            </af:inputText>
                        </af:column>
                        <af:column sortProperty="#{bindings.EmployeesVO1.hints.Salary.name}"
                                   sortable="true"
                                   headerText="#{bindings.EmployeesVO1.hints.Salary.label}"
                                   id="sal">
                            *<af:inputText value="#{row.bindings.Salary.inputValue}"*
                                          label="#{bindings.EmployeesVO1.hints.Salary.label}"
                                          required="#{bindings.EmployeesVO1.hints.Salary.mandatory}"
                                          columns="#{bindings.EmployeesVO1.hints.Salary.displayWidth}"
                                          maximumLength="#{bindings.EmployeesVO1.hints.Salary.precision}"
                                          shortDesc="#{bindings.EmployeesVO1.hints.Salary.tooltip}"
                                          id="it6" autoSubmit="true">
                                <f:validator binding="#{row.bindings.Salary.validator}"/>
                            </af:inputText>
                        </af:column>
                        <af:column sortProperty="#{bindings.EmployeesVO1.hints.CommissionPct.name}"
                                   sortable="true"
                                   headerText="#{bindings.EmployeesVO1.hints.CommissionPct.label}"
                                   id="comm">
                            *<af:inputText value="#{row.bindings.CommissionPct.inputValue}"*
                                          label="#{bindings.EmployeesVO1.hints.CommissionPct.label}"
                                          required="#{bindings.EmployeesVO1.hints.CommissionPct.mandatory}"
                                          columns="#{bindings.EmployeesVO1.hints.CommissionPct.displayWidth}"
                                          maximumLength="#{bindings.EmployeesVO1.hints.CommissionPct.precision}"
                                          shortDesc="#{bindings.EmployeesVO1.hints.CommissionPct.tooltip}"
                                          id="it7" autoSubmit="true">
                                <f:validator binding="#{row.bindings.CommissionPct.validator}"/>
                            </af:inputText>
                        </af:column>
                        <af:column sortProperty="#{bindings.EmployeesVO1.hints.Sums.name}"
                                   sortable="true"
                                   headerText="#{bindings.EmployeesVO1.hints.Sums.label}"
                                   id="c9">
                            *<af:inputText value="#{row.bindings.Sums.inputValue}"*
                                          *label="#{bindings.EmployeesVO1.hints.Sums.label}"*
                                          *required="#{bindings.EmployeesVO1.hints.Sums.mandatory}"*
                                          *columns="#{bindings.EmployeesVO1.hints.Sums.displayWidth}"*
                                          *maximumLength="#{bindings.EmployeesVO1.hints.Sums.precision}"*
                                          *shortDesc="#{bindings.EmployeesVO1.hints.Sums.tooltip}"*
                                          *id="it8">*
                                *<f:validator binding="#{row.bindings.Sums.validator}"/>*
                            *</af:inputText>*
                        </af:column>
                    </af:table>Edited by: apostolosk on May 2, 2012 3:19 PM

  • Tab out of quotes, parens, and brackets

    I have developed quite a bit in eclipse, for both java and flex. One of my favorite features in java development is the ability to "tab" out of quotes, and parens. I would like to see this abiltiy in mxml and as files as well. They say the things that make a product the most appealing are the small and simple things, and this is defenently one of those small things that would make flex development a whole lot nicer, especially when you are putting a bunch of attributes in mxml.
    If anyone knows of a way to enable this feature in flash builder, i would love to know how, and if there isn't any way to get this feature going, where could I post this to request it as a feature in the final version of flash builder?

    Yes, I'd like to have this too -- along with the ability to "type through" quotes and parens, i.e. if FB inserts quotes or parens for you (for instance, with MXML attribute code hints), you can still type the quote and it'll skip over the existing one, rather than inserting a second.
    I thought there was a bug for the latter, but now I can't find it. (Jason, have you seen it?)
    And Sean, I saw FB-21819 regarding your idea, thanks for opening that.
    gse

  • Howto make tabs show up in the title bar

    There was a version of safari that had the tabs in the title bar anyone know how to mac that happen on windows?
    found this for OS X, but stuck with winblows at work
    http://jkontherun.com/2009/03/11/how-to-get-safari-4-for-mac-tabs-out-of-the-tit lebar/

    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]
    This can also be a problem with the file places.sqlite that stores the bookmarks and the history.
    * http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox

  • Clicking certain parts of PS CC UI remove brush functionality (can't paint until tab-out)

    I ran this fix here on the Asus Vivotab Note 8: http://helpx.adobe.com/photoshop/kb/tablet-functions-dont-photoshop-142.html
    and ran into this weird problem.
    if I click certain parts of photoshop -- ie the swatches which were docked to the right as default -- the brush would not paint. this is fixable by tabbing out, or clicking on the photoshop icon on the taskbar even and clicking back on PS. moving the swatches and all the other toolbars slightly so that none of them are docksnapped to edges fixed that problem with most of the buttons, tec. BUT using the menu pulldowns at the top will trigger this annoyance, also if I use a plugin like painters wheel, for example, clicking the colour wheel itself will render the brush non-functional again. Also, clicking certain settings inside the brush settings menu will also trigger this problem (like pulldown menus, etc).
    Thanks for looking into this!

    Hey there. It didn't make a difference whether it was disabled for rightclick or not. However I grabbed the latest feelit drivers that came out yesterday from Wacom, and now the problem has metamorphosed: it fixes the majority of the menu disabling brush issues, but now photoshop will sometimes disable pressure sensitivity until I tab out and tab in again. this is something that also randomly breaks in photoshop CC on my desktop computer at work (on a cintiq with windows 8), I have to occasionally tab out and tab back to get pressure to come back. Any suggestions or thoughts would be really welcome as it's really annoying when it breaks up my workflow.
    Thanks!

  • How do you make tabbing skip a disabled field?

    Hi, how do you make tabbing skip a disabled field?
    I have a checkbox. If it's checked, one radio button in a radio button group is disabled. However, user can still tab into this disabled radio button. Once it's in there, it cannot tab out or use up & down arrow to move out of the disabled radio button. It just gets stuck there.
    I tried setting access="protected". But it makes no difference.
    Is there a way to exclude a disabled field from receiving a tab in LiveCycle Designer?
    Thanks.

    You may create your JTextField with the text i.e.
    JTextField myTextField = new JTextField("text");
    or anywhere in your program
    myTextField.setText("text");

  • Alt Tabbing out of Games take very long

    Alt-tabbing out of games take very long... about 5 seconds... the screen turns black i never had this problem in win 7 or 8.1. 
    I just installed win 10 on my laptop too see if this problem exists there... it doesnt :D
    Someone got an Solution?
    4770k
    16gig Ram
    780Ti
    MSI Mpower MB

    Hi,
    " I just installed win 10 on my laptop too see if this problem exists there...
    it doesnt :D"
    Does this issue happen in Windows 10 Technical Preview or not?
    If you don't start the game, and press alt-tab to switch between other applications, does it have a delay?
    Meanwhile, update the graphic driver to make the game more smoothly.
    Or it's game ot hardware related, see some explanation in the link below
    http://www.howtogeek.com/181761/why-pc-games-struggle-with-alttab-and-how-to-fix-it/
    NOTE
    This
    response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you.
    Microsoft
    does not control these sites and has not tested any software or information found on these sites.
    Yolanda Zhu
    TechNet Community Support

  • How can we make an outer join (+) between 2 Queries

    in the data model, i have 2 queries
    i.e
    Q_master and Q_detail
    i want to make a data link between
    these two queries and
    also make an outer join between these
    two queries(i.e. to display all the detail
    records, whether they have details or not)
    please reply is it possible ?
    if yes then how?
    plz write.
    [email protected]
    null

    Hello,
    Left outer join behavior is what you get by default with a link between two queries in Reports.
    If you want a full outer join behavior, you'll need to create a third query that selects the detail records that have no corresponding master, and also create an extra layout region to display them in as a default group left or group above won't pick up these extra records.
    If you want right outer join behavior, you'll need to put in a summary in the master query that counts the rows in the detail, and then put in a format trigger in the master repeating frame that suppresses printing when there are no detail records. And you'll also need the third query and layout section as in the full outer join case.
    Regards,
    The Oracle Reports Team --skw                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How do I create a new row on tab out of the last column, last row?

    JDev 11.1.2.1.0.
    I've seen a few topics on this but none that I think were really very good solutions.
    Use Case:
    On tab out of the last column in the last row, a new row should be added to the end of the table. Bonus points for setting the focus to the first <af:inputText> of the newly created row.
    Complications:
    1. I'm having a heck of a time trying to find a function that returns the column's displayed index. Sadly, <column binding>.getDisplayIndex() returns -1 unless the user has manually re-ordered the column.
    2. Value Change Listeners only fire if there is a value change. Guess that means I need to do client/server listeners to check each and every <af:inputText> for a tab press?
    3. I'm not even going to get into setting the focus. With all the templates, regions, etc. going on, it's dang near impossible.
    Any ideas on how to attack this one?
    Will

    Hi,
    You will need to use the Run Engine Installation Wizard found on the Tools menu. In addition you need to create a installation set for the operator interface.
    Look at Chapter 16 Distrubuting TestStand ( chapter 17 for version 2).
    Once you have created your installation, install is on your new system.
    The serial number etc is part of the process model. When you run the entry point 'Test UUTs' the PreUUT callback is executed which asks the user for the serial number.
    Hope this helps
    Ray Farmer
    Regards
    Ray Farmer

  • Can I use iCloud as my library instead of using local storage?  Would I be able to synchronize the music on my phone? and make CDs out of the my music in the icloud using itunes?

    Can I use iCloud as my library instead of using local storage?  Would I be able to synchronize the music on my phone? and make CDs out of the my music in the icloud using itunes?

    Many thanks JEM24 for your help.  Ive just spent the best part of six hundred pounds on a new Sony Rx100m2 compact camera, so I have no interest in the Ipods camera at all really. I doubt Ill be watching many videos on it as Im very lucky in that I have a good Android tablet. Its more as a stock music player that Ill be buying the Ipod for, if indeed I do end up buying one. I dont like the idea of paying the exorbitant amount added for more memory space that Apple along with most other companies charge. In fact I read an article on this very subject just yesterday in the tech section of Flipboard. It stated in the article that in the case of the Iphone  the actual cost of each additional  gigabyte of storage  to Apple et al is something in the order of 60p.. This is certainly not reflected in the price us the customer has to pay at the till.. Its for this reason primarily that Apple in particular, because their products do not allow adding expandable memory of your own in the form of cheap to buy cards, that nobody in their right mind buys the 64gig etc Iphones..I am aware that we are discussing my potential purchase of an Ipod Touch here but you see my point. Many thanks again though for helping me.

  • How to populate the data in fields if we tab out at one field

    Hi Gurus,
    I am new to OAF Technology and I've new requirement in custom OAF page.
    We have 12 fields like ID, Fname, Lname, Age, Address, Tphone etc..
    If we enter ID in message text input field box and tab out, then it should populate all the remaining fields data by default.
    Could anyone help me regarding this requirement?
    Thanks in Advance
    Sruthi

    Hi,
    Sruthi wrote:
    I am new to OAF Technology and I've new requirement in custom OAF page.
    We have 12 fields like ID, Fname, Lname, Age, Address, Tphone etc..
    If we enter ID in message text input field box and tab out, then it should populate all the remaining fields data by default.
    Could anyone help me regarding this requirement?---MessageTextInput filed set Action property:FirePartialAction and Event:TextInput
    ---Get the Event in co PFR
    if("TextInput".equals(pageContext.getParameter(EVENT_PARAM)))
    AM.setDafultValue();
    ---Write a method in AM
    public void setDafultValue()
    VOImpl vo=getVO1();
    if(vo!= null)
    vo.getCurrentRow().setAttribute("Number1","DefaultValue1");
    vo.getCurrentRow().setAttribute("Number2","DefaultValue2");
    ---Like this u can set default value when tab out.
    Regards
    Meher Irk

  • A black bar appeared at the bottom of the new window after I drag a tab out.

    this is actually an issue back in the mavericks safari, but the problem was somehow solvable and was not appearing every time.
    after upgrading to Yosemite, this problem appears every time.
    The problem is : when I have several tabs, then I drag a tab out, which you can see the minimized window.
    After you release it, it will become a new window as expected and intended. BUT there will be a black bar underneath.
    In the Youtube website, you can see that the upper part of the site is actually being blocked by the toolbar.
    ( I had waited for several seconds to let the toolbar to get to its original position )
    Clearly the black bar at the bottom caused this problem.
    It's a very annoying issue.
    I am not sure if it's a problem of Yosemite or Safari. But back in to mavericks, the problem also existed.
    Is there anyone out there having the same problem?
    How to Fix it ?
    P.S.1 HOWEVER, if i right-clicked the tab and select "move tab to a new window", the problem DOES NOT exist.
    P.S.2 I am using Mac Book Air(13", Mid 2013),  OS X Yosemite  (10.10.2)

    In the App store window at the top click on Purchases. Your download progress is there. If the progress seems to have stalled, click on the pause button and then restart the download. It should pick up where it left off.
    HTH

Maybe you are looking for