TextField background

I have a Dreamweaver form that contains a table that contains
4 Spry Text fields. I can't seem to get the backgound color of the
input textfield when the page first comes up to be anything but
yellow. I think it's FFFF99, I've tried changing every background
color in the SpryValidationTextField.css, I've also tried adding
classes on the table and table tags with different colors, I've
tried adding a class to the form with a different background color
but the input field is still pulling this yellow color from
somewhere. Does anyone know how to change this? I saw an old forum
email about a similar issue where someone sent several websites to
search. I searched those..no luck When I looked at the website of
the person who asked the similar question they still had the yellow
as the initial state. So I'm wondering if I'm stuck with that
yellow color? Does anyone know?

On Wed, 25 Jun 2008 21:26:21 +0000 (UTC), "AthroughZ"
<[email protected]> wrote:
>I have a Dreamweaver form that contains a table that
contains 4 Spry Text
>fields. I can't seem to get the backgound color of the
input textfield when
>the page first comes up to be anything but yellow. I
think it's FFFF99, I've
>tried changing every background color in the
SpryValidationTextField.css, I've
>also tried adding classes on the table and table tags
with different colors,
>I've tried adding a class to the form with a different
background color but the
>input field is still pulling this yellow color from
somewhere. Does anyone
>know how to change this? I saw an old forum email about a
similar issue where
>someone sent several websites to search. I searched
those..no luck When I
>looked at the website of the person who asked the similar
question they still
>had the yellow as the initial state. So I'm wondering if
I'm stuck with that
>yellow color? Does anyone know?
Do you have the Google toolbar installed? It'll turn
recognized form
fields that creamy yellow colour.
Win
Win Day, Wild Rose Websites
[email protected]
drink it. feel it. share it.
http://www.mymonavie.com/winday/

