Unable to clear text Field in Multi Screen JFrame GUI Application

i am working with a Swing GUI project where I want to accept user input in a
text field
I have used singleton pattern which will create only one instance of object
due to this when i move from one scree to another the input of textfield
doesnt updated I have used setText method to clear the JTextField but it wont
works
Program one -- 1st screen
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.event.*;
import javax.swing.JTextField;
public class Frame1 extends JFrame
public static Frame1 frame1;
public JButton button;
public JTextField input;
public static Frame1 getInstance()
if(frame1==null)
frame1 = new Frame1();
return frame1;
public JButton getJButton(String mytext)
JButton button = new JButton();
button.setText(mytext);
button.setBounds(450,450,150,50);
return button;
public void myGUI()
JPanel panel = new JPanel();
panel.setLayout(null);
button = getJButton("1st Frame");
addActionListener(button);
input = new JTextField(10);
input.setBounds(200,300,100,30);
panel.add(input);
panel.add(button);
add(panel);
setUndecorated(true);
setSize(1024, 768);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
public void addActionListener(Object obj)
try{
JButton button1 = (JButton)obj;
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae)
String text = "";
input.insert("", 0);
Frame2.getInstance().myGUI();
Frame2.getInstance().repaint();
dispose();
catch(Exception e1)
System.out.println("Exception==> "+e1.toString());
public static void main(String[] args)
Frame1.getInstance().myGUI();
Frame1.getInstance().repaint();
program 2 - 2nd screen
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.event.*;
import javax.swing.JTextField;
public class Frame2 extends JFrame
static Frame2 frame2;
public JButton BackButton;
public JTextField input;
public static Frame2 getInstance()
if(frame2==null)
frame2 = new Frame2();
return frame2;
public JButton getJButton(String mytext)
JButton button = new JButton();
button.setText(mytext);
button.setBounds(450,450,150,50);
return button;
public void addActionListener(Object obj)
try{
JButton BackButton1 = (JButton)obj;
BackButton.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent ae)
input.setText("");
Frame1.getInstance().myGUI();
Frame1.getInstance().repaint();
dispose();
catch(Exception e2)
System.out.println("Exception==> "+e2.toString());
public void myGUI()
JPanel panel2 = new JPanel();
panel2.setLayout(null);
BackButton = getJButton("2nd Screen");
addActionListener(BackButton);
input = new JTextField(10);
input.setBounds(200,300,100,30);
panel2.add(input);
panel2.add(BackButton);
add(panel2);
setUndecorated(true);
setSize(1024, 768);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
In this application the status of TextField input remain same means it shows
the earlier input in the textfield wnen I come to earlier or next screen.
what is the solution to clear the TextField input while moving from 1st
scrren to 2nd screen.

