Extending functionality of JTextField

Hello,
Just getting going with swing here. I'd like to make a custom JTextField that handles typing differently (for example, allowing entry of numbers only, or refusing to allow more than 3 characters, etc).
I've got a good start, but I'm stuck at the KeyListener ActionListener part. Here's some code:
public class DEField extends JTextField implements KeyListener, ActionListener
But, in the example I found, the listeners and stuff are handled in the app itself, not in the component:
http://java.sun.com/docs/books/tutorial/uiswing/events/keylistener.html
Any guidance is appreciated!
--- Eric

Thank you for that tip! Indeed, there it is, as you described.
Maybe this would be a good place to ask for feedback on what I am intending to build...
My intentions are to eventually make a highly customizable field for data-entry purposes. I'm starting down this path now. Some features I'll be working on:
1. A fixed (settable) number of characters allowed, with a beep sounding when characters in excess are entered. When the last character is entered, focus will move to the next field in the tab order.
2. An automatic drop-down list containing a sorted list of all allowed entries for this particular field. As the user types, the list will shrink in number, and scroll to center the current selection. Pressing ENTER will select the one that is currently selected, while the up and down arrow keys will scroll the list.
3. The field will be a certain length (say, 20 characters), regardless of how many characters are allowed to be entered into it (say, 4 characters). If a fixed number of characters are required, then there will be a colored box surrounding the space where each character will go.
4. Configurable at runtime to allow restrictions on allowed characters, color of the border, etc.
5. Accessibility features enabled.
There are probably a few more requirements that I haven't thought of yet, but does this basic description sound reasonable in Java? Is extending the functionality of a JTextField the right way to approach this, or do you think I'd be fighting an uphill battle? Perhaps I should implement it from a more abstract class?
Thanks! --- Eric