Similar Messages

  • How to set textField.Background alpha?

    Is there a way to set the alpha of textField.Background to say 30? I already have the following:
    txtField.background = true;
    txtField.backgroundColor = 0xEE9A00;
    All I need is a way to set the background so that it's not 100% opaque?

    quote:
    Originally posted by:
    kglad
    you have to fake it. add a sprite behind your textfield and
    assign its color/alpha to suit your needs.
    actually i was doing in flex before this.
    i dont know what is sprite and other stuffs.
    my class extends sprite and adds a TextField Child.
    hence, as much i can understand is there is already a sprite.
    can u pls elaborate how to change your suggestion to CODE so
    that i can try.

  • Color values of textfield background

    Hello,
    I need to get the color values of the light blue for a textfield background e.g. Red, Green Blue values - I need to add that color as a custom color. 
    Thanks for any assistance with this.

    Execute this code from the JS console:
    this.getField("FieldNameGoesHere").fillColor
    This will return a color object, which can be RGB, CMYK, Gray gradient or Transparent ("T").

  • Code for changing a TextField BackGround color?

    Hello again!
    I can´t find anywhere the code for changing the background color of a TextField, anyone knows?
    I tried:
         TextField.border.fill.color.value = "255,255,255";      // doesn´t change bg color
         TextField.caption.font.fill.color.value = "255,255,255";     // doesn´t change bg color
         TextField.value.rectangle.fill.color.value = "153,153,153";      // doesn´t change bg color
    Bur none of them works!

    The script works fine..please show here..
    https://workspaces.acrobat.com/?d=EKbH6jmrJ-5RXnVNyxPiPA
    Kind regards,
    Mandy

  • Set all TextField background color

    I searched the help and online for how to accomplish this and
    came up with the following code. It would seem to me that there is
    a more straight forward way but this is the best I could manage.
    Any suggestions on how improve this. Also I could not get the 'for
    in' or 'for each in' to work, the loop would not iterate when
    applied to the page_mc.

    Hi,
    You can set this in the Border palette.
    You might also want to set a white background for the value area (in the Object > Field palette) and zero margins in the Layout palette.
    Hope that helps,
    Niall
    Assure Dynamics

  • Background color of non editable textfield

    Dear all,
    how can I set the background color with a css stylesheet of a textfield that is enabled but non editable "textfield.setEditable(false);"?
    I can not find an example in the caspian.css stylesheet file.
    Regards Tim

    Use the -fx-background-color to change the background color of a TextField.
    Whether the textfield is editable or not, makes no difference as to how this is done.
    If you want the textfield background to change only when it is not editable, then you can use the :readonly css pseudoclass on the field as bouye suggests.
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.control.*;
    import javafx.scene.layout.VBox;
    import javafx.stage.Stage;
    public class TestCssStyles extends Application {
      public static void main(String[] args) throws Exception { launch(); }
      @Override public void start(final Stage stage) throws Exception {
        VBox root = new VBox();
        ToggleButton button = new ToggleButton("Toggle Editable");
        final TextField textField = new TextField("Frobozz");
        textField.getStyleClass().add("customtextfield");
        textField.editableProperty().bind(button.selectedProperty());
        root.getChildren().addAll(textField, button);
        Scene scene = new Scene(root);
        scene.getStylesheets().add(getClass().getResource("styletest.css").toExternalForm());
        stage.setScene(scene);
        stage.show();
    /** styletest.css place in same dir as TestCssStyles.java and ensure build system copies it to the app compile output path */
    .root {
      -fx-padding: 10;
      -fx-spacing: 5;
      -fx-background-color: cornsilk; 
    .customtextfield:readonly {
      -fx-background-color: coral;
    }Edited by: jsmith on Aug 6, 2012 4:14 PM
    Updated to demo use of a :readonly pseudoclass as per bouye's suggestion.

  • Changing font and background color for all components

    Hi,
    This is my first time writing a GUI, and I'm pretty new to Swing and Java. I just recently switched from C++, and so far Java seems to be doing a nice job =)
    Currently I have a gazilion components (textfields, labels, panels) and I'm wondering if there is a way to change their background/foreground colours without adding in setBackground/setForeground for every single component.
    I've done some researching onto using Look and Feel, but there aren't any current ones that suits my needs. And everyone seems to mention that programming your own is pretty complicated.
    My boss wants a slick white text on black background interface, so you can imagine that he's not very impressed with the current default greyish colours =)
    Thank you for any help!
    Cindy

    Hi Cindy,
    I'm not sure how effective a solution this will be, but you could try:UIManager.put("TextField.background", Color.BLACK); // Default text field background becomes blackThere are many more defaults you'd have to change and could probably achieve it more reliably and simply by creating or editing the properties file that controls the way the look and feel (even if it's the default) is implemented. Take a look at:
    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/UIManager.htmlHope this is helpful
    Chris.

  • Changing font and background

    How can i change the font and the background of the Total row in the report?

    Hi Cindy,
    I'm not sure how effective a solution this will be, but you could try:UIManager.put("TextField.background", Color.BLACK); // Default text field background becomes blackThere are many more defaults you'd have to change and could probably achieve it more reliably and simply by creating or editing the properties file that controls the way the look and feel (even if it's the default) is implemented. Take a look at:
    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/UIManager.htmlHope this is helpful
    Chris.

  • Removing background from text?

    Hi All. I am a very new user to Flash and know my question is
    probably extremely basic but I can't figure out what I'm doing
    wrong.
    I am trying to place fading text on top of an image and when
    I create the animation, it places it on a white (specified)
    background. The animation I have created is on its own layer. So my
    question would be, how do I remove the background from my text? I
    would like a transparent background so my text fades in right on
    top of my image.
    Right now, the initial image with falling snow starts and
    about 25 frames in, it turns to white and the text fades in...how
    do i get rid of the white so the text fades in and you are still
    able to see the image and the falling snow?
    I am very very new to Flash (3 days in) and although this is
    a ridiculously easy task to perform in photoshop, I cannot grasp
    how to do it in flash cs4. Thank you, in advance, for any help I
    may receive. I'm trying hard to learn this medium...

    Select the textfield on the stage and see if the icon remains
    unselectable... if so, what version of Flash are you using (I'm
    just curious if it's CS4)?
    Another way to remove the textfield background/border is thru
    actionscript. The textfield must have an instance name to be able
    to do this. Let's say you name it tFeld. In a timeline layer for
    actions, select the first frame of the actions layer where the
    textfield appears on the timeline below it (I only assume it's on a
    layer below somewhere) anmd type the following in the actionscript
    editor window:
    tField.background = false;
    tField.border = false;
    If none of the above works, then I have a feeling I'm
    misinterpretting the scenario. I'm assuming the textfield includes
    its own background at that there isn't some other background
    involved that you area talking about.

  • Flash CS5 How does one change background color in TextArea Component

    I'm trying to change the background color of a TextArea Component.  Does anyone know how to do this?
    function processXML(e:Event):void {
      var strTextBox:String;
      myText.visible=true;
      myText.setStyle("contentBackgroundColor", 0x000000);  //Does not work..nor does   myText.setStyle("backgroundColor",0x000000);
      myXML = new XML(e.target.data);
      strTextBox = "<a href='" + myXML.Branch[0].linkURL + "'> More Info...</a>";
      myText.htmlText=strTextBox;

    for that one you have use styles:
    var newFormat:TextFormat = new TextFormat;
       newFormat.bold = true;
       newFormat.size = 18;
       newFormat.color = 0xFFFFFF;  //I'm wanting white font on black background.
       //apply the format:
    myText.setStyle("textFormat",newFormat);
       myText.visible=true;
      myText.textField.background=true;
      myText.textField.backgroundColor=0x000000;

  • UITextField image background like the one in UISearchBar?

    Is it possible to use the oval background that is used for the TextField in a UISearchBar?
    Perhaps something like a borderStyle? I've tried the UITextBorderStyleRoundedRect but it isn't the same.
    Here's a link: http://img513.imageshack.us/my.php?image=searchuy0.png
    Is there any other way of using this image than just including it with my application and doing:
    textField.background = [UIImage imageNamed: SearchBarBackgroundImage];
    Thanks
    Note: I don't need the magnifying glass or cancel button or anything else. I just want the white oval background.
    Message was edited by: applehund

    But I don't want the magnifying glass image or the toolbar behind it

  • Error Message When Loading FLV

    I'm getting this error message when I run this movie -
    "Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095:
    flash.net.NetStream was unable to invoke callback onMetaData.
    error=ReferenceError: Error #1069: Property onMetaData not found on
    flash.net.NetStream and there is no default value.at
    Slide_GB_05_fla::MainTimeline/frame1()".
    My code to load the five FLV's is -
    var nc1:NetConnection = new NetConnection();
    nc1.connect(null);
    var ns1:NetStream = new NetStream(nc1);
    theVideo1.attachNetStream(ns1);
    ns1.play("Safety.flv");
    var nc5:NetConnection = new NetConnection();
    nc5.connect(null);
    var ns5:NetStream = new NetStream(nc5);
    theVideo5.attachNetStream(ns5);
    ns5.play("Dutyfree_3.flv");
    var nc3:NetConnection = new NetConnection();
    nc3.connect(null);
    var ns3:NetStream = new NetStream(nc3);
    theVideo3.attachNetStream(ns3);
    ns3.play("Hawaii.flv");
    var nc4:NetConnection = new NetConnection();
    nc4.connect(null);
    var ns4:NetStream = new NetStream(nc4);
    theVideo4.attachNetStream(ns4);
    ns4.play("CatWoman_1.flv");
    //ns4.seek(10);
    //ns4.pause();
    var nc2:NetConnection = new NetConnection();
    nc2.connect(null);
    var ns2:NetStream = new NetStream(nc2);
    theVideo2.attachNetStream(ns2);
    ns2.play("CITA_1.flv");
    ta1.textField.background = true;
    ta1.textField.backgroundColor = 0xC9C1B8;
    //ta1.htmlText = "<b>Kinds of PAVES
    entertainment:</b><ul><li>Audio
    channels</li><li><b>Video
    programs</b></li><li>Airshow</li></ul><br><b>Examples
    of video
    programs:</b><ul><li>Safety</li><li>Comfort
    in
    Flight</li><li>Destinations</li><li>Movies</li><li>Advertisements</li></ul>";
    var lessonInfoXML:XML;
    var lessonInfo:URLLoader = new URLLoader();
    var smartGraphicFile:String;
    lessonInfo.addEventListener(Event.COMPLETE,
    onCompleteLessonInfo);
    lessonInfo.load(new URLRequest("Slide_Information.xml"));
    function onCompleteLessonInfo(evt:Event) {
    lessonInfoXML = new XML(lessonInfo.data);
    smartGraphicFile = lessonInfoXML.slide5.narration;
    ta1.htmlText = smartGraphicFile;
    The FLV's load, and I can dismiss the error messages. Any
    idea what I'm doing wrong?

    BALTB  seems to be a structure , can you explain how you r trying to loadd
    The error may be the Record type B is invalid ,  the last field is record type , chk whether B exists or not

  • Something trivial but I can't work it out :/

    Okay basically, I want my buttonOval to draw an oval for me. Here is my code:
    import java.awt.*;                                                  //Import all the classes within the abstract windows toolkit
    import java.applet.*;                                                  /Import applet class
    import java.awt.event.*;
    import java.awt.Graphics.*;
    public class Shapes extends Applet implements ActionListener
         Button buttonOval, buttonRectangle;                              //Declaration of button variables
         Font fontVerdana;                                        //Declare fonts
         TextField textx, texty, textwidth, textheight, areatext;          //Declare text fields
         Label labelx, labely, labelh, labelw;                              //Declare label fields
         int x;                                                       //Declare variable x asinteger v
         int y;
         int height;
         int width;
         int area;
         double pi = 3.14;
         public void init()
              setSize(800,500);                                                       //Size of the applet viewer
              setBackground(Color.yellow);
              fontVerdana = new Font("Verdana", Font.BOLD,10);                //Set the font
              labelx = new Label("Enter in the x co-ordinate here:");          //Declares a new label
              labelx.setBackground(Color.yellow);                                   //Background colour becomes yellow
              labelx.setFont(fontVerdana);                                        //Label prompt uses the Verdana font
              add(labelx);                                                            //Add prompt to the applet
              textx = new TextField(1);                                             //Declares a textfield for input
              add(textx);                                                                 //Adds the textfield to the applet
              textx.setForeground(Color.white);                                   //Textfield font becomes white
              textx.setBackground(Color.black);                                   //Textfield background colour becomes black
              textx.addActionListener(this);
              labely = new Label("Enter in the y co-ordinate here:");
              labely.setBackground(Color.yellow);
              labely.setFont(fontVerdana);
              add(labely);
              texty = new TextField(1);
              add(texty);
              texty.setForeground(Color.white);
              texty.setBackground(Color.black);
              texty.addActionListener(this);
              labelw = new Label("Enter in the width here:");
              labelw.setBackground(Color.yellow);
              labelw.setFont(fontVerdana);
              add(labelw);
              textwidth = new TextField(1);
              add(textwidth);
              textwidth.setForeground(Color.white);
              textwidth.setBackground(Color.black);
              textwidth.addActionListener(this);
              labelh = new Label("Enter in height here:");
              labelh.setBackground(Color.yellow);
              labelh.setFont(fontVerdana);
              add(labelh);
              textheight = new TextField(1);
              add(textheight);
              textheight.setForeground(Color.white);
              textheight.setBackground(Color.black);
              textheight.addActionListener(this);
              areatext = new TextField(20);
              areatext.setEditable(false);
              add(areatext);
              areatext.addActionListener(this);
              buttonOval = new Button("Draw Oval");
              buttonOval.setForeground(Color.white);
              buttonOval.setBackground(Color.black);
              add(buttonOval);
              buttonRectangle = new Button("Draw Rectangle");
              buttonRectangle.setForeground(Color.white);
              buttonRectangle.setBackground(Color.black);
              add(buttonRectangle);
              buttonOval.addActionListener(this);
              buttonRectangle.addActionListener(this);
         public void paint(Graphics g)
              g.drawOval(x, y, width, height);
              g.drawRect(x, y, width, height);
         public void actionPerformed(ActionEvent ev)
              if (ev.getSource() == buttonRectangle)
                   x = Integer.parseInt(textx.getText());
                   y = Integer.parseInt(texty.getText());
                   width = Integer.parseInt(textwidth.getText());
                   height = Integer.parseInt(textheight.getText());
                   area = width * height;
                   areatext.setText("The area is = " + area + "cm�");
                   areatext.setEditable(false);
              else if (ev.getSource() == buttonOval)
                   x = Integer.parseInt(textx.getText());
                   y = Integer.parseInt(texty.getText());
                   width = Integer.parseInt(textwidth.getText());
                   height = Integer.parseInt(textheight.getText());
                   area = width * height;
                   areatext.setText("The area is = " + area + "cm�");
                   areatext.setEditable(false);
    I've used the paint method to set out the oval attributes 'g.drawOval(x, y, width, height' and I've declared all the integers and got the integer results from the textfields in which the integers are entered 'x = Integer.parseInt(textx.getText());'
    but when I click the buttonOval I want it to draw the oval which is defined in the paint method. Any ideas how I can do this? As plus, it would be great if someone could tell me how to implement the area of an oval too. :D
    I do apologise if this sort of thread has been posted before! Thank you for any help I appreciate. :)
    Have a good day,
    Jay

    I've ried to compile the following but no luck...
    Boolean ovalYes, rectYes;
    then in the paint method...
    public void paint(Graphics graf)
              if buttonOval = ovalYes
                   graf.drawOval(x,y,width,height);
              else if buttonRectangle = ovalYes
                   graf.drawRect(x,y,width,height);
    then in the actionPerformed method...
    public void actionPerformed(ActionEvent ev)
              if (ev.getSource() == buttonRectangle)
                   x = Integer.parseInt(textx.getText());
                   y = Integer.parseInt(texty.getText());
                   width = Integer.parseInt(textwidth.getText());
                   height = Integer.parseInt(textheight.getText());
                   repaint(rectYes);
                   area = width * height;
                   areatext.setText("The area is = " + area + "cm�");
                   areatext.setEditable(false);
              else if (ev.getSource() == buttonOval)
                   x = Integer.parseInt(textx.getText());
                   y = Integer.parseInt(texty.getText());
                   width = Integer.parseInt(textwidth.getText());
                   height = Integer.parseInt(textheight.getText());
                   repaint(ovalYes);
                   area = width * height;
                   areatext.setText("The area is = " + area + "cm�");
                   areatext.setEditable(false);
    It doesn't work. :s

  • Help needed, Createing Dynamic User input

    Hello,
    I am attempting to create some dynamic user input by "predicting" what the user requires in a text box.
    For example if the user enters "Smi" I have a select list pop up which gives the user all options that begin with "Smi".
    I am able to achieve the popups but the interface is quite jerky and not terribly responsive I am trying to solve this by using a thread which starts and stops when new input is received but it is still not quite right.
    The program uses a Sorted TreeSet to hold the data (I thought this would give me a quick search time) and a simple interface at this stage.
    Any help would be fantastic
    Thanks in advance :P
    import java.io.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.text.*;
    import java.util.*;
       /** This program represents part of a larger user interface for allowing the
       user to select data from a file or database.
       <p>
       When the program starts up, it will read in data from a given file, and hold
       it in some type of container allowing rapid access.
       <p>
       The user may then type in the first few letters of the surname of a person,
       and this program should immediately present in a popup dialog the names which
       match.  The user will be able to click on one of the names in the popup and
       that will cause all data about that person to be displayed in the JTextArea
       at the bottom of the window.
       <p>
       This program requires the FormLayout.class, FormLayout$Placement.class, and
       FormLayout$Constraint.class files in the same directory
       (folder) or in its classpath.  These is provided separately.
    class PartMatch extends JFrame implements Runnable
                        /** Close down the program. */
       JButton quitbtn;
                        /** Field for the surname. */
       JTextField namefld;
                        /** Full details of the person(s). */
       JTextArea  results;
                        /** Popup dialog to display the names and addresses which
                        match the leading characters given in namefld. */
       Chooser matches;
                      /** Default background color for a window. */
       final static  Color            defBackground = new Color(0xD0C0C0);
                      /** Default foreground color for a window. */
       final static  Color            defForeground = new Color(0x000000);
                      /** Default background color for a field */
       final static  Color            fldBackground = new Color(0xFFFFFF);
                      /** Default background color for a button */
       final static  Color            btnBackground = new Color(0xF0E0E0);
       final static  Color            dkBackground = new Color(0xB0A0A0);
                      /** Larger font */
       final static  Font bold = new Font("Helvetica", Font.BOLD, 30);
       TreeSet members;
       String input;
       String[] found;
       public static void main(String arg[])
          UIManager.put("TextField.background",fldBackground);
          UIManager.put("TextField.foreground",defForeground);
          UIManager.put("TextField.selectionBackground",btnBackground);
          UIManager.put("TextArea.background",fldBackground);
          UIManager.put("TextArea.foreground",defForeground);
          UIManager.put("TextArea.selectionBackground",btnBackground);
          UIManager.put("Panel.background",defBackground);
          UIManager.put("Label.background",defBackground);
          UIManager.put("Label.foreground",defForeground);
          UIManager.put("Button.background",btnBackground);
          UIManager.put("Button.foreground",defForeground);
          UIManager.put("CheckBox.background",defBackground);
          UIManager.put("ScrollBar.background",defBackground);
          UIManager.put("ScrollBar.thumb",btnBackground);
          UIManager.put("ComboBox.background",btnBackground);
          UIManager.put("ComboBox.selectionBackground",dkBackground);
          PartMatch trial = new PartMatch(arg);
       public PartMatch( String [] arg )
          super("Part Match");
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          Container cpane = getContentPane();
          FormLayout form = new FormLayout(cpane);
          JLabel lab1 = new JLabel("Fetch details") ;
          lab1.setFont( bold );
          form.setTopAnchor( lab1, 4 );
          form.setLeftAnchor( lab1, 4 );
          JLabel lab2 = new JLabel("Surname: ") ;
          form.setTopRelative( lab2, lab1, 4 );
          form.setLeftAlign( lab2, lab1 );
          namefld = new JTextField( 30 );
          form.setBottomAlign( namefld, lab2 );
          form.setLeftRelative( namefld, lab2, 4 );
          namefld.addCaretListener( new CaretListener()
             public void caretUpdate(CaretEvent e)
                 showMatches();
          quitbtn = new JButton( "Quit" );
          quitbtn.addActionListener( new ActionListener()
             public void actionPerformed(ActionEvent e)
                quitProcessing();
          form.setBottomAlign( quitbtn, namefld );
          form.setLeftRelative( quitbtn, namefld, 15 );
          results = new JTextArea( 10,50 );
          results.setEditable(false);
          JScrollPane jsp = new JScrollPane( results,
                                     JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
          form.setTopRelative( jsp, lab2, 6 );
          form.setLeftAlign( jsp, lab2 );
          form.setBottomAnchor( jsp, 5 );
          form.setRightAnchor( jsp, 5 );
          form.setRightAnchor( quitbtn, 5 );
          matches = new Chooser( this );
          //matches.setUndecorated(true);
          pack();
          setVisible(true);
          namefld.requestFocus();
          if (arg.length > 0) init(arg[0]);
          else init("triathlon.txt"); //<<<<<<<<<<<<<<<< Place the default filename here
          /** Called once only, at the end of the constructor, to read the data
            * from the membership file.
       public void init( String fname )
          members = new TreeSet();
           try {
               FileReader fr = new FileReader(new File (fname));
               Scanner scan = new Scanner(fr);
               trimember cmem;
               String cLine, eTag, memberNo, first, last, gender, yob, tel ,addr,
                       club;
               while(scan.hasNextLine())
                   cLine = scan.nextLine();
                   Scanner scan2 = new Scanner(cLine);
                   scan2.useDelimiter(";");
                   eTag = scan2.next().trim();
                   memberNo = scan2.next().trim();
                   first = scan2.next().trim();
                   last = scan2.next().trim();
                   gender = scan2.next().trim();
                   yob = scan2.next().trim();
                   tel = scan2.next().trim();
                   addr = scan2.next().trim();
                   club = scan2.next().trim();
                   cmem = new trimember(eTag, memberNo, first, last, gender, yob,
                           tel, addr, club);
                   members.add(cmem);
           catch (FileNotFoundException ex)
               results.append("Sorry can't find the input file\n");
               results.append("Please check file name and location and try again");
               ex.printStackTrace();
          /** Called every time there is a change in the contents of the text field
            * namefld.  It will first clear the text area.  It then needs to search
            * through the container of data to find all records where the surname
            * starts with the characters that have been typed.  The names and
            * addresses need to be set up as strings and placed in
            * an array of Strings.  This can be placed in the "matches" window and
            * displayed for the user, inviting one to be selected.
            * <p>
            * The performance of this is very important.  If necessary, it may be
            * necessary to run as a separate thread so that the user interface is
            * not delayed.  It is essential that the user be able to type letters at a
            * reasonable speed and not have the keystroke processing held up by
            * previous text.
       public void showMatches( )
           run();
                // First clear the text area
          //results.setText("");
                // Determine the leading characters of the surname that is wanted
                input = namefld.getText();
                // Locate the data for this name, and display each matching item
                //  in the JTextArea ...
                // Example of how to set the data in the popup dialog
          matches.list.setListData(found);
          matches.pack();   // resize the popup
                // set the location of the popup if it is not currently visible
          if ( ! matches.isVisible())
             Dimension sz = matches.getSize();
             Point mouse = getMousePosition();
             Point framepos = getLocation();
             int x=0, y=0;
             if (mouse == null)
                Point pt = results.getLocation();
                x = pt.x + 20 + framepos.x;
                y = pt.y + 20 + framepos.y;
             else
                x = mouse.x - 2 + framepos.x;
                y = mouse.y - 2 + framepos.y;
             matches.setLocation(x,y);
          matches.setVisible(true);
          namefld.requestFocus();
          /** Perform any final processing before closing down.
       public void quitProcessing( )
          // Any closing work.  Then
          System.exit(0);
        public void run()
            ArrayList<String> foundit = new ArrayList<String>();
            System.out.println(input);
            if(input != null)
            Iterator it = members.iterator();
            while(it.hasNext())
               trimember test = (trimember) it.next();
               if (test.last.startsWith(input))
                   foundit.add(test.last +", "+ test.first);
            found = new String[foundit.size()];
            for(int i=0; i<foundit.size();i++)
                found[i] = foundit.get(i);
         /** A window for displaying names and addresses from the data set which
          match the leading characters in namefld.
          <p>
          This will automatically pop down if the user moves the mouse out of the
          window.
          <p>
          It needs code added to it to respond to the user clicking on an item in
          the displayed list. */
       class Chooser extends JWindow
                /** To display a set of names and addresses that match the leading
                characters of the namefld text field. */
          public JList list = new JList();
          Chooser( JFrame parent )
             super( parent );
             Container cpane = getContentPane();
             cpane.addMouseListener( new MouseAdapter()
                public void mouseExited(MouseEvent e)
                   Chooser.this.setVisible(false);
             cpane.add("Center",list);
             list.addListSelectionListener( new ListSelectionListener()
                public void valueChanged(ListSelectionEvent e)
                   Chooser.this.setVisible(false);
                   System.out.println("ValueChanged");
                   // First clear the text area
                   results.setText("");
                   String in = (String) list.getSelectedValue();
                   System.out.println("Selected Value was : "+in);
                   String[] inlf = in.split(", ");
                   System.out.println("inlf[0]:"+inlf[0]+" inlf[1]:"+inlf[1]);
                   results.append("Surname \tFirst \teTag \tMemberNo \tSex \tYOB " +
                           "\tTel \tAddress \t\t\tClub\n");
                   Iterator it = members.iterator();
                   while(it.hasNext())
                       trimember test = (trimember) it.next();
                       if (test.last.equals(inlf[0])&&test.first.equals(inlf[1]))
                           results.append(test.toString()+"\n");
                   namefld.requestFocus();
          public class trimember implements Comparable
           String eTag;
           public String memberNo;
           public String first;
           public String last;
           String gender;
           String yob;
           String tel;
           String addr;
           String club;
           public trimember(String eT, String me, String fi, String la,
                   String ge, String yo, String te, String ad, String cl)
               eTag = eT;
               memberNo = me;
               first = fi;
               last = la;
               gender = ge;
               yob = yo;
               tel = te;
               addr = ad;
               club = cl;         
           //To String method to output string of details
           public String toString()
               return last + "\t" + first + "\t" + eTag + "\t" +
                       memberNo + "\t" + gender + "\t" + yob + "\t"+ tel + "\t" +
                       addr + "\t" + club;
           //Compare and sort on Last name
           public int compareTo(Object o)
               trimember com = (trimember) o;
               int lastCmp = last.compareTo(com.last);
               int firstCmp = first.compareTo(com.first);
               int memCmp = memberNo.compareTo(com.memberNo);
               if (lastCmp == 0 && firstCmp !=0)return firstCmp;
               else if (lastCmp==0&&firstCmp==0)return memCmp;
               else return lastCmp;
    }

    Please don't cross-post. It is considered very rude to do that here:
    http://forum.java.sun.com/thread.jspa?messageID=9953193

  • Help needed, Providing Dynamic User input

    Hello,
    I am attempting to create some dynamic user input by "predicting" what the user requires in a text box.
    For example if the user enters "Smi" I have a select list pop up which gives the user all options that begin with "Smi".
    I am able to achieve the popups but the interface is quite jerky and not terribly responsive I am trying to solve this by using a thread which starts and stops when new input is received but it is still not quite right.
    The program uses a Sorted TreeSet to hold the data (I thought this would give me a quick search time) and a simple interface at this stage.
    Any help would be fantastic
    Thanks in advance :P
    import java.io.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.text.*;
    import java.util.*;
       /** This program represents part of a larger user interface for allowing the
       user to select data from a file or database.
       <p>
       When the program starts up, it will read in data from a given file, and hold
       it in some type of container allowing rapid access.
       <p>
       The user may then type in the first few letters of the surname of a person,
       and this program should immediately present in a popup dialog the names which
       match.  The user will be able to click on one of the names in the popup and
       that will cause all data about that person to be displayed in the JTextArea
       at the bottom of the window.
       <p>
       This program requires the FormLayout.class, FormLayout$Placement.class, and
       FormLayout$Constraint.class files in the same directory
       (folder) or in its classpath.  These is provided separately.
    class PartMatch extends JFrame implements Runnable
                        /** Close down the program. */
       JButton quitbtn;
                        /** Field for the surname. */
       JTextField namefld;
                        /** Full details of the person(s). */
       JTextArea  results;
                        /** Popup dialog to display the names and addresses which
                        match the leading characters given in namefld. */
       Chooser matches;
                      /** Default background color for a window. */
       final static  Color            defBackground = new Color(0xD0C0C0);
                      /** Default foreground color for a window. */
       final static  Color            defForeground = new Color(0x000000);
                      /** Default background color for a field */
       final static  Color            fldBackground = new Color(0xFFFFFF);
                      /** Default background color for a button */
       final static  Color            btnBackground = new Color(0xF0E0E0);
       final static  Color            dkBackground = new Color(0xB0A0A0);
                      /** Larger font */
       final static  Font bold = new Font("Helvetica", Font.BOLD, 30);
       TreeSet members;
       String input;
       String[] found;
       public static void main(String arg[])
          UIManager.put("TextField.background",fldBackground);
          UIManager.put("TextField.foreground",defForeground);
          UIManager.put("TextField.selectionBackground",btnBackground);
          UIManager.put("TextArea.background",fldBackground);
          UIManager.put("TextArea.foreground",defForeground);
          UIManager.put("TextArea.selectionBackground",btnBackground);
          UIManager.put("Panel.background",defBackground);
          UIManager.put("Label.background",defBackground);
          UIManager.put("Label.foreground",defForeground);
          UIManager.put("Button.background",btnBackground);
          UIManager.put("Button.foreground",defForeground);
          UIManager.put("CheckBox.background",defBackground);
          UIManager.put("ScrollBar.background",defBackground);
          UIManager.put("ScrollBar.thumb",btnBackground);
          UIManager.put("ComboBox.background",btnBackground);
          UIManager.put("ComboBox.selectionBackground",dkBackground);
          PartMatch trial = new PartMatch(arg);
       public PartMatch( String [] arg )
          super("Part Match");
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          Container cpane = getContentPane();
          FormLayout form = new FormLayout(cpane);
          JLabel lab1 = new JLabel("Fetch details") ;
          lab1.setFont( bold );
          form.setTopAnchor( lab1, 4 );
          form.setLeftAnchor( lab1, 4 );
          JLabel lab2 = new JLabel("Surname: ") ;
          form.setTopRelative( lab2, lab1, 4 );
          form.setLeftAlign( lab2, lab1 );
          namefld = new JTextField( 30 );
          form.setBottomAlign( namefld, lab2 );
          form.setLeftRelative( namefld, lab2, 4 );
          namefld.addCaretListener( new CaretListener()
             public void caretUpdate(CaretEvent e)
                 showMatches();
          quitbtn = new JButton( "Quit" );
          quitbtn.addActionListener( new ActionListener()
             public void actionPerformed(ActionEvent e)
                quitProcessing();
          form.setBottomAlign( quitbtn, namefld );
          form.setLeftRelative( quitbtn, namefld, 15 );
          results = new JTextArea( 10,50 );
          results.setEditable(false);
          JScrollPane jsp = new JScrollPane( results,
                                     JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
          form.setTopRelative( jsp, lab2, 6 );
          form.setLeftAlign( jsp, lab2 );
          form.setBottomAnchor( jsp, 5 );
          form.setRightAnchor( jsp, 5 );
          form.setRightAnchor( quitbtn, 5 );
          matches = new Chooser( this );
          //matches.setUndecorated(true);
          pack();
          setVisible(true);
          namefld.requestFocus();
          if (arg.length > 0) init(arg[0]);
          else init("triathlon.txt"); //<<<<<<<<<<<<<<<< Place the default filename here
          /** Called once only, at the end of the constructor, to read the data
            * from the membership file.
       public void init( String fname )
          members = new TreeSet();
           try {
               FileReader fr = new FileReader(new File (fname));
               Scanner scan = new Scanner(fr);
               trimember cmem;
               String cLine, eTag, memberNo, first, last, gender, yob, tel ,addr,
                       club;
               while(scan.hasNextLine())
                   cLine = scan.nextLine();
                   Scanner scan2 = new Scanner(cLine);
                   scan2.useDelimiter(";");
                   eTag = scan2.next().trim();
                   memberNo = scan2.next().trim();
                   first = scan2.next().trim();
                   last = scan2.next().trim();
                   gender = scan2.next().trim();
                   yob = scan2.next().trim();
                   tel = scan2.next().trim();
                   addr = scan2.next().trim();
                   club = scan2.next().trim();
                   cmem = new trimember(eTag, memberNo, first, last, gender, yob,
                           tel, addr, club);
                   members.add(cmem);
           catch (FileNotFoundException ex)
               results.append("Sorry can't find the input file\n");
               results.append("Please check file name and location and try again");
               ex.printStackTrace();
          /** Called every time there is a change in the contents of the text field
            * namefld.  It will first clear the text area.  It then needs to search
            * through the container of data to find all records where the surname
            * starts with the characters that have been typed.  The names and
            * addresses need to be set up as strings and placed in
            * an array of Strings.  This can be placed in the "matches" window and
            * displayed for the user, inviting one to be selected.
            * <p>
            * The performance of this is very important.  If necessary, it may be
            * necessary to run as a separate thread so that the user interface is
            * not delayed.  It is essential that the user be able to type letters at a
            * reasonable speed and not have the keystroke processing held up by
            * previous text.
       public void showMatches( )
           run();
                // First clear the text area
          //results.setText("");
                // Determine the leading characters of the surname that is wanted
                input = namefld.getText();
                // Locate the data for this name, and display each matching item
                //  in the JTextArea ...
                // Example of how to set the data in the popup dialog
          matches.list.setListData(found);
          matches.pack();   // resize the popup
                // set the location of the popup if it is not currently visible
          if ( ! matches.isVisible())
             Dimension sz = matches.getSize();
             Point mouse = getMousePosition();
             Point framepos = getLocation();
             int x=0, y=0;
             if (mouse == null)
                Point pt = results.getLocation();
                x = pt.x + 20 + framepos.x;
                y = pt.y + 20 + framepos.y;
             else
                x = mouse.x - 2 + framepos.x;
                y = mouse.y - 2 + framepos.y;
             matches.setLocation(x,y);
          matches.setVisible(true);
          namefld.requestFocus();
          /** Perform any final processing before closing down.
       public void quitProcessing( )
          // Any closing work.  Then
          System.exit(0);
        public void run()
            ArrayList<String> foundit = new ArrayList<String>();
            System.out.println(input);
            if(input != null)
            Iterator it = members.iterator();
            while(it.hasNext())
               trimember test = (trimember) it.next();
               if (test.last.startsWith(input))
                   foundit.add(test.last +", "+ test.first);
            found = new String[foundit.size()];
            for(int i=0; i<foundit.size();i++)
                found[i] = foundit.get(i);
         /** A window for displaying names and addresses from the data set which
          match the leading characters in namefld.
          <p>
          This will automatically pop down if the user moves the mouse out of the
          window.
          <p>
          It needs code added to it to respond to the user clicking on an item in
          the displayed list. */
       class Chooser extends JWindow
                /** To display a set of names and addresses that match the leading
                characters of the namefld text field. */
          public JList list = new JList();
          Chooser( JFrame parent )
             super( parent );
             Container cpane = getContentPane();
             cpane.addMouseListener( new MouseAdapter()
                public void mouseExited(MouseEvent e)
                   Chooser.this.setVisible(false);
             cpane.add("Center",list);
             list.addListSelectionListener( new ListSelectionListener()
                public void valueChanged(ListSelectionEvent e)
                   Chooser.this.setVisible(false);
                   System.out.println("ValueChanged");
                   // First clear the text area
                   results.setText("");
                   String in = (String) list.getSelectedValue();
                   System.out.println("Selected Value was : "+in);
                   String[] inlf = in.split(", ");
                   System.out.println("inlf[0]:"+inlf[0]+" inlf[1]:"+inlf[1]);
                   results.append("Surname \tFirst \teTag \tMemberNo \tSex \tYOB " +
                           "\tTel \tAddress \t\t\tClub\n");
                   Iterator it = members.iterator();
                   while(it.hasNext())
                       trimember test = (trimember) it.next();
                       if (test.last.equals(inlf[0])&&test.first.equals(inlf[1]))
                           results.append(test.toString()+"\n");
                   namefld.requestFocus();
          public class trimember implements Comparable
           String eTag;
           public String memberNo;
           public String first;
           public String last;
           String gender;
           String yob;
           String tel;
           String addr;
           String club;
           public trimember(String eT, String me, String fi, String la,
                   String ge, String yo, String te, String ad, String cl)
               eTag = eT;
               memberNo = me;
               first = fi;
               last = la;
               gender = ge;
               yob = yo;
               tel = te;
               addr = ad;
               club = cl;         
           //To String method to output string of details
           public String toString()
               return last + "\t" + first + "\t" + eTag + "\t" +
                       memberNo + "\t" + gender + "\t" + yob + "\t"+ tel + "\t" +
                       addr + "\t" + club;
           //Compare and sort on Last name
           public int compareTo(Object o)
               trimember com = (trimember) o;
               int lastCmp = last.compareTo(com.last);
               int firstCmp = first.compareTo(com.first);
               int memCmp = memberNo.compareTo(com.memberNo);
               if (lastCmp == 0 && firstCmp !=0)return firstCmp;
               else if (lastCmp==0&&firstCmp==0)return memCmp;
               else return lastCmp;
    }Edited by: Roger on Nov 3, 2007 11:50 AM

    Please don't cross-post. It is considered very rude to do that here:
    http://forum.java.sun.com/thread.jspa?threadID=5233033&messageID=9953169#9953169

Maybe you are looking for