multiple screens = multiple posts
well done indeed - just another farking cross-poster
[http://www.coderanch.com/t/492998/Swing-AWT-SWT-JFace/java/unable-clear-text-box-Multi#2218566]

Similar Messages

  • What is the Table name & Field Name for Clearing text field in F-53 Transac

    Hi,
    I need prepare a functional specification for Clearing text field in Check Register.I am not able to find the Table name and Field Name for Clearing text field in F 53 transaction code.Kindly provide me the Table and filed name.so that i can proceed.Kindly help me.
    I will assign points.
    Thanks
    Sunitha

    Hi
    From the payment document you have to link to the clearing document (Number BSEG-AUGBL, same Fiscal year and Company Code) in the clearing document the text entered in the transaction can be found on item text (BSEG-TEXT).
    RF05A is a Structure name
    Ranga
    Edited by: Ranga Swamy on Dec 4, 2008 7:55 PM

  • JFileChooser as save dialog clears text field on change directory

    I am trying to implement a basic save dialog using JFileChooser, which initiates with an initial file name, "untitled.txt". However, as soon as the directory is changed by the user, the text field is cleared. I want to ensure that whatever is in the text field when the user changes directories (i.e., untitled.txt may have been changed to something else by the user) stays visible throughout any kind of user navigation. I've tried all sorts of things, but nothing seems to work.
    Thanks for your help.

    Yes, it very well could be an OS/JDK issue. I'm using jdk 1.5 on Mac OS X (Tiger). Apparently, FileNameExtensionFilter is a jdk 1.6 implementation, because it doesn't work for me.
    Here's my code:
    JFileChooser fc = new JFileChooser();
    String output = outputTextArea.getText();
            String selectedFile = "untitled.txt";
            File file = new File(selectedFile);
            fc.setDialogTitle("Save");
            fc.setMultiSelectionEnabled(false);
            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            fc.setSelectedFile(file);
            setFileName(file.getName());
            int result = fc.showSaveDialog(this);
            if (result == JFileChooser.CANCEL_OPTION) {
                return;
            } else if (result == JFileChooser.APPROVE_OPTION) {
                file = fc.getSelectedFile();
                if (file.exists()) {
                    int response = JOptionPane.showConfirmDialog(null,
                            "Overwrite existing file?","Confirm Overwrite",
                            JOptionPane.OK_CANCEL_OPTION,
                            JOptionPane.QUESTION_MESSAGE);
                    if (response == JOptionPane.CANCEL_OPTION) return;
                if (!writeFile(file, output)) {
                    setErrorMessage(ERROR5_1); //Just a custom error message and display.
                    showErrorMessage();
                    return;
            }Is there a workaround if this is an OS or JDK issue?
    Thanks again for your help.

  • Clearing text field

    Hi,
    I have a page where you scan a barcode into a text field submits when enter pressed. If the barcode exists a report appears showing that record. The barcode must stay in the text field.
    My question is if I scan a barcode and the barcode does not exist and then I scan another barcode, the previous barcode stays and gets appended onto the new barcode. How do I clear the barcode data out of the text field when I scan in a new barcode?

    Hi,
    Add something like the following into the report region's Region Footer setting:
    <script type="text/javascript">
    if (#ROWS_FETCHED# == 0)
    $x("P36_BARCODE").value = "";
    </script>Replacing P36_BARCODE with the actual name of the barcode field.
    #ROWS_FETCHED# is populated with the number of rows fetched on the page for the report. If this is 0 (zero), then the script will run, and the field will be cleared.
    Andy

  • Clearing text field after query

    I have seen alot of old post on this but no answers, I am wondering if anyone knows how to accomplish clearing a text field after a query has been executed?
    Example:
    User types a query in the search field, clicks submit then the query is returned and the search field is empty again ready for the next query.

    I tried that and I was getting "(null)" in the value of the column I queried.
    This is what I came up with and it seems to be working. In the Page Definition click Edit Attributes and add this line to the On Load section:
    onload="html_GetElement('PX_SEARCH').value=''; html_GetElement('PX_SEARCH').focus()"That will clear the field and focus the cursor in the same field so its ready for another query.

  • To increase the font size of the text field on the screen

    Hi Experts,
    I have created a new screen , but there is a requirement to increase the size of the text field , so that they are visible even if the user is far from these system.
    Please let me know if this can be done.
    Thanx,
    Sunitha
    Edited by: sunitha j on Aug 18, 2008 10:13 AM

    >
    sunitha j wrote:
    > Hi ,
    >
    > It would br gr8..if u could give some more info about the usage of this class..i mean if i hav to implement it in my program....wat is the necessary data that needs to b copied...
    >
    > Thanx,
    > Sunitha
    what Text field you want to change.
    Since you are working with Dynpros , you have to split the screen in two parts, and one for the Showing differenet fonts and other your normal Dynpro information.
    you need to use the Method ADD_TEXT Did you check the program DD_STYLE_TABLE.

  • Populating Text Field from Multi Checkboxes

    Need help with formula.  Not sure whether or not I should be using FormCalc or Javascript as I am not extremely familiar with either.  I have a form that has three checkboxes (Box1, Box2, & Box3) that need to auto populate a text field (EmpAck).  I have tried three different ways to get this done and none are working for me.  What I need to happen is if "Box1" is checked "Text1" is inserted in "EmpAck" field and if "Box2" is checked "Text2" is instered & so on.  The texts are never the same and never added together.  I have set "EmpAck" to be read only, allowing multiple lines, and have the "Expand to fit box marked as the texts' are different lengths.  Any help would be great.
    1. // This would go in the Textfield under calulate using FormCalc
    if (Box1 = "On") then
    EmpAck = "Text1"
    elseif (Box2 = "On") then
    EmpAck = "Text2"
    elseif (Box3 = "On") then
    EmpAck = "Text3"
    endif
    2. //This would go in the checkbox "Box1" changing "Text1" to "Text2" or "Text3" as required under mouseup using JavaScript (found under http://forums.adobe.com/message/2489082#2489082)
    if (this.rawValue == 1)
    {EmpAck.rawValue = "Text1";}
    else {EmpAck.raqValue = " ";}
    3.//This would go in textfield under calcuate using JavaScript (found under http://forums.adobe.com/message/4108395#4108395)
    var a =" "
    if (this.getField(Box1).value == "Yes")
    {a="Text1"}
    if (this.getField(Box2).value == "Yes")
    {a="Text2"}
    if (this.getField(Box3).value == "Yes")
    {a="Text3"}
    event.value=a

    Found my problem.  Was using different subforms without including in the formula.

  • How to Multi-Screen android tablet application on Adobe AIR and Flash Professional

    hello,
    I have done app in ipad with Adobe AIR thats work fine in ipad,
    but now i have to create android tablet app for multiscreen resolution like this,
    2560*1600, 1366*768, 1280*800, 1280*768, 1024*768, 1024*600, 960*640, 960*540, 854*480, 800*600, 800*480, 800*400
    and my current .fla file resolution is 1024*768 so how can i create android tablet app with multi-screen?
    thanks

    If your app is mainly code layout interface, then you'll have to just change your code to work with arbitrary widths and heights, instead of a fixed width and height. If instead your app is basically one graphical scene, like say Angry Birds, or a highly graphical scene, you could take the approach I use.
    Read my reply to this message:
    http://forums.adobe.com/message/4735070?tstart=0
    In that message I describe things in Portrait, because I was answering a question about portrait, but it all works out too if you substitute landscape numbers.

  • Text field with autocomplete: little bug in application builder

    Hi,
    I just noticed that the application builder complains when a text field with autocomplete is defined with a named LOV containing a single column value (Apex 4.0.2.00.06).
    I created the text-field with a dynamic LOV (please specify in the docs that autocomplete requires single column queries!), then I used the "Convert to named LOV" task link to convert it to a named LOV and it works perfectly, however as soon as you attempt to change some other attribute for the item, it will throw the following error:
    1 error has occurred
        Using a named list of values (LOV) is only supported for item types which require at least two LOV columns.As i said, the named single column LOV works just fine with the autocomplete, so the error message seems to be also misleading.
    Flavio
    http://oraclequirks.blogspot.com
    http://www.yocoya.com

    Hi Surya,
    the "Text Field with autocomplete" is really just an autocomplete widget and doesn't behave like a LOV. But we are planning to release an item type plug-in which solves both of your requirements.
    Regards
    Patrick
    My Blog: http://www.inside-oracle-apex.com
    APEX 4.0 Plug-Ins: http://apex.oracle.com/plugins

  • How to clear text fields when the user navigates back to the screen

    Hi,
    Does anyone have any idea on how to clear the text input fields and dropdown boxes when the user navigates back to the screen, say for e.g. create screen?
    My issue is that i have plenty of fields in the create screen within a form. Is there a way to avoid programaticaly blanking out every field and just do it at the form level using an api to reset to a state before the user entry?
    Thanks

    This code allows you to make it more generic, and you would need to tweak it if there are more than TextInput controls, but it should provide some ideas.
    As far as using states, you could use SetProperty to set the text to empty, but that might be messier.
    <?xml version="1.0"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
      <mx:Script>
        <![CDATA[
          import mx.containers.FormItem;
          import mx.controls.TextInput;
          import mx.events.IndexChangedEvent;
          import mx.core.Container;
          private function clearSreen(evt:IndexChangedEvent):void{
            var view:Container = tn.selectedChild as Container;
            for each(var child:Object in view.getChildren()){
              if(child is FormItem){
                var subchild:DisplayObject = child.getChildAt(0);
                if(subchild is TextInput){
                  TextInput(subchild).text = "";
        ]]>
      </mx:Script>
      <mx:TabNavigator id="tn" resizeToContent="true"
        change="clearSreen(event)">
        <mx:Form id="frm1" label="View Number One">
          <mx:FormItem label="First name:">
            <mx:TextInput/>
          </mx:FormItem>
          <mx:FormItem label="Last name:">
            <mx:TextInput/>
          </mx:FormItem>
        </mx:Form>
        <mx:Form id="frm2" label="View Number Two">
          <mx:FormItem label="Address1:">
            <mx:TextInput/>
          </mx:FormItem>
          <mx:FormItem label="Address2:">
            <mx:TextInput/>
          </mx:FormItem>
          <mx:FormItem label="City:">
            <mx:TextInput/>
          </mx:FormItem>
          <mx:FormItem label="State:">
            <mx:TextInput/>
          </mx:FormItem>
          <mx:FormItem label="Zip code:">
            <mx:TextInput/>
          </mx:FormItem>
        </mx:Form>
      </mx:TabNavigator>
    </mx:Application>
    If this post answers your question or helps, please mark it as such. Thanks!
    http://www.stardustsystems.com
    Adobe Flex Development and Support Services

  • Field Length of the text field on the screen

    Hello Experts,,
    I have field with its label on the screen. Now the label text is picked up from data dictionary as defined.
    Data element       J_3ARQDA                       Active
    Short Description:  Requested delivery date
    Length           Field   Label
    Short             10       RqDlv.date
    Medium         16       Req.deliv.date
    Long              20      Requested deliv.date
    Heading         5        Dldat
    Now the text in different laguage say russian is quite bigger in length as compared to english ones. Now on the sales order screen i have the text 'Dldat', but the russian user needs a bigger word than just 'Dldat'.
    Approach :  I changed the heading length to some '25' from '5' to accomedate the russian text in DDIC for data element. But if i have to adjust the same on the screen with new text length i have to extend the screen border as well.
    Is this right approach ? If not how do we actually accomedate the other language texts on the screen with out altering the screen borders ( length and breadth).

    Hi Radhika,
      I tried doing that with a couple of invoices but I dont see the Long text printed on the check after the automatic payment run. Can you please suggest me if I am missing on anything. I inserted a long text and a '*" before this to have it printed on the check which does not seem to work. Can you please suggest me alternative solution.
       Thanks in advance.
    Ramya

  • How to clear the fields of the screen ?

    Hi,
    I'm having two fields for selection..when i press enter after entering some values,based on that my table control will get filled up..and when i double -click on that row in table control i get all the values of that row in the respective fields in my tabstrip..all these r in same screen 100..and in tabstrip i have 5 tabs with 5 subscreens..containing the fields of table control..now that when i enter a value in the selection screen fields..my table control is getting added with a second row of values as required..but my problem is that the values of the tabstrip should get cleared..this is not happening..i wrote logic like if my tablecontrol is getting appended the values from tabstrip should get cleared..all the fields are getting cleared except the fields of tab which is active..how to do it..

    Hi,
    Try this out.
    declare a variable in Top Include
    data : appended type c.
    if the appending to the internal table is success means sy-subrc = 0
    make appended = 'X'.
    go to the PBO of subscreen of the tab where you want to clear the data
    if appended = 'X'.
    clear appended.( this is must otherwise for every call of the subscreen of this tab the values get cleared)
    here clear the value of the subscreen of the tab strip)
    endif.
    The same can be achieved using the OK_CODE also
    Regards
    Ramchander Rao.K

  • Unable to select a field in Datasource screen

    Hi Gurus,
    I am trying to change a datasource by including another field (by checking the selection field) but am unable to do it as its disabled. however the hide field can be editable and is unselected at the moment.
    How can i enable the selection box for this field and check it?
    Thanks in advance
    S N

    Hi San
    Thanks for your quick reply.
    I have checked the field and it hasnt got any value in the SELECTION field (its just blank). Some of the other fields have got 'X'.
    The OBJVERS for this particular field is A. However there is another occurance of the same field with OBJVERS as D.
    Anymore suggestions as to how i can enable and select this field in my Datasource.
    Thanks
    S N

  • Unable highllight the text in the multi-line text item in forms11g

    Hi,
    I using forms11g and I have a foirm which have a multilline field which are not hinghlighting the text when the cursor come there but it works fine in forms6i.
    Any solution on this will highly appriciated.

    I using forms11g and I have a foirm which have a multilline field which are not hinghlighting the text when the cursor come there but it works fine in forms6i.Check your Forms 6i form. I'll bet you have a Current Record Visual Attribute property assigned and you missed assigning this in Forms 11g. If it is assigned, double-check the Visual Attribute (VA) group exists and/or make sure all the VA attributes are valid for Forms 11g.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Need to add new Text Field on the Screen

    Hi,
    I am using Oracle 9 Designer and generating the web pages using web pl/sql language. After I generate the page, my screen looks like this:
    Employee id: TextField
    Employee Name: TextField
    I want to add a comment"(Please enter characters Only" below the Employee ID like the following:
    Employee id : TextField
    (Please enter characters Only)
    Employee Name: TextField
    Can anybody help me how to add this in the designer form?
    thanks in advance.

    You can do this with an unbound item on a View Form. You cannot do it at all for an Insert Form. There is a work around but takes a little explaining for the Insert Form. You need to create a web page from the insert form html, modify it manually. I do it as a simple procedure so it is consistent with the rest of the application. Then all menus, links, etc. need to reference that page instead of the FormInsert procedure in the generated package.
    There may be other work arounds. Without knowing more about your requirements, I can't say.
    John Caputo
    [email protected]

Maybe you are looking for

  • Error while creating the USER in UME

    Hi Experts, I'm having NW 7.1 SP05 JAVA Engine and SAP MII 12.1 is running on NW. I'm having the Super Admin Role and trying to create the new user in UME,but I'm getting the error while doing so. The complete error trace is as below: "Error Creating

  • Issue With Payment Proposal.

    Hello Experts, When I am running proposal,I am facing the message " Payment Proposal Could not be carried Out". Could you please guide me what it means? Thanks, Bala

  • DBMS_LOB IN ORACLE 8i TRIGGER

    Hello friends; I'm working with oracle 8i This is my TABLE CREATE TABLE PROBCLOB ( CAMPO1 CLOB, CAMPO2 NUMBER(1) ); This is my TRIGGER CREATE OR REPLACE TRIGGER PROBANDO BEFORE INSERT ON PROBCLOB FOR EACH ROW DECLARE cCAMPO CLOB; nNUM NUMBER( 10 ); B

  • Saving Location @ Adobe Acrobat XI Pro

    If you open a document with Adobe Acrobat X Pro and sign it, than the Software wants to save the document on the same place, like you opened it. In Adobe Acrobat XI Pro the software wants to save it on an other place. Do anybody know this issue and i

  • HT1918 I changed the card and i want to know how make to change the data from itunes. I tried and doesn't work.

    I changed the card and i want to know how make to change the data from itunes. I tried and doesn't work. Please, Help Me!