Similar Messages

  • I want a router in N-standard which support extend-function. Which product should I buy?

    Hi.
    I want to establish a new wireless network in my house because my old router are crashed after a stroke of lightning. My old router was a Netgear RangeMax Dual Band Wireless-N (WNDR3300). I live in a big old house and my problem with this and my older Linksys router was that the signal could not reach in the ends of the house even though the router was placed in the middle of the house.
    I have heard that you can extend the wireless-signal if you put an extra router (in extend/repete-mode) halfway to the end of the house and this without cables between the "main router" and the secondary router that you have set at extend-mode. Is this correct and if so which Linksys routers supports this extend-function in N-standard (I would like to have the possibility to stream music at the network and I have read that the N-standard would be best to this) and is it the same model I should by for the "mail router" and the router there may be in extend-mode?
    Thanx for your help (-;
    BR
    Jan

    The Linksys router will not work wirelessly with another router with the linksys firmware installed in it.You need hardwired both the router together or need to installed the third party firmware on it.I would suggest you to go for WAP200E Access Point which will work as repeater mode.

  • Extended functions of Info Sets

    Hi Experts,
    what are Extended functions of Info Sets .....Could you plz explain me.
    Regards
    Venkat

    hi,
    we use cubes also in  an infoset like as data store object.
    SAP does not generally support more than two InfoCubes in an InfoSet. If you include more than two InfoCubes in an InfoSet, the system produces a warning. There are several reasons for this limitation
    see this link u get more information for infoset.
    http://help.sap.com/saphelp_nw70/helpdata/EN/42/ca6a69992f6bb1e10000000a1553f6/frameset.htm
    hope its help to u.
    plz assign points if its solve your query.
    thanks,
    suresh.
    Edited by: sureshkumar gedela on Feb 25, 2008 12:03 PM

  • Can't download extended function program

    I can't download evernotel's webclipper.  I already followed the suggestion made by evernote technician that I deleted all related file and programs related to evernote (using appcleaner, empty trash can), restarted Mac, reinstall evernote, and then downloaded webclippers installation file.  When I hit "install" key, a window pops out telling me "unable to install this extended function".  I was unable to install another program, fastestbue, which was another extended program for safari.  I doubt that was because I had Kaspersky installed in my mac.
    My macair has MAC OSX (10.7.5), safari 6.1.1. 

    A.
    Back up all data.
    This procedure will unlock all your user files (not system files) and reset their ownership and access-control lists to the default. If you've set special values for those attributes on any of your files, they will be reverted. In that case, either stop here, or be prepared to recreate the settings if necessary. Do so only after verifying that those settings didn't cause the problem. If none of this is meaningful to you, you don't need to worry about it.
    I've tested these instructions only with the Safari web browser. If you use another browser, they may not work as described.
    Step 1
    If you have more than one user account, and the one in question is not an administrator account, then temporarily promote it to administrator status in the Users & Groups preference pane. To do that, unlock the preference pane using the credentials of an administrator, check the box marked
    Allow user to administer this computer
    Then reboot. You can demote the problem account back to standard status when this step has been completed.
    Triple-click anywhere in the following line on this page to select it:
    { sudo chflags -R nouchg,nouappnd ~ $TMPDIR..; sudo chown -R $UID:staff ~ $_; sudo chmod -R u+rwX ~ $_; chmod -R -N ~ $_; } 2>&-
    Copy the selected text to the Clipboard by pressing the key combination command-C.
    Launch the built-in Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.
    Paste into the Terminal window (command-V). I've tested these instructions only with the Safari web browser. If you use another browser, you may have to press the return key after pasting.
    You'll be prompted for your login password. Nothing will be displayed when you type it. You may get a one-time warning to be careful. If you don’t have a login password, you’ll need to set one before you can run the command. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator.
    The command may take a few minutes to run, or perhaps longer if you have literally millions of files in your home folder. Wait for a new line ending in a dollar sign ($) to appear, then quit Terminal.
    Step 2 (optional)
    Take this step only if you have trouble with Step 1, if you prefer not to take it, or if it doesn't solve the problem.
    Boot into Recovery. When the OS X Utilities screen appears, select
    Utilities ▹ Terminal
    from the menu bar. A Terminal window will open.
    In the Terminal window, type this:
    res
    Press the tab key. The partial command you typed will automatically be completed to this:
    resetpassword
    Press return. A Reset Password dialog will open. You’re not going to reset a password.
    In the dialog, select the startup volume ("Macintosh HD," unless you gave it a different name) if it's not already selected.
    Select your username from the menu labeled Select the user account if it's not already selected.
    Under Reset Home Directory Permissions and ACLs, click the Reset button.
    Select
     ▹ Restart
    from the menu bar.
    B.
    Remove the worthless "Kaspersky" and "AppCleaner."
    Remove "Kaspersky Security" by following the instructions on this page. If you have a different version of the product, the procedure may be different. The product includes a Safari extension that may not be removed by the uninstaller.

  • QRT alert RTMT -- Cisco Extended Function

         Hi All,
    Have been getting this particular alert for a 7937 device -- which has been throwing this particular alert intermittently.
    -/Syslog UC_RTMT-2-RTMT_ALERT: %[Name=ExcessiveVoiceQualityReports][Detail= Number of quality reports exceeds configured threshold during configured interval 10 within 60 minutes on cluster StandAloneCluster. There are 12 QRTRequest events (up to 30) received during the monitoring interval
    AppID : Cisco Extended Functions ClusterID : StandAloneCluster NodeID : HXXXX TimeStamp : Sat Oct 19 18:56:55 CDT 2013 Category : Problems with current call ReasonCode : TimeStamp : 10/19/13 18:56:15 DeviceName : SEP000000000000 IPAddress : 00.000.00.000 DN : 0000 AppID : Cisco Extended Functions ClusterID : StandAloneCluster NodeID : XXXX TimeStamp : Sat Oct 19 18:56:45 CDT 2013 Category : Problems with current call ReasonC! ode : TimeStamp : 10/19/13 18:56:29 DeviceName : SEP00000000000 IPAddress :
    00.000.00.000 DN : 0000 AppID : Cisco Extended Functions ClusterID : StandAloneCluster NodeID
    Reached out to TAC -- they asked for logs -- I need to check before hand the exact cause of this alert as in what triggered this. Have been requested by TAC to check if QRT is enabled -- how can we check that on the device -- as I only see a standard " None" soft key template on the device.
    Appreciate some help on what exactly the alert stands for and what are the steps that can be followed to isolate the issue with this particular alert.
    Whatever level you reach getting better never stops -- Sachin Tendulkar       

    Hi All,
    Can someone please guide on this alert and the steps that are required to troubleshoot the same at the earliest -- would appreciate some assistance on this.
    Whatever level you reach getting better never stops -- Sachin Tendulkar

  • Documentation on extended functions - Siebel

    Pls. anyone has any doc that has some syntax and other details about the BIP extended functions used when integrated with Siebel ?
    I understand they are defined in the XLSFunctions.jar and called thru the psfn: in the field code...
    Txs. for any help.
    Antonio

    The blog has examples and few extension functions too. I dont understand what do you mean by 'no syntax'.
    It has covered steps on usage too.
    For complete list refer MOS note 'Siebel Reporting XSLFunction Methods [ID 1435271.1]'

  • Photoshop CS3 Extended functions don't work

    I just got a copy of Photoshop CS3 Extended.  I am using Windows 7 and it installed fine.  However, I noticed that many functions (i.e Filter Gallery) show up in light gray and can't be activated.  All standard plugins are visible but also can't be triggered.  I am not familiar with Photoshop yet and I am not sure whether I am missing something here.  Any help is much appreciated.
    Thanks

    Thanks a lot or the hint.  Of course I was in 16bits channel.
    Appreciate your help.

  • Disable copy and paste function in jtextfield

    I wish to disable the copy and paste function (CTRL+C and CTRL+V) of the data in the jtextfield... anybody can help?

    I think you can add a KeyListener to listen to those keys and when you get such an input just do nothing. Not tested though.

  • Extending functionality from existing custom taglib

    Hi!
    I'm trying to extend the functionality of an already existing custom taglib. To test this possibility I�ve so far created a small taglib containing two tags. QbeTag.java and QbeSumTag.java.
    The QbeTag class handles a database connection and constructs a table showing the result of a query passed in as an attribute in the tag. (The database contains a �dummy table� holding information about persons.)
    Now let�s pretend that I don�t have the source code for the QbeTag but need to/ want to extend its functionality. For instance:
    In the QbeSumTag I want to summarize all the persons ages and present it in a new text field somewhere else on the page.
    To do this I probably need to access the QbeTag class from the QbeSumTag class, or is there any other way to achieve this wanted functionality?
    Up to this point:
    What I�ve tried is to implement the QbeSumTag so that It extends the QbeTag class. This means that I now can access the doStartTag, doEndTag, and so on methods from the QbeSumTag by typing super.doStartTag().
    The problem with this approach is that this way only gives me the possibility to run the methods not altering the process it self and I can�t alter the out stream. A syntax like:
    public int doStartTag() throws JspException
    return super.doStartTag();
    Will only result in a call for the QbeTag�s doStartTag() method to run and do it�s stuff.
    Is there any way I can solve this or am I stuck? Maybe one approach would be to nest the QbeSumTag with the QbeTag wich would mean that there will be a dependency between the tow tags.
    I believe that this question is quite difficult to answer but it could be the starting point for an interesting discussion. Hasn�t anyone tried to extend the functionality of the Jakarta taglib, say the DB tags or Mail tag.
    All thoughts and replies will great fully received.
    /Daniel

    Well, the answer to this is the same as the answer to extending any third party classes... it depends on how the original class was created.
    If the original class was designed with extension in mind, then (hopefully) its realy functionality will be isolated to a series of protected methods (that you would have access to) and private methods (you would not have access to).
    You would use the public and protected methods to retrieve the data you need to do your work, or override those ones whose work you want to replace (for instance, if it has a protected displayOutput(Map dataMap) method, you are in luck!).
    If everything is done giving you know access to the pieces, then you may be stuck providing a tag that has the original tag nested inside it. Buffer the output from the original tag and parse it, retrieving the info you need, then output your own stuff...

  • Can I extend functionality of Portal Reports / wizard?

    Is there a way to extend the functionality of Portal Reports? I'd like to add some output formatting options to the existing Portal reports functionality, and I don't want to write a complete portlet to do it. I know that I can edit the package after the wizard creates it, but if anyone runs the wizard again, I'll lose my modifications. Can I modify the code generator/wizard?
    Thanks

    Is there a way to extend the functionality of Portal Reports? I'd like to add some output formatting options to the existing Portal reports functionality, and I don't want to write a complete portlet to do it. I know that I can edit the package after the wizard creates it, but if anyone runs the wizard again, I'll lose my modifications. Can I modify the code generator/wizard?
    Thanks

  • Need to extend functionality in VM below ribbon

    Hi,
    I want to extend the VM resource provider to add some more functionality like VM upgrade. This I want to add along with Start, Stop, Checkpoint buttons. Is it possible to extend the below ribbon to add more such options. Any link will be useful.
    Regards,
    Umesh

    I suggest that you start with the API reference: https://msdn.microsoft.com/en-us/library/dn448694.aspx
    Some capabilities are available in the API today, but not exposed in the portal. 
    If you need to extend the WAP solution, there's several ways to do so, like creating custom resource providers or interact with the native API's from other angels. 
    -kn
    Kristian (Virtualization and some coffee: http://kristiannese.blogspot.com )

  • Marquee function for JTextField?

    Hi,
    currently I'm working on a group project to do a media player. I have a JTextField that will display the file name and duration of it. And this text should change when another media file is being played. I am now able to just set the text by using .setText(String text) method.
    It is okay if the text does not exit the length of the JTextField. However, if the text is too long, it is cut off halfway. I am thinking of implementing it in such a way that when the text length exceeds the JTextField's length, the text will move from right to left like what marquee does...
    Do I have to use applet? Or thread? Or neither? Thanks...
    Cozel

    This should get you started:
    * @(#)TextFieldMarquee.java 1.00
    package de.behr.gui;
    import javax.swing.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    * <code>TextFieldMarquee</code>
    * @author Thomas Behr Nov 30, 2002
    public class TextFieldMarquee extends JTextField implements Marquee
         private final Animater animater;
         private final Timer timer;
         private String buffer2;
         private String delimiter;
         private char[] buffer1;
         private int maximumDisplayedCharacters;
         private int scrollDirection;
         private boolean useDelimiter;
          * Constructor
         public TextFieldMarquee()
              animater = new Animater();
              timer = new Timer(200, animater);
              delimiter = " +++ ";
              maximumDisplayedCharacters = 512;
              scrollDirection = RIGHT_TO_LEFT;
              useDelimiter = false;
              setHorizontalAlignment(scrollDirection);
              setText("");
              setEditable(false);
              setBorder(BorderFactory.createEmptyBorder());
         public String getText()
              return buffer2;
         public void setText(String t)
              buffer2 = t;
              buffer1 = (useDelimiter)
                                  ? (t + delimiter).toCharArray()
                                  : t.toCharArray();
              animater.reset();
              _setText("");
         public void setDelay(int milliseconds) {
              timer.setDelay(milliseconds);
         public void setDelimiter(String delimiter)
              this.delimiter = delimiter;
         public void setMaximumDisplayedCharacters(int maximumDisplayedCharacters)
              this.maximumDisplayedCharacters = maximumDisplayedCharacters;
         public void setScrollDirection(int scrollDirection)
              this.scrollDirection = scrollDirection;
         public void setUseDelimiter(boolean useDelimiter) {
              this.useDelimiter = useDelimiter;
         public void startAnimation() {
              timer.start();
         public void stopAnimation() {
              timer.stop();
         private void _setText(String t)
              super.setText(t);
         private String _getText()
              return super.getText();
         private class Animater implements ActionListener {
              private int offset;
              public Animater() {
                   offset = 0;
              public void actionPerformed(ActionEvent e) {
                   if (TextFieldMarquee.this.scrollDirection == RIGHT_TO_LEFT) {
                        scrollRightToLeft();
                   } else {
                        scrollLeftToRight();
              public void reset() {
                   offset = 0;
              private void scrollLeftToRight() {
                   final int length = TextFieldMarquee.this.buffer1.length;
                   final String text =
                                       TextFieldMarquee.this.buffer1[length - offset - 1] +
                                       TextFieldMarquee.this._getText();
                   int end = text.length();
                   if (end >= TextFieldMarquee.this.maximumDisplayedCharacters) {
                        end--;
                   TextFieldMarquee.this._setText(text.substring(0, end));
                   offset++;
                   offset %= length;
              private void scrollRightToLeft() {
                   final int length = TextFieldMarquee.this.buffer1.length;
                   final String text =
                                       TextFieldMarquee.this._getText() +
                                       TextFieldMarquee.this.buffer1[offset];
                   final int textLength = text.length();
                   int start = 0;
                   if (textLength >= TextFieldMarquee.this.maximumDisplayedCharacters) {
                        start++;
                   TextFieldMarquee.this._setText(text.substring(start, textLength));
                   offset++;
                   offset %= length;
    }

  • Extend function in pl/sql table

    declare
    type aar_test is table of varchar2(100)
    index by binary_integer;
    aar_main aar_test;
    begin
    aar_main.extend;
    aar_main(aar_main.last) :='Extend Cell';
    end;
    it's return a error....it is possible??? if yes how...plzzzzzzzz help me...

    Hi..
    Please go through this...!!
    EXTEND
    This procedure has three forms. EXTEND appends one null element to a collection.
    EXTEND(n) appends n null elements to a collection.
    EXTEND(n,i) appends n copies of the ith element to a collection.
    EXTEND operates on the internal size of a collection.
    If EXTEND encounters deleted elements, it includes them in its tally.
    You cannot use EXTEND with associative arrays.Regards
    KPR
    *If this response is correct then mark it as correct answer.
    *If this response is helpful then mark it as helpful answer.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Extending functionality of SynthTreeUI

    I am attempting to build a custom JTree component that needs to dig its claws into the UI. Unfortunately this doesn't seem possible with Synth/Nimbus as it is with Metal. MetalTreeUI is public so I can create:
    class MetalXTreeUI extends MetalTreeUI {}But SynthTreeUI is package private :(
    Perhaps there is a better approach to what I am trying to accomplish so allow me to explain. I have created a custom JTree that uses a JList to render its nodes when the node is an instance of ListModel. The purpose is to display a data structure consisting of groups of large lists. A JTree is used so the a list can be shown/hidden by expanding/collapsing its parent. The JList used to render the lists uses the HORIZONTAL_WRAP layout mode to make the most of the space available. Here is a screen shot of my testing app so that you can visualize what I am probably not explaining very well:
    http://img4.imageshack.us/i/treelist.png/
    The reason the UI needs to be involved is to handle selection changes. The details are quite a bit nostalgic so I won't go into them. But it suffices to say that with MetalTreeUI, it's quite simple, just put the details of the selection change implementation into
    protected boolean startEditing(TreePath path, MouseEvent evt)and
    protected void completeEditing(boolean messageStop, boolean messageCancel, boolean messageTree)as a JList is used as the editor for the ListModel nodes so that the elements in each list can be individually selected and so forth..
    But Synth/Nimbus seems to forbid any ruffling of their handiwork.

    OK, just kidding about overriding that completeEditing method. That was from an old version that didn't keep track of whether a JList node had any selected elements in real time.
    Anyway, the aforementioned nonsense aside, the old way is much better than the new way which attempts the same bag of tricks without interfacing with the UI. But this seems to be a necessary evil as I haven't seen any way to interface with SynthTreeUI. That is bad form on the part of the Synthites IMO. And bad forms beget bad forms (especially with the aid of alcohol) so hence the following:
    An editor is used to hijack the selection handling for all nodes. A regular TreeCellRenderer is used as the editor component for regular nodes and a JList for list nodes, so the tree is not really editable. The problem with this is that the event that triggered the editing needs to be analyzed to check if it is a MouseEvent and if it is, if it is a multi-select event, toggle-selection event or regular select event. Since this is done in the editor and not the UI, the isMultiSelect(MouseEvent) and isToggleSelection(MouseEvent) methods are inaccessible. I have to determine my own conditions...
    And there are various other details that really ought to be done directly in the UI. For instance, when the tree is resized, a node changed event has to be dispatched for each list node to the UI so that it will relayout the lists based on the new size of the tree. Before I could send this only to the UI's tree model listener, but now I have to use valueForPathChanged on the tree model and hope that it sends the appropriate event to all its listeners.
    Is this really the way it is suppose to be? Seems to me that Nimbus' mantra of being highly customizable is a bit misleading :) Yeah... maybe if you are into painting.

  • Extending functionality of a button in pagebuttonbar

    Hi,
    I'm trying to customize "Create Customer" page in R12. The page has "Apply" button in pagebuttonbar. Based on "Profile Class" value entered in the create page, I need to create some child records like customer relationships. For this, I think I need to create a new row in the VO and set the values. I dont have the RelationshipVO attached to the AM. Moreover, the AM with buttonbarRN is the root AM of the page and cannot be extended. Can anyone please help me out in finding the solution for this scenario.
    Thanks,
    Bharath

    Yup, now it makes more sense. But still I feel that if all the further pages are part of same business logic, then there should be a common AM.
    Anyway, if you look for the root AM extension issue resolution, that will solve this scenario also :)
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for