Textfield and eventlisteners

Hi guys, i fee im plauging this forum sometimes, this code lets a user input text and click a button which outputs it to a textfieldand also adds a number to another textfield. Another button removes this text and also subtracts the same number. It all works fine when there is text in the input field but when it is empty and you click the button that adds the text it still adds to the number.
[AS]
var textAdd01 : Number;
          textAdd01 = 3;
LBtextMenu.LBtxtSubmit.addEventListener(MouseEvent.MOUSE_UP, LBtypedChar);
function LBtypedChar(evt:MouseEvent):void
LBTxt.LBOutput.text = LBtextMenu.LBInput.text;
LBtextHotspot.gotoAndStop(2);
trace (LBTxt.LBOutput.text.length)
///----------------------Add Price---------------------------------------
LBtextMenu.LBtxtSubmit.addEventListener(MouseEvent.MOUSE_UP, LBtxtAddPrice);
function LBtxtAddPrice(evt:MouseEvent):void
priceOutput.text = String(textAdd01 + Number(priceOutput.text));
if (LBTxt.LBOutput.text.length >0){
          LBtextMenu.LBtxtSubmit.removeEventListener(MouseEvent.MOUSE_UP, LBtxtAddPrice);
          LBtextMenu.LBtxtRemove.addEventListener(MouseEvent.MOUSE_UP, LBtxtRemovePrice);
LBtextMenu.LBtxtRemove.addEventListener(MouseEvent.MOUSE_UP,LBtxtRemoveTxt);
function LBtxtRemoveTxt(e:MouseEvent)
  LBTxt.LBOutput.text = "";
          LBtextHotspot.gotoAndStop(1);
          LBtextMenu.LBtxtSubmit.addEventListener(MouseEvent.MOUSE_UP, LBtxtAddPrice);
          trace (LBTxt.LBOutput.text.length)
///----------------------Remove Price---------------------------------------
LBtextMenu.LBtxtRemove.addEventListener(MouseEvent.MOUSE_UP, LBtxtRemovePrice);
function LBtxtRemovePrice(evt:MouseEvent):void
priceOutput.text = String(Number(priceOutput.text) - textAdd01);
if (LBTxt.LBOutput.text.length ==0){
          LBtextMenu.LBtxtRemove.removeEventListener(MouseEvent.MOUSE_UP, LBtxtRemovePrice);
[/AS]
Thanks for any help in advance.

Thanks for reply Ned, yes everything is tracing as it should.   "LBtextMenu.LBtxtSubmit"  is the add button which takes the text from the inputfield "LBtextMenu.LBInput.text" outputs to the output field "LBTxt.LBOutput.text" and also adds the number "textAdd01" to "priceOutput.text".
"LBtextMenu.LBtxtRemove" is the remove button which removes the text from "LBTxt.LBOutput.text" and subtracts "textAdd01" from "priceOutput.text"
Dont know if that has made it clearer?

Similar Messages

  • How do I limit the size of a TextField and do an auto advance of that field

    Attached is a copy of my program. It reads a bar code and enters that bar code into a textfield and 2 text areas. everything is working fine except I want the bar code read to trigger a print to the 2 text areas automatically instead of the user having to hit the enter key. Any suggestions on where I should start researching or any snippets of code that I could use would be appreciated.
    //-------------------Buffalo Offline Scan Program------------
    //This program will allow the Buffalo user to continue scanning cases on pallets
    //when the AS\400 is down. The scans will be sent to a flat file that will be
    //FTPed to the AS\400 when it is back up and update the proper files.
    //Program Author: Susan Riggin
    package javalab;
    import javabook.*;
    import javalab.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.applet.*;
    import java.io.*;
    import java.io.File.*;
    import java.util.*;
    public class BuffOff extends Applet implements ActionListener
    //               Data Members
         //Variables
         private int scanCount = 0;
         private int sessionCount = 0;
         //Labels
         private Label buffaloLabel = new Label();
         private Label scanLabel = new Label();
         private Label cPalletLabel = new Label();
         private Label cCountLabel = new Label();
         private Label tPalletLabel = new Label();
         private Label tCountLabel = new Label();
         private Label rButtonLabel = new Label();
         private Label eButtonLabel = new Label();
         //TextFields
         private TextField scanTextField = new TextField(6);
         //Buttons
         private Button rButton = new Button("Reset");
         private Button eButton = new Button("Exit");
         //Text Areas
         private TextArea cTextArea = new TextArea( 10, 40);
         private TextArea tTextArea = new TextArea(10, 40);
         public void paint(Graphics g){
         Toolkit kit = Toolkit.getDefaultToolkit();
         Image imageA = kit.getImage("d:\\\\javaproj\\javalab\\abbott.gif");
         g.drawImage(imageA, 555, 5, 50, 50, this);
    //               Constructor
    public BuffOff()
         //Attach the GUI objects so they will appear on the screen.
         setLayout (null);
         buffaloLabel.setBounds(203, 5, 200, 27);
         buffaloLabel.setFont(new Font ("dialog",Font.BOLD, 18));
         buffaloLabel.setAlignment(Label.CENTER);
         buffaloLabel.setText("Buffalo OffLine Scan");
         cPalletLabel.setBounds(18, 60, 291, 23);
         cPalletLabel.setFont(new Font ("dialog", Font.BOLD, 14));
         cPalletLabel.setAlignment(Label.CENTER);
         cPalletLabel.setText("Current Pallet");
         cPalletLabel.setBackground(Color.cyan);
         tPalletLabel.setBounds(322, 62, 291, 23);
         tPalletLabel.setFont(new Font ("dialog", Font.BOLD, 14));
         tPalletLabel.setAlignment(Label.CENTER);
         tPalletLabel.setText("Total Pallets");
         tPalletLabel.setBackground(Color.pink);
         rButton.setBounds(129, 485, 56, 23);
         rButton.setBackground(Color.cyan);
         rButton.setLabel("Reset");
         eButton.setBounds(459, 485, 56, 23);
         eButton.setBackground(Color.pink);
         eButton.setLabel("Exit");
         cCountLabel.setBounds(18, 88, 291, 23);
         cCountLabel.setFont(new Font("dialog", Font.BOLD, 12));
         cCountLabel.setAlignment(Label.CENTER);
         cCountLabel.setText("Current Pallet Case Count = " + scanCount);
         cCountLabel.setBackground(Color.lightGray);
         tCountLabel.setBounds(322, 88, 291, 23);
         tCountLabel.setFont(new Font("dialog", Font.BOLD, 12));
         tCountLabel.setAlignment(Label.CENTER);
         tCountLabel.setText("Total Pallet Case Count = " + sessionCount);
         tCountLabel.setBackground(Color.lightGray);
         scanLabel.setBounds(120, 33, 160, 23);
         scanLabel.setFont(new Font("dialog", Font.BOLD, 14));
         scanLabel.setAlignment(Label.CENTER);
         scanLabel.setText(" Current Barcode Scan: ");
         scanTextField.setBounds(300, 34, 58, 23);
         scanTextField.setBackground(Color.white);
         eButtonLabel.setBounds(322, 460, 291, 23);
         eButtonLabel.setAlignment(Label.CENTER);
         eButtonLabel.setBackground(Color.pink);
         eButtonLabel.setText("Press Exit to end Program.");
         rButtonLabel.setBounds(18, 460, 291, 23);
         rButtonLabel.setAlignment(Label.CENTER);
         rButtonLabel.setBackground(Color.cyan);
         rButtonLabel.setText("Press Reset for next pallet scan.");
         cTextArea.setBounds(18, 118, 291, 333);
         cTextArea.setBackground(Color.cyan);
         tTextArea.setBounds(322, 118, 291, 333);
         tTextArea.setBackground(Color.pink);
         //Place the GUI objects on the applet.
         add(buffaloLabel);
         add(scanLabel);
         add(cPalletLabel);
         add(cCountLabel);
         add(tCountLabel);
         add(tPalletLabel);
         add(cCountLabel);
         add(rButtonLabel);
         add(eButtonLabel);
         add(scanTextField);
         add(rButton);
         add(eButton);
         add(cTextArea);
         add(tTextArea);
         //Add applet as an action listener.
         scanTextField.addActionListener(this);
         rButton.addActionListener(this);
         eButton.addActionListener(this);
    //               Methods that make the program work
    //---------method for action performed and action event---------
         public void actionPerformed(ActionEvent e)
         if (e.getSource() == eButton) exit();
         if (e.getSource() == scanTextField) {
              try {     
                   scan();
              catch(IOException f){}
         if (e.getSource() == rButton) reset();
    //-------------method for pressing the exit button---------------
         private void exit()
         System.exit(0);
    //------------method for pressing the reset button---------------
         private void reset()
         scanCount = 0;
         scanTextField.setText("");
         cTextArea.setText("");
         cCountLabel.setText("Current Pallet Case Count = " + scanCount);
         scanTextField.requestFocus();
    //------------method for scanning barcode------------------------
         private void scan() throws FileNotFoundException
         String scanText = scanTextField.getText();
         if (scanText.equals("999999")) reset();
         else{
         String cTime, cDate;
         File scan = new File("d:\\\\javaproj\\javalab", "scan.txt");
         //adds the date and time to entries
         Clock myClock = new Clock();
         cTime = myClock.getCurrentTime();
         cDate = myClock.getCurrentDate();
         //Add to counts
         ++scanCount;
         ++sessionCount;     
         //Append scanned data to text areas
         cTextArea.append(scanCount + "->" + scanText + " " + " " + cDate + " " + cTime );
         cCountLabel.setText("Current Pallet Case Count = " + scanCount);
         cTextArea.append("\r\n");
         tTextArea.append(sessionCount + "->" + scanText + " " + " " + cDate + " " + cTime);
         tCountLabel.setText("Total Pallet Case Count = " + sessionCount);
         tTextArea.append("\r\n");
         //Append scanned data directly to flat file.
         try
         FileWriter outputFile = new FileWriter("d:\\\\javaproj\\javalab\\scan.txt", true);
         outputFile.write(scanTextField.getText());
         outputFile.write(myClock.getCurrentDate());
         outputFile.write(myClock.getCurrentTime());
         outputFile.write("\r\n");
         outputFile.close();
    catch (IOException e)
         //clear the scan field
         scanTextField.setText("");
         // position the cursor
         scanTextField.requestFocus();
    Thanking you in advance for your assistance!!!!!!!!!
         

    Sorry that you're still having trouble :-( The title of your post seems a little different to your description of the problem, but I'm assuming you want the textfields to auto-scroll so they always show the last entry?
    Try this://Append scanned data to text areas
    cTextArea.append(scanCount + "->" + scanText + " " + " " + cDate + " " + cTime );
    cCountLabel.setText("Current Pallet Case Count = " + scanCount);
    cTextArea.append("\r\n");
    //ADD CALL TO AUTO-SCROLL METHOD:
    autoScroll(cTextArea);
    tTextArea.append(sessionCount + "->" + scanText + " " + " " + cDate + " " + cTime);
    tCountLabel.setText("Total Pallet Case Count = " + sessionCount);
    tTextArea.append("\r\n");
    //ADD CALL TO AUTO-SCROLL METHOD:
    autoScroll(tTextArea);Then you need to add this method to your class:private void autoScroll(TextArea textArea){
        //get the length of the text in the text area:
        int endOfText = (textArea.getText()).length();
        //...then set the caret position to the end:
        textArea.setCaretPosition(endOfText);

  • Adjust position and size of textField and button...

    Dear All,
    I have the following sample program which has a few textFields and a button, but the positions are not good. How do I make the textField to be at the right of label and not at the bottom of the label ? Also how to adjust the length of textField and button ? The following form design looks ugly. Please advise.
    import javax.swing.*; //This is the final package name.
    //import com.sun.java.swing.*; //Used by JDK 1.2 Beta 4 and all
    //Swing releases before Swing 1.1 Beta 3.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.text.*;
    import javax.swing.JTable;
    import javax.swing.JScrollPane;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    public class SwingApplication extends JFrame {
    private static String labelPrefix = "Number of button clicks: ";
    private int numClicks = 0;
    String textFieldStringVEHNO = "Vehicle No";
    String textFieldStringDATEOFLOSS = "Date of Loss";
    String textFieldStringIMAGETYPE = "Image Type";
    String textFieldStringIMAGEDESC = "Image Description";
    String textFieldStringCLAIMTYPE = "Claim Type";
    String textFieldStringSCANDATE = "Scan Date";
    String textFieldStringUSERID = "User ID";
    String ImageID;
    public Component createComponents() {
    //Create text field for vehicle no.
    final JTextField textFieldVEHNO = new JTextField(5);
    textFieldVEHNO.setActionCommand(textFieldStringVEHNO);
    //Create text field for date of loss.
    final JTextField textFieldDATEOFLOSS = new JTextField(10);
    textFieldDATEOFLOSS.setActionCommand(textFieldStringDATEOFLOSS);
    //Create text field for image type.
    final JTextField textFieldIMAGETYPE = new JTextField(10);
    textFieldIMAGETYPE.setActionCommand(textFieldStringIMAGETYPE);
    //Create text field for image description.
    final JTextField textFieldIMAGEDESC = new JTextField(10);
    textFieldIMAGEDESC.setActionCommand(textFieldStringIMAGEDESC);
    //Create text field for claim type.
    final JTextField textFieldCLAIMTYPE = new JTextField(10);
    textFieldCLAIMTYPE.setActionCommand(textFieldStringCLAIMTYPE);
    //Create text field for scan date.
    final JTextField textFieldSCANDATE = new JTextField(10);
    textFieldSCANDATE.setActionCommand(textFieldStringSCANDATE);
    //Create text field for user id.
    final JTextField textFieldUSERID = new JTextField(10);
    textFieldUSERID.setActionCommand(textFieldStringUSERID);
    //Create some labels for vehicle no.
    JLabel textFieldLabelVEHNO = new JLabel(textFieldStringVEHNO + ": ");
    textFieldLabelVEHNO.setLabelFor(textFieldVEHNO);
    //Create some labels for date of loss.
    JLabel textFieldLabelDATEOFLOSS = new JLabel(textFieldStringDATEOFLOSS + ": ");
    textFieldLabelDATEOFLOSS.setLabelFor(textFieldDATEOFLOSS);
    //Create some labels for image type.
    JLabel textFieldLabelIMAGETYPE = new JLabel(textFieldStringIMAGETYPE + ": ");
    textFieldLabelIMAGETYPE.setLabelFor(textFieldIMAGETYPE);
    //Create some labels for image description.
    JLabel textFieldLabelIMAGEDESC = new JLabel(textFieldStringIMAGEDESC + ": ");
    textFieldLabelIMAGEDESC.setLabelFor(textFieldIMAGEDESC);
    //Create some labels for claim type.
    JLabel textFieldLabelCLAIMTYPE = new JLabel(textFieldStringCLAIMTYPE + ": ");
    textFieldLabelCLAIMTYPE.setLabelFor(textFieldCLAIMTYPE);
    //Create some labels for scan date.
    JLabel textFieldLabelSCANDATE = new JLabel(textFieldStringSCANDATE + ": ");
    textFieldLabelSCANDATE.setLabelFor(textFieldSCANDATE);
    //Create some labels for user id.
    JLabel textFieldLabelUSERID = new JLabel(textFieldStringUSERID + ": ");
    textFieldLabelUSERID.setLabelFor(textFieldUSERID);
    Object[][] data = {
    {"Mary", "Campione",
    "Snowboarding", new Integer(5), new Boolean(false)},
    {"Alison", "Huml",
    "Rowing", new Integer(3), new Boolean(true)},
    {"Kathy", "Walrath",
    "Chasing toddlers", new Integer(2), new Boolean(false)},
    {"Mark", "Andrews",
    "Speed reading", new Integer(20), new Boolean(true)},
    {"Angela", "Lih",
    "Teaching high school", new Integer(4), new Boolean(false)}
    String[] columnNames = {"First Name",
    "Last Name",
    "Sport",
    "# of Years",
    "Vegetarian"};
    final JTable table = new JTable(data, columnNames);
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);
    //Add the scroll pane to this window.
    getContentPane().add(scrollPane, BorderLayout.CENTER);
    final JLabel label = new JLabel(labelPrefix + "0 ");
    JButton buttonOK = new JButton("OK");
    buttonOK.setMnemonic(KeyEvent.VK_I);
    buttonOK.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
              try {
    numClicks++;
              ImageID = textFieldVEHNO.getText() + textFieldDATEOFLOSS.getText() + textFieldIMAGETYPE.getText();
    label.setText(labelPrefix + ImageID);
              ScanSaveMultipage doScan = new ScanSaveMultipage();
              doScan.start(ImageID);
         catch (Exception ev)
    label.setLabelFor(buttonOK);
    * An easy way to put space between a top-level container
    * and its contents is to put the contents in a JPanel
    * that has an "empty" border.
    JPanel pane = new JPanel();
    pane.setBorder(BorderFactory.createEmptyBorder(
    20, //top
    30, //left
    30, //bottom
    20) //right
    pane.setLayout(new GridLayout(0, 1));
         pane.add(textFieldLabelVEHNO);
         pane.add(textFieldVEHNO);
         pane.add(textFieldLabelDATEOFLOSS);
         pane.add(textFieldDATEOFLOSS);
         pane.add(textFieldLabelIMAGETYPE);
         pane.add(textFieldIMAGETYPE);
         pane.add(textFieldLabelIMAGEDESC);
         pane.add(textFieldIMAGEDESC);
         pane.add(textFieldLabelCLAIMTYPE);
         pane.add(textFieldCLAIMTYPE);
         pane.add(textFieldLabelDATEOFLOSS);
         pane.add(textFieldDATEOFLOSS);
         pane.add(textFieldLabelUSERID);
         pane.add(textFieldUSERID);
    pane.add(buttonOK);
         pane.add(table);
    //pane.add(label);
    return pane;
    public static void main(String[] args) {
    try {
    UIManager.setLookAndFeel(
    UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (Exception e) { }
    //Create the top-level container and add contents to it.
    JFrame frame = new JFrame("SwingApplication");
    SwingApplication app = new SwingApplication();
    Component contents = app.createComponents();
    frame.getContentPane().add(contents, BorderLayout.CENTER);
    //Finish setting up the frame, and show it.
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    frame.pack();
    frame.setVisible(true);

    Post Author: Ranjit
    CA Forum: Crystal Reports
    Sorry but, i've never seen formula editor for altering position and size. If you know one please navigate me.
    I guess you have updated formula editor beside "Lock size and position" - if yes its not right. There is only one editor beside 4 items and editor is actually for Suppress.
    Anyways, A trick to change size a position is:
    Create 4-5 copies (as many as you expect positions) of the text object. place each at different positions,  right click, Format, Suppress and in formula editor for suppress write the formula: If your condition is true, Suppress=false, else true.
    Position will not change but user will feel; for different conditions -position is changed
    Hope this helps.
    Ranjit

  • JavaFX 2.2 TextField and TextArea use black text-fill on select.

    Two of my applications--one FXML and the other UI-coded on NetBeans7.1.1--both have a problem when user selects text in either TextArea or TextField when editing. When content word is double-clicked, the selection background becomes dark blue (dodgerblue) but the text remains BLACK. According to JavaFX-CSS reference the default for -fx-highlight-text-fill is WHITE but this doesn't seem to occur, assuming that "highlight" is the correct operation name.
    I tried an explicit CSS statement: .text-medium {-fx-font: 14 serif;
         -fx-highlight-text-fill: white;
         -fx-highlight-fill: lightgreen;
    } even trying to change the selection background. This also had no effect on selected text color or background.
    Interestingly, other "selection" operations for a TableView or ListView cell work as specified.
    I don't know the JavaFX build version. It came imbedded in jdk1.7.0_03 and was updated with "javafx-windows-i586__Vlatest.exe" download on May 2, 2012.
    Please let me know if this is abnormal and, if so, how it can be fixed.

    MORE INFO:
    The applications and testing is now running on up-to-date platforms: jdk 7.2.0_u4, javafx-2_2_0-beta-b10, NetBeans 7.2 Beta, and JavaFxSceneBuilder 1.0 (which is now somewhat integrated into NB7.2).
    The basic problem--highlighted text-fill color for both TextField and TextArea remains BLACK when double-clicked or selected draging cursor. This should be WHITE by default and the black text is almost invisible.
    Another discovery is that the legendary CTL-Z does not work within TextArea or TextField. All of the other edit keys seem to be fine. My applications have a lot of edit functions so not having an "undo" function is disappointing. Maybe there is some API disclaimer as to CTL-Z being unsupported. Anyone know about this?

  • [svn:fx-trunk] 10889: Add FTETextTests which check that a Label and NumericStepper configured to use FTEText have a textField and textInput , respectively, of type UIFTETextField and MXFTETextInput.

    Revision: 10889
    Author:   [email protected]
    Date:     2009-10-06 09:29:53 -0700 (Tue, 06 Oct 2009)
    Log Message:
    Add FTETextTests which check that a Label and NumericStepper configured to use FTEText have a textField and textInput, respectively, of type UIFTETextField and MXFTETextInput.  The components are configured via style properties rather than by theme which would require another version/compile of the BasicTests.swf.
    QE notes:
    Doc notes:
    Bugs:
    Reviewer: Alex
    Tests run: basictests
    Is noteworthy for integration: no
    Modified Paths:
        flex/sdk/trunk/frameworks/tests/basicTests/BasicTests-config.xml
        flex/sdk/trunk/frameworks/tests/basicTests/BasicTests.mxml
    Added Paths:
        flex/sdk/trunk/frameworks/tests/basicTests/halo/scripts/FTETextTestScript.mxml
        flex/sdk/trunk/frameworks/tests/basicTests/halo/views/FTETextTests.mxml

    I'm also having this problem. I'm using Flash Builder 4.6, AIR 3.4 and I've made a DLL (e.g. ExtensionDll.dll) which needs to call functions in another DLL (e.g. DllUsedByExtensionDll.dll) . I've made sure my ANE is working with the ExtensionDll.dll already, so there are no issues with my actionscript code or my ANE packaging or my DLL compilation. However, once I start calling functions from the other DLL, it starts throwing me Error #3500. Even if I call this function (e.g. abc()) in ExtensionDll.dll, but I never actually use the function from actionscript, and I call another function (e.g. def()) from actionscript, the Error #3500 still appears, so it does not seem to depened on the whether the code is used or not.
    It's similar to this problem.
    http://stackoverflow.com/questions/9823504/how-to-use-external-dll-in-air-native-extension
    Does anyone have a solution or at least a way to debug this?

  • How can i clear the textfield and the list selections?

    How can i clear the textfield and the list selections?
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    <applet code="ListDemo" width=300 height=400>
    </applet>
    public class ListDemo extends Applet implements ActionListener {
    List os, browser;
    String msg = "";
    String text;
    String named = "";
    TextField name;
    Button Ok, reset;
    public void init() {
    Ok = new Button("Ok");
    reset = new Button("reset");
    add(reset);
    add(Ok);
    reset.addActionListener(this);
    Ok.addActionListener(this);
    Label namep = new Label("Name: ", Label.RIGHT);
    name = new TextField(12);
    add(namep);
    add(name);
    name.addActionListener(this);
    os = new List(4, false);
    browser = new List(4, false);
    os.add("default");
    os.add("BMW");
    os.add("BENZ");
    os.add("Lexus");
    os.add("Acura");
    browser.add("default");
    browser.add("Red");
    browser.add("Black");
    browser.add("Silver");
    browser.add("Blue");
    browser.add("Yellow");
    browser.add("Pink");
    browser.add("Grey");
    browser.add("Blue/Black");
    os.select(0);
    browser.select(0);
    add(os);
    add(browser);
    os.addActionListener(this);
    browser.addActionListener(this);
    public void actionPerformed(ActionEvent ae) {
    String str = ae.getActionCommand();
    if(str.equals("Ok")){
    text = "You pressed Ok";
    else
    if(str.equals("reset")){
    browser.select(0);
    os.select(0);
    text = "";
    repaint();
    public void paint(Graphics g) {
    g.drawString("Name: " + name.getText(), 6, 120);
    int idx[];
    msg = "Current Car: ";
    idx = os.getSelectedIndexes();
    for(int i=0; i<idx.length; i++)
    msg += os.getItem(idx) + " ";
    g.drawString(msg, 6, 140);
    msg = "Current Color: ";
    msg += browser.getSelectedItem();
    g.drawString(msg, 6, 160);
    g.drawString(text, 6, 200);

    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    <applet code="ListDemo" width=300 height=400>
    </applet>
    public class ListDemo extends Applet implements ActionListener {
    List os, browser;
    String msg = "";
    String text;
    String named = "";
    TextField name;
    Button Ok, reset;
    public void init() {
    Ok = new Button("Ok");
    reset = new Button("reset");
    add(reset);
    add(Ok);
    reset.addActionListener(this);
    Ok.addActionListener(this);
    Label namep = new Label("Name: ", Label.RIGHT);
    name = new TextField(12);
    add(namep);
    add(name);
    name.addActionListener(this);
    os = new List(4, false);
    browser = new List(4, false);
    os.add("default");
    os.add("BMW");
    os.add("BENZ");
    os.add("Lexus");
    os.add("Acura");
    browser.add("default");
    browser.add("Red");
    browser.add("Black");
    browser.add("Silver");
    browser.add("Blue");
    browser.add("Yellow");
    browser.add("Pink");
    browser.add("Grey");
    browser.add("Blue/Black");
    os.select(0);
    browser.select(0);
    add(os);
    add(browser);
    os.addActionListener(this);
    browser.addActionListener(this);
    public void actionPerformed(ActionEvent ae) {
    String str = ae.getActionCommand();
    if(str.equals("Ok")){
    text = "You pressed Ok";
    else
    if(str.equals("reset")){
    browser.select(0);
    os.select(0);
    text = "";
    name.setText("");
    repaint();
    public void paint(Graphics g) {
    g.drawString("Name: " + name.getText(), 6, 120);
    int idx[];
    msg = "Current Car: ";
    idx = os.getSelectedIndexes();
    for(int i=0; i<idx.length; i++)
    msg += os.getItem(idx) + " ";
    g.drawString(msg, 6, 140);
    msg = "Current Color: ";
    msg += browser.getSelectedItem();
    g.drawString(msg, 6, 160);
    g.drawString(text, 6, 200);

  • Adf autosubmit textfield and focus

    Hi everybody,
    i am faces to a problem : i put autosubmit to textfield, and when i want to pass from one text field to another one i need to push two times one the tab key, same when i want to submit the form, i need to click twice on the button. Is someone has an idea how to do this? I searched on the forum, i found some threads but no solution ....
    Thank in advance.
    Regards.
    Yannick.

    Hi,
    sounds as if PPT is involved. Can you try with JDeveloper 10.1.3.4 to see if this problem still reproduces ? JDeveloepr 10.1.3.4 is available for download from otn.oracle.com/products/jdev
    Frank

  • GetImageReference and eventListeners

    Hi,
    Through a textField you can access images (or it's Loader
    object) with
    getImageReference( imgId ). This works fine.
    Now I want to add eventListeners to the Loader to detect
    mouseClicks on
    the images. But somehow that part won't work.
    Code from a quick test:
    In a function which loads the XML I have these lines:
    var img:Loader = Loader( html_txt.getImageReference( "img_0"
    img.contentLoaderInfo.addEventListener( Event.COMPLETE,
    loadedImage );
    the eventListeners are:
    function clickImage( evt:MouseEvent ):void
    trace( evt.target );
    function loadedImage( evt:Event ):void
    trace( evt.target.content, "is loaded" )
    var li:LoaderInfo = LoaderInfo( evt.target );
    li.content.addEventListener( MouseEvent.CLICK, clickImage );
    li.loader.addEventListener( MouseEvent.CLICK, clickImage );
    Al this traces:
    [object Bitmap] is loaded
    If I click on tha image in the textField however, nothing
    happens... Now
    I could go with the textField, have it listen to mouseEvents,
    get the
    bounds of all the images in it and see over which the mouse
    is at that
    moment, but that seems rather silly if I could get each image
    to
    register it's own listeners.
    Anybody?
    Thanks in advance.
    Manno
    Manno Bult
    http://www.aloft.nl

    Hi kglad and others,
    well, it works, but not as intended (at least, not my
    intention ;) ).
    addChild( img ); adds the image to the root (or parent of the
    textField) thereby removing it, like documentation states, from the
    textField itself. Ok, it becomes clickable, but not as part of the
    content of the textField.
    You cant issue addChild() on the textField in anyway so that
    won't work.
    Has anyone been able to do sort of the same thing as I'm
    trying now?
    Below is some simplified code working on this XML:
    <?xml version="1.0" encoding="utf-8"?>
    <rootnode>
    <p>Lorem ipsum... </p>
    <img src="plaatje.jpg" id="img_0" />
    <p>Donec malesuada, arcu eget tristique convallis...
    </p>
    </rootnode>
    Thanks,
    Manno

  • Newbie:how to create a page with 4 textfields and send data to MySql DB

    Dear all,
    i have created a page called page1 with 1 submit button named 'submitButton' and 4 textfields named:
    'date'
    'item'
    'contact'
    'phone'
    I have created a MySql DB table with the schema named 'association' and table named todolist3. Fields created in the table are :
    'Date' - >INTEGER->Primary
    'Item' ->VARCHAR(100)
    'Contact' ->VARCHAR(45)
    'Phone_contact' ->INTEGER
    what i want to do is to send the data from the 4 textfields to the database when i click the submit button. Below is the code i out in submit button. please kindly help as i have tested different ways but none of them works. thank you!!!
    public String submitButton_action() {
    try {
    if ( todolist3DataProvider.canAppendRow() )
    String item1=(String)item.getText();
    String contact1=(String)contact.getText();
    Integer phone1=(Integer)phone.getText();
    Integer date1=(Integer)date.getText();
    RowKey rowKey = todolist3DataProvider.appendRow();
    todolist3DataProvider.setCursorRow(rowKey);
    todolist3DataProvider.setValue("todolist3.Date", date1);
    todolist3DataProvider.setValue("todolist3.Item",item1);
    todolist3DataProvider.setValue("todolist3.Contact",contact1);
    todolist3DataProvider.setValue("todolist3.Phone_contact",phone1);
    } else {
    error("submitButton_action() -- cannot append todolist3 record");
    } catch (Exception e) {
    error("Page1::submitButton_action-- something's wrong trying to append todolist3 record");
    return null;
    }

    Hi,
    I think that you have forgotten to commit changes. Modify your code to look like this:
    RowKey rowKey = todolist3DataProvider.appendRow();
    todolist3DataProvider.setCursorRow(rowKey);
    todolist3DataProvider.setValue("todolist3.Date", date1);
    todolist3DataProvider.setValue("todolist3.Item",item1);
    todolist3DataProvider.setValue("todolist3.Contact",contact1);
    todolist3DataProvider.setValue("todolist3.Phone_contact",phone1);
    // commit your changes !!!
    todolist3DataProvider.commitChanges();
    } else {
    // ....best regards
    Grzegorz

  • Increaseing the height and width of textfield and password fields

    Dear friends in apex 4.1 when we create a application it automatically creates a login page
    with username and password field in it
    So my question is can i increase the height and width of the username and password field in that login page
    If it is possible please help.
    and also i cannot find the html tag like <input type=text............>
    Where to find it?

    Hi,
    You can easily achieve this using css
    <style>
    input.myclass
      height:100px;
      width:100px;
    </style>
    <input type="test" class="myclass" size="10">So in APEX you have to edit the textfield > HTML Form Eelement Attributes > put class="myclass"
    Thanks

  • Simple layout question, shrinking TextField and TextArea inside VBox

    Given:
            VBox root = new VBox(10);
            root.getChildren().addAll(new TextField(), new TextArea());
            Scene scene = new Scene(root, 300, 250);When I shrink the application window vertically, the textfield starts to shrink first, while the text area stays its size, then when the textfield is only a narrow strip, the text area starts to shrink.
    1) Is this expected?
    2) Is it by design? If so, why?
    3) How can I avoid it, i.e. have the text area shrink first, then the textfield?
    It think the behaviour in 3) makes more sense, since a text area by its nature can have different heights; a text field on the other hand I would expect to have the height of a single line of text unless there is absolutely no space for it in its container. It doesn't make sense to have a textfield that is a fraction of the height of a line of text.
    I have tried various combinations of minHeight and prefHeight, but without luck.

    Hey,
    1) Yes, this is expected!
    2) Yes, why.. well I don't know why the minimum height of a TextField is smaller than the pref size.
    3) This can be avoid by setting your own sizes (min size - pref size - max size)
            VBox root = new VBox(10);
            root.setStyle("-fx-background-color: lightgray");
            TextField tf = new TextField();
            tf.setMinHeight(Control.USE_PREF_SIZE); //the minimum height = the preferred height
            TextArea ta = new TextArea();
            ta.setMinHeight(30);
            ta.setPrefHeight(50);
            ta.setMaxHeight(Double.MAX_VALUE); //maximum height, depends on the parent
            VBox.setVgrow(ta, Priority.ALWAYS); //use the maximum height available
            root.getChildren().addAll(tf, ta);
            Scene scene = new Scene(root, 300, 250);Edited by: FXdude on 21-jan-2013 6:13

  • AS3: DisplayList and EventListeners

    I was wondering if there's a way to monitor the DisplayList
    so that you can see when items get removed/Garbage Collected.
    And is there a way to monitor EventListeners so that you can
    see if you're effectively removing them when they're no longer
    needed?
    Thanks...
    Brenda

    you can monitor the display list but that doesn't make much
    sense in the present context: if you want something gc'd, it must
    be removed from the displaylist. you surely won't detect something
    being gc'd by monitoring the displaylist.
    in general, you must know to what displayobjectcontainer you
    added your display object or you can't remove it. and if you know
    that, you must use removeChild() or removeChildAt() to remove it.
    you could check the numChildren property of your
    displayobjectcontainer, but that would be a pretty crude way to
    determine if a particular object has been removed from that
    displayobjectcontainer.

  • [PROBLEM] TextField() and addChild(scrollbar)

    Hi,
    i've HTMLText class that extends TextField. When i try to use addChild to an instance of this class like:
    htmlTxt.addChild(mySb);
    it says to me
    Error #1061: Call to a possibly undefined method addEvent through a reference with static type
    Why?
    I need it to visualize a vertical scrollbar. there is a why to add it?

    If it's a UIScrollBar component then you can assign the textfield to the scrollTarget property.
    mySB.scrollTarget = htmlTxt;
    The Flash helps docs explain all the properties and methods available for the UIScrollBar.

  • TextField and CSS: How to control spacing between paragraphs

    I'm using an external CSS to format a textField that has some
    HTML text in it, let's say something similar to this:
    myTextField.htmlText = "<p>paragraph
    one</p><p>paragraph two</p>";
    How can I control the spacing between paragraphs when there
    is no support for margin-top or margin-bottom? I don't want to add
    empty <p> or <br /> elements to my text since they
    don't allow exact control and insert too much space. Is there any
    good solution?
    Thanks

    I think rob day's suggestion has merits too. Either way I
    don't see any other way but inserting an extra element that adjusts
    the spacing somehow.
    Yes, it sucks that the majority of styling declarations are
    not supported but, on the other hand, it is not such a big deal to
    insert an element especially with the powerful XML tools in AS3.
    You can create a function that will preprocess all XML "page"
    nodes and insert an extra <p> tag after each <p> tag
    (see attached code)
    I did not check if code works - it is just a concept.
    The same approach can be taken with rob's suggestion but
    inside the <p> element that comes with the XML.

  • Spacing between textfield and text

    Anyone know how to set spacing between the text and border of a textfield?
    The docs say to use
    textfield.setMargin(new Insets(top, left, bottom, right));
    but that doesn't do anything.
    Thanks a lot for suggestions.

    The problem is that your border isn't going to use the margin of the text field (since it's not specialised for text fields). You've got a number of options:
    1) use the default border
    2) use a compound border with the default border inside
    3) write your own border that incorporates the text field's margin
    4) don't bother setting the margin and simply add a corresponding EmptyBorder into your compound border instead
    Option 4 is probably the quickest for you:
    textField.setBorder(new CompoundBorder(SOLID_BORDER, new EmptyBorder(10, 10, 10, 10)));Hope this helps.

Maybe you are looking for