No return in a textfield

hello!
well, i've two textfields á la
inhalt.restrict = "a-zA-Z0-9_\\-?.,;!äüöÄÜÖß ";
inhalt.multiline = true;
inhalt.wordWrap = true;
in the first case i do not want the user be able to use the enter / return - key and in the second one i do not want him use it more then two ore three times. how can i manage this? i've serched with google but i do not find the right things, maybe i used the wrong search-words
thanks for any help!

hm
inhalt.restrict = "a-z0-9^\u0013"
doesn't work

Similar Messages

  • How to retain focus in Textfield

    I have one panel which contains three textfiled and one ToolBar. on clicking tool bar button certain dialog get opened.
    intially foucus remained on first textfield but when i do open the dialog with tool bar button. focus doesn't get return to first textfield even focus doesn't get back to screen.
    And my requirement is that to get focus on first textfield after closing the dialog.
    Please let me know if you have any suggestions.
    Thanks,

    yeah I need to set focus again on textfield and that is my question.you can do that using something like :jTextField.requestFocus(); I am seeking the event on which i can set the focus again please suggest.If you are using JOptionPane just add the above statement after showing dialog like JOptionPane.showInputDialog("Hello");
    jTextField.requestFocus();If you are using your own dialog, have a refrence to the textfield in the dialog and at 'windowClosing' Event use the mentioned statement.
    I think that should work....
    Thanks!

  • IOS multiline textfield - enter key

    I'm having a weird bug on iOS
    I create 2 dynamic text fields, 1 multiline, 1 singleline. I run this on my ipad, I give the textfields focus by clicking on them to pull up the softkeyboard.
    The multiline textfield will have an enter button that say "Return"
    The singleline textfield will have an enter button that says "Done"
    add a listener for keyup
    stage.addEventListener(KeyboardEvent.KEY_UP, this._onKeyUp);
    private function _onKeyUp($event:KeyboardEvent):void{
                switch($event.keyCode){
                    case Keyboard.ENTER:
                    trace("HELLO?");
              break;
    The trace will only work when you press "Done", it never fires for "Return"

    Hi,
    Yes it's always allowed, however the problem comes when you then try to output it using an outputText, it won't show the line feed as \n is ignored in HTML. You have to use Trinidad's outputDocument component for that.
    Regards,
    ~ Simon

  • Making the textbox/textfield single-line

    Is there a way to disable carriage returns in a textfield or textbox? I don't want the user to enter mulitple lines of text in my applet.

    Well the problem with that is that the SEND key enters a carriage return, which is basically one character. But it expands the text box to accomodate the second line. If you have 10 characters you could potentially have 10 lines of data--just 10 blank lines. I guess the only way is to filter out the carriage returns using ItemStateListener.

  • Add to TextField on Different Form

    Hi
    How is it possible to add text to a textfield from a from (Class A) to another form (Class B) which is open behind the first form.
    Any help would be appreciated
    Thanks
    Gregg

    Hi
    How is it possible to add text to a textfield from a
    from (Class A) to another form (Class B) which is open
    behind the first form.
    Any help would be appreciated
    Thanks
    GreggI'm not sure if this will work but it might.... you could have a method in classA that returns the first TextField, and call a getText Method from that and use that to set the textField in class B.

  • Creating a search form based on a table.

    Hello,
    I'm currently trying to create a search form which performs a searchquery in values stored in a table in my database.
    The table is filled peoples names,lastnames ,telephonenumbers and departments.
    I can use the sample application to make a form based on the tableview but this returns a search textfield for every column in the table. I just want 1 searchfield/textfield to search on ALL columns at the same time and display the other fields as labels when returning the queryresults.
    I tried searching the forums for an explanation on how to build said form and I checked Metalink but I have yet to find one. Anyone out there willing to help me out?
    thanks in advance,
    Melvin K.

    Why not use an instr with your data in a bind variable in your where clause for the select?? Page 1 sets an item called P2_Parameter with your value string slightly modified ('12345','345632','645534534','3434344')
    Select a,b,c,d,e from some_table where INSTR(TO_CHAR(Lookup_column,'099999999'),:P2_Parameter)
    Maybe that will work? Its off the top of my head, but should get you what you want.. (But to agree with one of the other posters, it is a BAD Design..) I would try like an interactive report to allow them to enter in acct #'s or whatever these are and let them access the rows that way..
    Thank you,
    Tony Miller
    Webster, TX

  • How to include an ActionScript based media player in Flex

    Hi,
    Flex/ AS3 newbie here.
    I'm attempting to port/include the flowplayer (http://flowplayer.org) into a flex project.
    I've included the .swc file for the player in my flex project. While trying to instantiate the player I'm running into an issue where the player code does not know about what seems to me should be important things (such as the stage) -- they are always coming back as null.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application
        xmlns:mx="http://www.adobe.com/2006/mxml"
        xmlns:flowplayerView="org.flowplayer.view.*"
        applicationComplete="init();"
    >
    <mx:Script>
         <![CDATA[
              import mx.core.UIComponent;
              import org.flowplayer.view.*;
              public function init(): void
                   var ui:UIComponent = new UIComponent();
                            var sprite:Sprite = new Sprite();
                            var movieClip:Preloader = new  Preloader();
                            ui.addChild(sprite);
                            ui.addChild(movieClip);
                            myPanel.rawChildren.addChild(ui);
         ]]>
    </mx:Script>
    <mx:Panel id="myPanel"
            paddingTop="10"
            paddingBottom="10"
            paddingLeft="10"
            paddingRight="10"
            height="300"
            width="600"       
        >
        </mx:Panel>
    </mx:Application>
         The goal is to start up this preloader code, which will make the flowplayer go in the same way as if I started it via Javascript. However, the marked items below are always null. What do I need to do to propogate these high level flash system variables into this included code?
    public class Preloader extends MovieClip {
              private var _app:DisplayObject;
              private var _percent:TextField;
              public function Preloader() {
                stop();
    // !!null pointer here on loader info
    if (loaderInfo.bytesLoaded == loaderInfo.bytesTotal) {
                     init();
                     return;
                _percent = new TextField();
                   var format:TextFormat = new TextFormat();
                   format.font = "Lucida Grande, Lucida Sans Unicode, Bitstream Vera, Verdana, Arial, _sans, _serif";
                   _percent.defaultTextFormat = format;
                   _percent.text = "Loading...";
                addChild(_percent);
                addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
              private function onAddedToStage(event:Event):void {
                loaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoadProgress);
                loaderInfo.addEventListener(Event.COMPLETE, init);
              private function onLoadProgress(event:ProgressEvent):void {
                     var percent:Number = Math.floor((event.bytesLoaded*100) / event.bytesTotal);
                graphics.clear();
                 _percent.text = (percent + "%");
                _percent.x = stage.stageWidth / 2 - _percent.textWidth / 2;
                _percent.y = stage.stageHeight / 2 - _percent.textHeight / 2;
            private function init(event:Event = null):void {
                 if (_percent) {
                      removeChild(_percent);
                 nextFrame();
                 prepareStage();
                   var mainClass:Class = Class(getDefinitionByName("org.flowplayer.view.Launcher"));
                _app = new mainClass() as DisplayObject;
                   addChild(_app as DisplayObject);
              private function prepareStage():void {
                   //!!null pointer here on stage
                   stage.align = StageAlign.TOP_LEFT;
                   stage.scaleMode = StageScaleMode.NO_SCALE;

    Were you able to get to work? I would like to include the Flowplayer in a Flex application also.

  • Creating a very simple XML-driven gallery

    Hi, I'm learning XML in AS3 and I am having real trouble finding a resource that can help me learn how to build a very simple XML-driven picture gallery.
    I am working in an FLA file with AS3, with a dynamic text field with the instance name "textfield". I also have a UILoader Component with the instance name "UILoaderComponent" and an XML file called "rootdir.xml".
    I have an XML file in the following format.
    <images>
         <imagenames>
              <name>image1</name>
              <name>image2</name>
              <name>image3</name>
              <name>image4</name>
              <name>image5</name>
         </imagenames>
         <imagepaths>
              <path>image1.jpg</path>
              <path>image2.jpg</path>
              <path>image3.jpg</path>
              <path>image4.jpg</path>
              <path>image5.jpg</path>
         </imagepaths>
    </images>
    I am using the following as my actionscript.
    var xmlLoader:URLLoader = new URLLoader();
    var xmlData:XML = new XML();
    xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
    xmlLoader.load(new URLRequest("rootdir.xml"));
    function LoadXML(e:Event):void {
    xmlData = new XML(e.target.data);
    parseImg(xmlData);
    function parseImg(imgLoad:XML):void {
    var imgChild:XMLList = imgLoad.images.children();
    for each (var imgTrace:XML in imgChild) {
    trace(imgTrace);
    No matter which way I experiment, I always have poor results with my dynamic text, and every tutorial I've followed does not reproduce anything like the same returned data in "textfield" that it does with the trace command.
    My objective is: I simply want to build a menu inside a textbox called "textfield" that lists images1-5, and when clicked, calls upon the relevant image. For instance: I load the file "rootdir.xml" into the file "index.fla". I call a function to parse the XML into a dynamic text box called "textfield". When image 2 is clicked on the textbox "textfield", it would call upon a function that would load into the UIComponent Loader "image2.jpg".
    Are there any tutorials for this? I'm so confused as to why dynamic text operates so differently from the trace command. I'm not interested in doing a fancy menu bar with thumbnails, scrollbars and animations, I just want to learn the basics.

    I don't really see how you are getting a valid trace out of that code (I get nothing if I try it as is), but as far as the textfield goes, you haven't shown any attempt in your code that might help to point to why you cannot get the text into a textfield.  It might be a problem with how you are trying to write to the textfield and not how your are manipulating the data.
    While you could make use of a textfield for the menu, doing so is not straightforward, as you would need to implement htmlText with special coding in order to have the text clickable.  You might consider using a List component or ComboBox instead.
    What I always do when I am working with xml is to store the data into a data structure, usually an array conatining objects, and then make use of that structure rather than dippng into the xml data itself when I utilize the data.
    Another thing, which rquigley demonstrated, is that your xml will serve its purpose better if the data for each image is collected under the same node.  If you have separate sections for each piece of data like you have, when it comes to editing it will be more prone to error as you have to be sure you are editing the correct entry of each separate group.
    I too am no expert in the world of xml, but I have not yet worked with parameters inside the tags, so I would usually structure it as...
    <images>
       <image>
           <imgName>image 1</imgName>
           <imgPath>image1.jpg</imgPath>
       </image>
       <image>
           <imgName>image 2</imgName>
           <imgPath>image2.jpg</imgPath>
       </image>
    </images>
    Now, back to what you have...  let's say you have a textField named imgText that you want to list the image names in.  The following should work, though I do not go my usual route of storing the data into an object array first...
    function parseImg(imgLoad:XML):void {
       var imgNames:XMLList = imgLoad.imagenames.name;
       var imgPaths:XMLList = imgLoad.imagepaths.path;
       // show name
       for each (var nameTrace:XML in imgNames) {
          trace(nameTrace);
          imgText.appendText(nameTrace +"\n");
       // show path
       for each (var pathTrace:XML in imgPaths) {
          trace(pathTrace);
          imgText.appendText(pathTrace +"\n");
       // show name and path
       for(var i:uint=0; i<imgNames.length(); i++){
          trace(imgNames[i].text()+"  "+imgPaths[i].text());
          imgText.appendText(imgNames[i].text()+"  "+imgPaths[i].text() +"\n");

  • The curious custom panel caper!

    Greetings all, before you instantly dismiss this question as too long/noobish, please read it, it's really quite strange. If a couple of you could at least copy the code I have given and let me know if you get the same results that would be great, as I have access to only one machine to program on at the moment.
    Anyway, back to the story. I have a curious mystery which is somewhat bizzare. I created a very simple program which features a JButton in a frame which is attached to a JFileChooser. Above the button is a custom JPanel which is basically a fancy text box and is supposed to give the filename of the file selected by the JFileChooser. The weird part comes when you click the button... the component (which is already initialized and has had it's value set) seems to have vanished, its still visible, but trying to change it's value or print any of its attributes results in a NPE. Any ideas you can come up with would be of great help. It's probably something really obvious that my tired eyes just can't spot.
    Here is the code... I've stripped it down to the bare minimum to highlight the problem.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    public class Experiment extends JFrame implements ActionListener{
         private File in_file;
         private JFileChooser fc;
         private JButton button;
         private CustomPanel fileField;
         public Experiment(){
              super("Experiment");
              fc = new JFileChooser();
              JPanel box = new JPanel();
              box.setLayout(new BoxLayout(box,BoxLayout.Y_AXIS));
              box.setBorder(BorderFactory.createTitledBorder(
                               BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
                               "Form Details"));
              CustomPanel fileLabel = new CustomPanel(CustomPanel.LABEL,"File",250,"file","file");
              fileLabel.setObject("no file selected");
              box.add(fileLabel);
              button = new JButton("Select File");
              button.addActionListener(this);
              button.setActionCommand("select");
              box.add(button);
              getContentPane().add(box, BorderLayout.NORTH);
              setSize(new Dimension(300,120));
              setResizable(false);
              /* this println is successful */
              System.out.println("fileLabel = "+fileLabel.getText());
         public void actionPerformed(ActionEvent e){
              /* this one is unsuccessful! why?! */
              System.out.println("fileField = "+fileField.getText());
              String command = e.getActionCommand();
              if(command.equals("select")){
                   selectTemplate();
         public void selectTemplate(){
              int returnVal = fc.showDialog(this, "Select");
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                in_file = fc.getSelectedFile();
                   fileField.setObject(in_file.getName());
         public static void main(String [] args) throws IOException{
              Experiment s = new Experiment();
              s.show();
    }You will also require the code for the CustomPanel
    import java.io.*;
    import java.awt.*;
    import java.text.*;
    import java.util.*;
    import javax.swing.*;
    public class CustomPanel extends JPanel {
        public static final int TEXT=0;
        public static final int LABEL=1;
        private JPanel spacer;
        private JLabel label,label2;
        private JTextField textField;
        private DisabledCustomPanel disabledField;
        private String entity,labelTxt,toolTip;
        private int type,labelWidth,fieldWidth,maxSize=1024;
        private boolean notNull = false;
         * Creates a new CustomPanel object
         * @param type the type of component to be generated
          * @param labelTxt the text for the label
          * @param labelWidth the width of the label
          * @param fieldWidth the width of the editable field
          * @param entity the entity that this component corresponds to
          * @param toolTip The tool tip text for this component
        public CustomPanel(int type,String labelTxt,int labelWidth,int fieldWidth,String entity,String toolTip){
              this.type=type;
              this.labelTxt=labelTxt;
              this.entity=entity;
              this.toolTip=toolTip;
              this.labelWidth=labelWidth;
              this.fieldWidth=fieldWidth;
              init();
         * Creates a new CustomPanel object
         * @param type the type of component to be generated
          * @param labelTxt the text for the label
          * @param width the width of the entire component (label/field are balanced 3/7)
          * @param entity the entity that this component corresponds to
          * @param toolTip the tool tip text for this component
        public CustomPanel(int type,String labelTxt,int width,String entity,String toolTip){
              this.type=type;
              this.labelTxt=labelTxt;
              this.entity=entity;
              this.toolTip=toolTip;
              labelWidth=(int)((float)width*0.3);
              fieldWidth=(int)((float)width*0.7);
              init();
        private void init() {
              label=new JLabel(labelTxt,SwingConstants.RIGHT);
              setLayout(new FlowLayout(FlowLayout.LEFT,1,3));
              add(label);
              spacer=new JPanel();
              spacer.setPreferredSize(new Dimension(7,7));
              add(spacer);
              disabledField=new DisabledCustomPanel();
              add(disabledField);
              label.setToolTipText(toolTip);
              disabledField.setToolTipText(toolTip);
              switch(type) {
                   case TEXT:
                       textField=new JTextField();
                       add(textField);
                       textField.setPreferredSize(new Dimension(fieldWidth,25));
                       break;
                   case LABEL:
                       label2=new JLabel("");
                       add(label2);
                       break;
              label.setPreferredSize(new Dimension(labelWidth,25));
              disabledField.setPreferredSize(new Dimension(fieldWidth,25));
              setPreferredSize(new Dimension(labelWidth+fieldWidth,30));
              getActiveComponent().setToolTipText(toolTip);
              setEnabled(false);
         * Returns the contents of the component as a string.
         * @return the String representation of the value held by this component.
        public String getText() {
              Object tmpObj;
              switch(type) {
                   case TEXT:
                       return textField.getText().trim();
                   case LABEL:
                       return label2.getText().trim();
              return "";
         * Sets the contents of the component.
          * @param obj the object to set.
        public void setObject(Object obj) {
              if (obj == null) {
                   clear();
                   return;
              String txt=obj.toString();
              switch(type) {
                   case TEXT:
                       textField.setText(txt);
                       break;
                   case LABEL:
                       label2.setText(txt);
                       break;
              updateDisabled();
         * Updates the field of the component displayed when it is uneditable.
        public void updateDisabled(){
              String txt=getText();
              switch(type){
                   case TEXT: case LABEL:
                       disabledField.setText(txt);
                       break;
         * Clears the component's contents.
        public void clear() {
              disabledField.setText("");
              switch(type){
                   case TEXT:
                       textField.setText("");break;
                   case LABEL:
                       label2.setText("");break;
         * Gets the string you would need to use with an UPDATE statement to
         * represent this component.
         * @return a String consisting of the encapsulated field name and value of
         *         this component in the form <code>field='value'</code> for use
         *         with SQL UPDATE statements.
        public String getUpdateText() {
              switch(type) {
                   case LABEL: return "";
              return entity+"='"+formatSQL(getText())+"'";
         * Gets the string you would need to use with an INSERT statement to
         * represent this component.
         * @return a String consisting of the encapsulated value of this component
         *         in the form <code>'value'</code> for use with SQL INSERT
         *         statements.
        public String getInsertText(){
             return "'"+formatSQL(getText())+"'";
         * Gets the type of this CustomPanel.
         * @return the type of this CustomPanel.
        public int getType() {
              return type;
         * Gets the entity currently associated with this CustomPanel.
         * @return the entity currently associated with this CustomPanel.
        public String getEntity() {
              return entity;
         * Creates part of an UPDATE statement given an array of CustomPanel objects.
          * @param v The array of CustomPanel objects to join.
          * @return a textual representation of the set of CustomPanels of the form
          *         <code>field1='value1', field2='value2'</code> used for UPDATE
          *         statements.
        public static String joinForUpdate(CustomPanel [] v) {
              String vStr="";
              int i;
              for (i=0;i<v.length;i++) {
                  if (vStr.length() > 0 && v.getType() != LABEL) vStr+=", ";
              vStr+=v[i].getUpdateText();
              return vStr;
    * Creates part of an INSERT statement given an array of CustomPanel objects.
         * @param v The array of CustomPanel objects to join.
         * @return a textual representation of the set of CustomPanels of the form
         * <code>'value1', 'value2'</code> used for INSERT statements.
    public static String joinForInsert(CustomPanel [] v){
         String vStr="";
         int i;
         for (i=0;i<v.length;i++) {
              if (vStr.length() >0 && v[i].getType() !=LABEL) vStr+=", ";
              vStr+=v[i].getInsertText();
         return vStr;
    * Fills in multiple components at once using data from an SQLResult
    * object. NB - only the first row from the SQLResult is used.
         * @param v The array of CustomPanel objects
         * @param r The SQLResult containing the destination data
         * @see SQLResult
    public static void fill(CustomPanel [] v,SQLResult r) {
              Object tmpObj;
              int i,col;
              for (i=0;i<v.length;i++) {
              col=r.getNamedColumn(v[i].getEntity());
              if (col != -1) {
                        tmpObj=r.getValueAt(0,col);
                   if (tmpObj != null) v[i].setObject(tmpObj);
    * Sets whether this component may be edited or not.
    * @param enabled whether or not you want the component enabled or not.
    public void setEnabled(boolean enabled) {
              if (!enabled) updateDisabled();
              getActiveComponent().setVisible(enabled);
              disabledField.setVisible(!enabled);
    * Gets the JComponent used by the this CustomPanel to hold data.
    * NB - if you change the contents of the component, you will have to
    * call updateDisabled().
    * @return the JComponent used by this CustomPanel to hold data.
    public JComponent getActiveComponent() {
              switch(type) {
              case TEXT:
              return textField;
              case LABEL:
              return label2;
              return null;
    * Registers whether this component may be allowed to be NULL (empty).
    public void setNotNull(boolean notNull) {
              this.notNull=notNull;
    * Registers the maximum number of characters allowed by the component.
    * @param maxSize the maximum number of characters allowed by the component.
    public void setMaxSize(int maxSize) {
              this.maxSize=maxSize;
    * Verifies the integrity constraints of the component.
         * @param usePopup whether to display a popup if there's a problem or not.
         * @return <code>false</code> if the component has a problem,
         * <code>true</code> otherwise.
    public boolean verify(boolean usePopup) {
              Object tmpObj;
              switch(type) {
                   case TEXT:
                   if (notNull && textField.getText().length()==0) {
                        if (usePopup) popup("Please complete the '"+labelTxt+"' field.");
                        return false;
                   if (textField.getText().length() > maxSize) {
                        if (usePopup) popup("'"+labelTxt+"' may only contain up to "+
                                  maxSize+" characters.");
                        return false;
                   break;
              return true;
    * Verifies an entire array of components, stopping and popping up an
    * error if there's a problem.
         * @param v the target array of CustomPanels to check for validity.
         * @return <code>false</code> if there's a problem, <code>true</code>
         * otherwise.
    public static boolean sanityCheck(CustomPanel [] v) {
              int i;
              for (i=0;i<v.length;i++)
              if (!v[i].verify(true)) return false;
              return true;
         * Conveniance method to popup JOptionDialog targeted at this CustomPanel.
         * @param message the message to popup.
         private void popup(String message) {
              JOptionPane.showMessageDialog((JPanel)this,message,"Warning",JOptionPane.WARNING_MESSAGE);
         * Method to format Strings for SQL queries and statements, uses character
         * stuffing to protect special characters.
         * @param txt the String to format.
         * @return the formatted String.
         private static String formatSQL(String txt) {
              String out="";
              String chr;
              int i;
              for (i=0;i<txt.length();i++) {
              chr=""+txt.charAt(i);
              if (chr.equals("'")) chr="''";
              out+=chr;
              return out;
    * An easily-readable, un-editable field of text. Used by CustomPanel, but may
    * be used alone if necessary.
    * @see CustomPanel
    public class DisabledCustomPanel extends JPanel{
    private JLabel label;
    * Creates a new DisabledCustomPanel
    public DisabledCustomPanel() {
              super(new GridLayout());
              setBackground(Color.WHITE);
              setForeground(Color.BLACK);
              label=new JLabel();
              label.setFont(new Font("dialog",Font.PLAIN,12));
              add(label);
              setBorder(BorderFactory.createLineBorder(Color.GRAY));
    * Sets the text shown by this component.
         * @param txt the text to be shown.
    public void setText(String txt) {
              label.setText(" "+txt);
    * Sets the tool tip text for this component.
         * @param toolTip the tool tip text for this component.
    public void setToolTipText(String toolTip) {
              label.setToolTipText(toolTip);

    You are referencing an uninitalized component.
    I changed the code below to use the class member var fileField
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    public class Experiment extends JFrame implements ActionListener
        private File in_file;
        private JFileChooser fc;
        private JButton button;
        private CustomPanel fileField;
        public Experiment()
            super("Experiment");
              setDefaultCloseOperation( EXIT_ON_CLOSE );
            fc = new JFileChooser();
            JPanel box = new JPanel();
            box.setLayout(new BoxLayout(box,BoxLayout.Y_AXIS));
            box.setBorder(BorderFactory.createTitledBorder(
                                                          BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
                                                          "Form Details"));
            //This was a local var that you were using.
           //CustomPanel fileLabel = new CustomPanel(CustomPanel.LABEL,"File",250,"file","file");          
             //You needed to initalize the member var.
            fileField = new CustomPanel(CustomPanel.LABEL,"File",250,"file","file");
            fileField.setObject("no file selected");
            box.add(fileField);
            button = new JButton("Select File");
            button.addActionListener(this);
            button.setActionCommand("select");
            box.add(button);
            getContentPane().add(box, BorderLayout.NORTH);
            setSize(new Dimension(300,120));
            setResizable(false);
            /* this println is successful */
            System.out.println("fileLabel = "+fileField.getText());
        public void actionPerformed(ActionEvent e)
            /* this one is unsuccessful! why?! */
            System.out.println("fileField = "+fileField.getText());
            String command = e.getActionCommand();
            if( command.equals("select") )
                selectTemplate();
        public void selectTemplate()
            int returnVal = fc.showDialog(this, "Select");
            if( returnVal == JFileChooser.APPROVE_OPTION )
                in_file = fc.getSelectedFile();
                fileField.setObject(in_file.getName());
        public static void main(String [] args) throws IOException{
            Experiment s = new Experiment();
            s.show();

  • Indesign slow when editing remote documents

    We're using an Indesign/Incopy webbased solution to write/edit our Indesign documents. All Indesign (Incopy) documents are on a remote database server. So when I open such an Indesign document, I basically download it from the remote location, edit it and when saving I upload it back to the server. There are no local Indesign/Incopy files. While testing we discovered that editing can be very slow. When placing a carriage return in a textfield for example, it can take a few seconds and meanwhile the Mac is showing it's rotating circle indicating that it's busy. It simple text edit can take a long time when the document contains a lot of high resolution psd documents.
    Is there anything we can do to speed up this process. Apparently it is doing something to the remote Indesign (or auto recover) document while doing text edits. Some kind of upload seems necessary to those documents while doing the text edits. And as the Indesign document is quite large when containing a lot of psd documents these uploads during text edits can take quite a while. What could it be doing during such a text edit and can that process be turned off? So I can open (download) the Indesign document, do my edits while there are no uploads necessary, and finally save (upload) the document?

    The recovery folder is the default one, locally on my IMac.
    The process is as follows.
    I select an Indesign/Incopy document on the remote server to open it. It gets downloaded and opens like any normal document. Then I edit and when I save it, it gets uploaded again to the remote server. All Indesign documents there are stored in the third-party database.
    When I open a large (many photos) document and do text edits, a simple text edit can take quite a few seconds. The macs 'busy' circle rotates. It's saving to the local recovery folder, so that couldn't be it.
    But it looks like it is doing something to the remote third-party database indesign file during the text edit?

  • Full Component acces

    Hello. I have successful made an layerPaned. But the JPanels stopped to repaint() when LayerPaned was added(worked before). Have have tried to fix this in lots of days now but I really cant solve it.
    The only wrong I can think of is that I don't have full access to the layer. But have looked over http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Component.html many times and cant find anything useful. Can you see what I have missed? (I know it would be easyer if I made this "shorten problem example code" thing. But I have really tried do that for some hours, but the result was way to many lines. So just added main and layerPane classes where the problem should be located at):
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.accessibility.*;
    import java.awt.*;
    import java.awt.event.*;
    public class LayeredPane extends JPanel{
    // Other classes added
        private JLayeredPane layer;
        private Performance p = new Performance(3);
    // to reduce the code I removed this(stringView) JPanel(Just to not make you to confused)
        private stringView sview = new stringView(p);
        private View view = new View(p);
        private TextField f = new TextField(view, p, sview);
    // Constructor: taking in the layers to add
        public LayeredPane(Performance p, stringView sview, View view, TextField f){
            this.sview = sview;
            this.view = view;
            this.p = p;
            this.f = f;
            layer = new JLayeredPane();
            layer.setPreferredSize(new Dimension(600,500));
    // creating the panels with the createPane1(2) methods
           View pane1 = createPane1(new Point(0, 0));
           TextField pane2 = createPane2(new Point(50, 50));
    // adding the panels and z possition for them
           layer.add(pane1, new Integer(1));
           layer.add(pane2, new Integer(2));
           add(layer);
    // In this methods I have tried to add things like this without any result:
            v.setEnabled(true);
            v.enable(true);
            v.setFocusable(true);
        private View createPane1(Point origin) {
            View v = new View(p);
            v.setOpaque(true);
            v.setBounds(0, 0, 600, 500);
            return v;
        private TextField createPane2(Point origin) {
            TextField f = new TextField(view, p, sview);
            f.setOpaque(true);
            f.setBounds(200, 400, 300, 50);
            f.requestFocus();
            return f;
    }And here is the Main class I also had to change to add the JComponent/layers
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.accessibility.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Main{
    public static void main(String[] args) {
             //Create and set up the window.
            JFrame frame = new JFrame("title");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane with all the classes
            Performance p = new Performance(3);
    // stringView and View draws up correctly here but NEVER repaints(have told it to repaint in another class)
            stringView s = new stringView(p);
            View v = new View(p);
            TextField f = new TextField(v, p, s);
            v.setBounds(0,0,500,500);
            JComponent newContentPane = new LayeredPane(p, s, v, f);
    // Here comes some desperate tries. . . .
            newContentPane.setEnabled(true);
            newContentPane.enable(true);
            newContentPane.setFocusable(true);
            newContentPane.setOpaque(true);
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
    }Offcorse it repaints as a JFrame do when I rezise the JFrame window with the mouse when the program is running. Thats why I also came up with the question: is it not possible to somehow make the framewindow change width/height with 1 px or something by a method call?
    Great thanks in advance!!

    Ok. I belive I might understand whats wrong.
    http://hem.bredband.net/hunter85/help.jpg
    Normaly when JPanels are directly connected to "Main" they are like mirrors and repaints(). But when added to a JLayeredPane() it�s the JLayeredPane() who needs to be repainted/updated/runned.
    Can someone please tell me if I�mcorrect or wrong about this to start with?

  • How to have constructor with arguments for controller?

    I would like to have the controller have arguments so that they can be a precondition for the object being constructed and not in setters to be added later on. This will reduce errors.
    Unfortunately, fxml only seems to take the no-arg constructor. Is there another way?
    Edited by: likejiujitsu on Apr 20, 2013 10:30 AM

    Here's perhaps a more realistic example. I have a Main.fxml file with a MainController. The event handler for a button in the Main.fxml file is going to load another fxml file (Dialog.fxml) and display the content in a dialog. The controller associated with Dialog.fxml (DialogController) is going to be initialized by passing a String into the constructor; that String value is retrieved from a text field in Main.fxml.
    Main.java:
    package example;
    import java.io.IOException;
    import javafx.application.Application;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Parent;
    import javafx.scene.Scene;
    import javafx.stage.Stage;
    public class Main extends Application {
      @Override
      public void start(Stage primaryStage) throws IOException {
        Parent root = FXMLLoader.load(getClass().getResource("Main.fxml"));
        primaryStage.setScene(new Scene(root, 400, 200));
        primaryStage.show();
      public static void main(String[] args) {
        launch(args);
    }Main.fxml:
    <?xml version="1.0" encoding="UTF-8"?>
    <?import javafx.scene.layout.VBox?>
    <?import javafx.scene.layout.HBox?>
    <?import javafx.scene.control.Label?>
    <?import javafx.scene.control.TextField?>
    <?import javafx.scene.control.Button?>
    <VBox xmlns:fx="http://javafx.com/fxml" spacing="10"
         fx:controller="example.MainController" fx:id="mainRoot">
         <HBox>
              <Label text="Enter text:" />
              <TextField fx:id="textField" />
         </HBox>
         <Button text="Show Dialog" onAction="#showDialog" />
         <!-- TODO Add Nodes -->
    </VBox>MainController.java:
    package example;
    import java.io.IOException;
    import javafx.fxml.FXML;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Parent;
    import javafx.scene.Scene;
    import javafx.scene.control.TextField;
    import javafx.stage.Modality;
    import javafx.stage.Stage;
    import javafx.util.Callback;
    public class MainController {
      @FXML
      private TextField textField;
      @FXML
      private Parent mainRoot;
      private final FXMLLoader dialogLoader;
      public MainController() {
        dialogLoader = new FXMLLoader(
            MainController.class.getResource("Dialog.fxml"));
        dialogLoader.setControllerFactory(new Callback<Class<?>, Object>() {
          @Override
          public Object call(Class<?> cls) {
            if (cls == DialogController.class) {
              return new DialogController(textField.getText());
            } else {
              try {
                return cls.newInstance();
              } catch (InstantiationException | IllegalAccessException e) {
                e.printStackTrace();
                throw new RuntimeException(e);
      @FXML
      private void showDialog() throws IOException {
        dialogLoader.setController(null);
        dialogLoader.setRoot(null);
        Parent dialogRoot = (Parent) dialogLoader.load();
        Scene scene = new Scene(dialogRoot, 300, 150);
        Stage dialog = new Stage();
        dialog.initModality(Modality.APPLICATION_MODAL);
        dialog.initOwner(mainRoot.getScene().getWindow());
        dialog.setScene(scene);
        dialog.show();
    }Dialog.fxml
    <?xml version="1.0" encoding="UTF-8"?>
    <?import javafx.scene.layout.VBox?>
    <?import javafx.scene.control.Label?>
    <?import javafx.scene.control.Button?>
    <?import javafx.scene.layout.HBox?>
    <VBox xmlns:fx="http://javafx.com/fxml" fx:controller="example.DialogController"
         fx:id="dialogRoot">
         <Label fx:id="label" />
         <HBox>
              <Button text="Click Me" onAction="#click" />
              <Button text="Close" onAction="#close" />
         </HBox>
    </VBox>DialogController.java
    package example;
    import javafx.fxml.FXML;
    import javafx.scene.Parent;
    import javafx.scene.control.Label;
    public class DialogController {
      private final String text;
      @FXML
      private Label label;
      @FXML
      private Parent dialogRoot;
      public DialogController(String text) {
        this.text = text;
      public void initialize() {
        label.setText(text);
      @FXML
      private void click() {
        System.out.println("Text is " + text);
      @FXML
      private void close() {
        dialogRoot.getScene().getWindow().hide();
    }Edited by: James_D on Apr 22, 2013 8:00 PM

  • How to set JTextField to show certain map scale (e.g. 1/2000)

    Hi,folks. I have a JTextField instance. How can I set the format to only allow user to only type the map scale(e.g. 1/2000). I can only use the JTextField component. Thank you in advance.

    I think the regex you're looking for is"1/[1-9]\\d*"Note that in the regex you posted"1[\\]\\d*"the closing bracket is quoted by the backslash, causing the error you mentioned. Not that you needed a backslash there anyways.
    You can try this, but note that since replace(...) invokes remove(...) and replace(...), pasting an apparently valid String will not succeed if the slash is part of the replacement. Also that setText or pasting are the only ways to set the initial content as you won't be able to type it in one character at a time.import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    import javax.swing.SwingUtilities;
    import javax.swing.text.AttributeSet;
    import javax.swing.text.BadLocationException;
    import javax.swing.text.PlainDocument;
    public class ScaleFactorTextField {
       public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
             @Override
             public void run() {
                new ScaleFactorTextField().makeUI();
       public void makeUI() {
          JTextField textField = new JTextField(10);
          textField.setDocument(new PlainDocument() {
             final Pattern p = Pattern.compile("1/[1-9]\\d*");
             @Override
             public void insertString(int offs, String str, AttributeSet a)
                   throws BadLocationException {
                String newText = getText(0, offs) + str +
                      getText(offs, getLength() - offs);
                if (isValidText(newText)) {
                   super.insertString(offs, str, a);
             @Override
             public void remove(int offs, int len) throws BadLocationException {
                String newText = getText(0, offs) +
                      getText(offs + len, getLength() - offs - len);
                if (isValidText(newText)) {
                   super.remove(offs, len);
             @Override
             public void replace(int offs, int len, String text,
                   AttributeSet attrs) throws BadLocationException {
                String newText = getText(0, offs) + text +
                      getText(offs + len, getLength() - offs - len);
                if (isValidText(newText)) {
                   super.replace(offs, len, text, attrs);
             private boolean isValidText(String text) {
                Matcher m = p.matcher(text);
                return m.matches();
          textField.setText("1/20000");
          JFrame frame = new JFrame();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.add(textField);
          frame.pack();
          frame.setLocationRelativeTo(null);
          frame.setVisible(true);
    }db

  • Jtable - partial text selection

    Hey all,
    I have a read-only table.
    Currently, when a user clicks on a cell, the whole cell is selected.
    I want to allow the user to select only a partial text in the cell - mainly for copy purposes.
    How can I achieve that?

    The trick (with Swing) is that the JTable must be enabled and you must register a custom Tableeditor that prevents the string from changing:
    public class SelectableTextTableTest {
        public static void main(String[] args) {
            DefaultTableModel notEditableModel = new DefaultTableModel(11, 5) {
                @Override
                public Object getValueAt(int row, int column) {
                    return "Column " + column + " / Row " + row;
                @Override
                public boolean isCellEditable(int row, int column) {
                    return false;
            JTable table = new JTable(notEditableModel) {
                @Override
                public boolean isCellEditable(int row, int column) {
                    return true;
            JTextField textField = new JTextField();
            textField.setEditable(false);
            table.setDefaultEditor(Object.class, new DefaultCellEditor(textField));
            JOptionPane.showMessageDialog(null, table);
    bye
    TPD

  • Getting ItemStateChanged from more than one form

    Is this a bug in the MOTOROKR E6 or am I missing something? Advice from experienced coders would be really appreciated.
    My MIDlet has to detect itemStateChanged for any item in the current form (Form1 or Form2 in the example) and update a ticker common to both the forms.
    Works fine in any emulator including MOTOROKR_E6_E6e emulator.
    Works fine in Sony Ericsson k700i even when built using Motorola SDK for Linux products.
    On MOTOROKR E6, after once changing to Form2 and back to Form1, Form1 no longer detects itemStateChanged when typing a new value in textField1.
    Please advise any workaround, I need to collect data from 2 forms, if I have to include all the fields on one form it would recult in unacceptable amount of scrolling down to get at the fields. The ticker has to be updated immediately when values are changed in either form.
    Code appended below, IDE used was NetBeans 5.5.
    Thanks in advance, Darryl
    * BugReport.java
    package BugReport;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    public class BugReport extends MIDlet implements CommandListener, ItemStateListener {
       public BugReport() {
           initialize();
       private Form form1;                    
       private Form form2;
       private Command exitCommand1;
       private Command exitCommand2;
       private Command screenCommand1;
       private TextField textField1;
       private TextField textField2;
       private Ticker ticker1;                  
       public void commandAction(Command command, Displayable displayable) {                   
           if (displayable == form2) {                    
               if (command == exitCommand2) {                  
                   getDisplay().setCurrent(get_form1());                      
                   form1.setItemStateListener(this);               
           } else if (displayable == form1) {
               if (command == screenCommand1) {                   
                   getDisplay().setCurrent(get_form2());                      
                   form2.setItemStateListener(this);               
               } else if (command == exitCommand1) {                    
                   exitMIDlet();                      
       private void initialize() {                     
           getDisplay().setCurrent(get_form1());                     
       public Display getDisplay() {                        
           return Display.getDisplay(this);
       public void exitMIDlet() {                        
           getDisplay().setCurrent(null);
           destroyApp(true);
           notifyDestroyed();
       public Form get_form1() {
           if (form1 == null) {                     
               form1 = new Form(null, new Item[] {get_textField1()});                      
               form1.addCommand(get_exitCommand1());
               form1.addCommand(get_screenCommand1());
               form1.setCommandListener(this);
               form1.setTicker(get_ticker1());                    
               form1.setItemStateListener(this);
           return form1;
       public Form get_form2() {
           if (form2 == null) {                     
               form2 = new Form(null, new Item[] {get_textField2()});                      
               form2.addCommand(get_exitCommand2());
               form2.setCommandListener(this);                    
               form2.setTicker(get_ticker1());
           return form2;
       public Command get_exitCommand1() {
           if (exitCommand1 == null) {                     
               exitCommand1 = new Command("Exit", Command.EXIT, 1);                     
           return exitCommand1;
       public Command get_exitCommand2() {
           if (exitCommand2 == null) {                     
               exitCommand2 = new Command("Back", "Back to Form1", Command.EXIT, 1);                     
           return exitCommand2;
       public Command get_screenCommand1() {
           if (screenCommand1 == null) {                     
               screenCommand1 = new Command("Form2", "Show Form2", Command.SCREEN, 1);                     
           return screenCommand1;
       public TextField get_textField1() {
           if (textField1 == null) {                      
               textField1 = new TextField("textField1 on Form1", null, 120, TextField.ANY);                      
           return textField1;
       public TextField get_textField2() {
           if (textField2 == null) {                      
               textField2 = new TextField("textField2 on Form2", null, 120, TextField.ANY);                      
           return textField2;
       public Ticker get_ticker1() {
           if (ticker1 == null) {                      
               ticker1 = new Ticker("Welcome");                      
           return ticker1;
       public void startApp() {
       public void pauseApp() {
       public void destroyApp(boolean unconditional) {
       // Everything works fine on any of the emulators
       // Tested and works fine on Sony Ericsson k700i
       //  Buggy omly on M0TOROKR E6
       public void itemStateChanged(Item item) {
           // Even this doesn't execute after returning to Form1 from Form2'
           ticker1.setString("Some Change");
           if (getDisplay().getCurrent() == form1) {
               // This works fine on first entry to Form1
               // but doesn't work after coming back to Form1 from Form2'
               ticker1.setString("Change in Form1");
           } else if (getDisplay().getCurrent() == form2) {
               ticker1.setString("Change in Form2");
    }

    OK guys, I've found my workaround.
    By using form.set(int itemNum, Item item) I'm able to reuse the same form and the problem doesn't arise.
    Hope my experience is useful to anyone who faces the same bug in any Motorola handset.
    Regards, Darryl

Maybe you are looking for

  • Cannot Delete BP Relationships in SAP CRM 7.0 - intermittent error

    Hi Everyone, We are running SAP CRM 7.0, SP08.  We are trying to delete just the relationship "Contact Person" between an Account and a Contact in CRM.  Sometimes when we do it everything works just fine and the relationship is removed in CRM and the

  • Hp mini 110 cnu9332tc2 enter current password

    HI..please help me with my HP mini 110 s/n {Personal Information Removed} p/n VJ924PA#UUF saying please enter current password..what can i do with this This question was solved. View Solution.

  • Offline / Online Re-Link Issue

    Having an issue using Premiere as an online/finish tool Received EDL's and XM'L's from the offline house. Also got consolidated color-corrected clips back from telecine. Clip A imported with the XML-------- Video In  00:00:30:08   Video out  00:00:31

  • Trouble with Burning and dragging music to playlist

    Hello, I have recently downloaded the new version of ITUNES and I am having some problems. One is I can't burn cd's. It's not that it wont let me, it's that the option doesn't exist. I've searched everywhere throughout Itunes, and cannot find out how

  • Error at  Cenvat Credit_J1IEX

    Dear Experts, Recently we have create new plant. A the time taken Cenvat credit through J1IEX Business area not copy automatically at header level under Excise Invoice  tab. please guide the where we have configured the same. So it will automatically