JLabel updating text

Hi,
I have a panel called BottomPanel that is used in three frames.
The same instance of BottomPanel is always used.
I want the BottomPanel to do the following, every 10 seconds to change the text of a JLabel to "current time is XX".
The issue I have is that when the JLabels.setText is invoked within the panel with the new text is not be shown in the panel.
I have tried calling revaliate and repaint and no luck.
I want the panel to handle this itself as it will be called from a number of frames.
A BottomPanelManager is called by the frames to get the BottomPanel (always the same instance).
Any help would be much appreciated
Cheers

You need to emulate Swing by creating a non-GUI model object to underlie the logic of this JPanel. Then create 3 new JPanels and have them all share the same model.
edit: for instance:
BottomPanelModel.java
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.swing.Timer;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
public class BottomPanelModel
  private static final int DELAY = 1000;
  private SimpleDateFormat sdFormat = new SimpleDateFormat("hh:mm:ss a");
  private int delay = DELAY;
  private Timer swingTimer = new Timer(delay, new TimerListener());
  private List<ChangeListener> changeListenerList = new ArrayList<ChangeListener>();
  public BottomPanelModel(int delay)
    this.delay = delay;
    swingTimer.setDelay(delay);
    swingTimer.start();
  public BottomPanelModel()
    this(DELAY);
  public void addChangeListener(ChangeListener cl)
    changeListenerList.add(cl);
  public String getTimeString()
    Date date = new Date(System.currentTimeMillis());
    return sdFormat.format(date);
  private class TimerListener implements ActionListener
    public void actionPerformed(ActionEvent arg0)
      ChangeEvent changeEvent = new ChangeEvent(BottomPanelModel.this);
      for (ChangeListener listener : changeListenerList)
        listener.stateChanged(changeEvent);
}BottomPanel.java
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
public class BottomPanel extends JPanel
  private BottomPanelModel model;
  private JLabel timeLabel = new JLabel();
  public BottomPanel(BottomPanelModel model)
    this.model = model;
    add(timeLabel);
    model.addChangeListener(new ChangeListener()
      public void stateChanged(ChangeEvent arg0)
        timeLabel.setText(BottomPanel.this.model.getTimeString());
}BottomPanelTest.java
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class BottomPanelTest
  private static final Dimension MAIN_SIZE = new Dimension(400, 600);
  private static final int BOTTOM_COUNT = 8;
  private JPanel mainPanel = new JPanel();
  public BottomPanelTest()
    mainPanel.setLayout(new GridLayout(0, 1));
    mainPanel.setPreferredSize(MAIN_SIZE);
    BottomPanelModel bpModel = new BottomPanelModel();
    for (int i = 0; i < BOTTOM_COUNT; i++)
      BottomPanel bPanel = new BottomPanel(bpModel);
      mainPanel.add(bPanel);
  public JComponent getPanel()
    return mainPanel;
  private static void createAndShowGUI()
    JFrame frame = new JFrame("BottomPanelTest Application");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(new BottomPanelTest().getPanel());
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  public static void main(String[] args)
    javax.swing.SwingUtilities.invokeLater(new Runnable()
      public void run()
        createAndShowGUI();
}Edited by: Encephalopathic on Jan 12, 2009 3:24 PM

Similar Messages

  • JLabel not updating text in GUI

    i've spent about an hour trying to get my label to update from another class. i set the label to public and i tried to invoke setText() on it from the other class, but it doesnt change it in the GUI. i printed the getText() method of the label and it's identical to what i tried to set it to be, but it just isnt displaying the correct text.
    i know to update in the GUI it needs to repaint itself, but this is automatic for setText() and it is working for the local calls to setText().
    i have a method
         public void setStatus(String text)
              status.setText(text);
         }that should do exactly what i want, but it only works when called from its own class..... HELP

    hey,
    just a little example...
    //first little class with the label in it! and a getter for the label.
    public class LabelPanel extends JFrame {
         private static  JLabel label;
         public LabelPanel(){
              initGUI();
         private void initGUI() {
              label = new JLabel("old text");
              JPanel panel = new JPanel();
              ButtonPanel buttonPanel = new ButtonPanel();
              panel.add(buttonPanel.getPane());
              panel.add(label);
              setContentPane(panel);
         public static void main(String[] args)
              // Schedule a job for the event-dispatching thread:
              // creating and showing this application's GUI.
              javax.swing.SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        createAndShowGUI();
          * Create the GUI and show it.
         private static void createAndShowGUI() {
              // Create and set up the window.
              JFrame frame = new LabelPanel();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setTitle("test");
              // Display the window.
              frame.pack();
              frame.setVisible(true);
            // gets the label
         public static JLabel getLabel() {
              return label;
    //second class just a button that changes the label
    public class ButtonPanel implements ActionListener{
         private JPanel pane;
         private JButton button;
         public ButtonPanel(){
              init();
         private void init(){
              button = new JButton("change");
              button.addActionListener(this);
              pane = new JPanel();
              pane.add(button);
         public void actionPerformed(ActionEvent e) {
              String cmd = e.getActionCommand();
              if(cmd.equals("change")){
                   button.setText("done");
                            //get the label and set the new text
                   LabelPanel.getLabel().setText("new text");
              }else if(cmd.equals("done")){
                   button.setText("change");
                            //get the label and set the new text
                   LabelPanel.getLabel().setText("old Text");
         public JPanel getPane() {
              return pane;
    }hope that helps!!! :)

  • JLabel update fails

    Hello,
    I'm having a problem with a JLabel update in our application.
    When performing setText on the JLabel, the text attribute is set but not always displayed (I know this because when I do a repaint of the whole frame, the JLabel is updated; but because the JLabel is updated frequently, I don't want to do the frame repaint every time for performance reasons).
    When the new text starts with a non-space character, the updates are displayed. When the new text starts with at least 3 space characters, the updates fail.
    A call to repaint() or revalidate() for the JLabel does not help! Also, this problem only occurs under Linux, in Windows we don't have this problem.
    Any solutions??
    Thanks in advance,
    Taaje

    I know that it is big enough because the updates work for some texts and the texts for which it does not work aren't longer than the other texts.
    I've just tried updateUI(), no change :-(
    I'm now trying to remotely debug the application step by step, running through the jre source code but since I'm not an expert this will take a while to understand...
    Thanks for the responses, any further help is welcome!
    Taaje

  • Problem with Update Text fields in Infoset

    Hi experts,
    Here i would like to rephrase the question. Normaly while working with Infosets, when press "update text fields" button, those fields having text is updated. But one of my field is not updated. I need some help from you for that.
    One more question i've that my field is having check table so i would like to know how exactly the text field is updated.
    scenario.
    Customized IT9320 has field prt_pos added. This field is having check table T528B. But i want text field to be attached is IT1000-STEXT.
    How this can be done, because i suspect that just using check table field IT1000-STEXT is not attached to IT9320-prt_pos.
    Please help. I'm really got stuck here.
    Thanks a lot,
    Toral.
    Hi,
    I'm working on customised Infotype. I need to add one new customised field ie Present Position. This field has number as well as text associated with it. There is a check table attached with this field so that text can be displayed alongwith number.
    I need this field in SAP/Adhoc query. But when i go to SQ02 this fields shows only value. Text is disabled for this field. I'm not sure why is it so.
    I looked into other infotype which as one field using same data element, and that field shows both value as well as text. Please help me to rectify this issue for present position field.
    Thanks,
    Toral.
    Edited by: Toral Sheth on Jul 4, 2008 2:01 PM

    You would be much better off with one multi-line form field.
    There are many problems with trying to determine when one is at the end of the display field with text entry.

  • SAP VB script for updating texts in purchase orders

    Hello,
    I am trying to create a SAP script for updating texts in purchase orders. It is in the last third - Item Detail,  Texts tab.
    The script is ok apart from the fact that it always deletes whatever text is in there and than add a new one.
    I would like to keep history in the texts tab and always just add one line to existing texts. Is there any way (command) how
    to keep existing texts and only add a new line to the top?
    Thanks a lot!
    Jan

    Yes, you are exactly right. I have already figured it out as well. I did not expect it would be that easy. But thanks a lot anyway for replying on this!
    Now I am struggeling with changing SAPLMEGUI in vb scripts for ME22n. Sometimes, there is SAPLMEGUI:0010 and sometimes SAPLMEGUI:0015. Even when the users have the same screens in the beginning the SAPLMEGUI number differs. They also do one item by hand and than it changes. It keeps changing between SAPLMEGUI:0010 and SAPLMEGUI:0015
    Is there a way how to have the same number of SAPLMEGUI or how to eliminate this issue?
    Thanks a lot
    Jan

  • Update text in creation mode ME21N

    Hi,
    How to update text in texts tab while creating PO .
    Thanks

    Hi,
    Have a look to OSS note :
    Note 432689 - ME21N: Changes to texts are not adopted.
    Regards
    Kiran Sure

  • Print Preview: SAP GUI showing updated text, CRM UI not showing updated text

    Hello,
    can anyone please help me with "Print Preview" button in CRM UI:
    In the CRM UI when a certain data is changed on the document, a note on the document is updated with changes in data. When pressing the "Print Preview" button the generated PDF is not showing an updated text. If i run the SmartForm directly in SAP GUI after the data change, the generated PDF shows an updated text. If i reload the CRM UI (close the browser and run the CRM_UI transaction) the "Print Preview" shows an updated text.
    What should i do, that the Print Preview in the CRM UI would also show an updated text (without reloading the CRM UI) ?
    Im thinking it could be a problem with the parameters SFPDOCPARAMS and SFPOUTPUTPARAMS, that are used when calling the SmartForm FM. The parameters are set as this:
       ls_outputparams-nodialog = 'X'.
       ls_outputparams-getpdf = 'X'.
       ls_outputparams-connection = 'ADS'.
       CALL FUNCTION 'FP_JOB_OPEN'
         CHANGING
           ie_outputparams = ls_outputparams
         EXCEPTIONS
           cancel          = 1
           usage_error     = 2
           system_error    = 3
           internal_error  = 4
           OTHERS          = 5.
       ls_docparams-country = 'SI'.
       ls_docparams-langu = sy-langu.
       CALL FUNCTION lv_name
         EXPORTING
           /1bcdwb/docparams  = ls_docparams
           I_HEADER_GUID      = ls_orderadm_h_wrk-guid
         IMPORTING
           /1bcdwb/formoutput = ls_formoutput
         EXCEPTIONS
           usage_error        = 1
           system_error       = 2
           internal_error     = 3
           OTHERS             = 4.
    SAP gurus, please help

    I figured the solution:
    In the Code Initialization of my interface (SFP transaction) i had to initialize the buffer:
       CALL FUNCTION 'INIT_LOAD_TEXT_BUFFER'
         EXPORTING
           EXCL_ID       = ls_stxh-tdid
           EXCL_LANGUAGE = ls_stxh-tdspras
           EXCL_NAME     = ls_stxh-tdname
           EXCL_OBJECT   = ls_stxh-tdobject
         EXCEPTIONS
           NOT_FOUND     = 1
           OTHERS        = 2.
    This way the text is loaded from the updated note every time a "Print Preview" button is pressed.

  • ITunes 12 - App update text missing

    I'm running Yosemite and iTunes 12.0.1.26 on a Macbook 13" Retina.
    Since upgrading to itunes 12+, the text that describes the update to any particular app is missing. Here's an example:
    Anyone know how to fix this?
    Thanks!
    Doug

    Same for me since itunes 12.0.1.26.
    Annoying.
    Found Feedback Link: https://www.apple.com/feedback/itunesapp.html
    Used Feedback Type: Downloading ...
    Subject: iTunes 12 - App update text missing
    What iTunes version are you running? Left on: Select itunes Version

  • Can BAPI_REQUIREMENTS_CHANGE  update text?

    can we use this BAPI to update long text for Planned dependent requirement?
    If it's possible, please advise the procedure.
    Otherwise, pls suggest if there is any function module to update text for this object.

    thank you !
    i set it DELKZ = 'X'.
    i run it! no change in result!

  • Updating text on a JButton

    is it posible to update text on a JButton before the actionPerformed method has completed??
    to put this into context if two buttons have been assigned names, by clicking on the button the names are displayed (as labels by saying button.setText(button.getName());. Can you then check if the names are the same, and if not set the labels to "?"

    Not quite sure I understand what you need, but is this any use?
    When the button is pressed, if it's name is not the same as it's text
    a "?" is shown, when released the text is restored.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class BronDali1
         public static void main(String[] argv)
              JButton btn1= new JButton("Button1");
              btn1.setName("Button1");
              JButton btn2= new JButton("Button2");
              btn2.setName("SomeButton");
              MouseListener listener= new MouseAdapter() {
                   private String text;
                   public void mousePressed(MouseEvent e) {
                        JButton btn= (JButton) e.getSource();
                        if (!btn.getText().equals(btn.getName())) {
                             text= btn.getText();
                             btn.setText("?");
                        else
                             text= null;
                   public void mouseReleased(MouseEvent e) {
                        JButton btn= (JButton) e.getSource();
                        if (text != null)
                             btn.setText(text);
              btn1.addMouseListener(listener);
              btn2.addMouseListener(listener);
              JPanel panel= new JPanel(new GridLayout(0,1));
              panel.add(btn1);
              panel.add(btn2);
              JFrame frame= new JFrame("BronDali1");
              frame.getContentPane().add(panel);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.pack();
              frame.setVisible(true);
    }

  • Warning trying to underline JLabel's text?

    Hello everyone. I've been trying to make the font of a JLabel underlined. I found this solution:Map map = myView.getMyJLabel().getFont().getAttributes();
    map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
    myView.getMyJLabel().setFont(new Font(map));However, I can't make this 2 warnings dissapear:
    Type safety: The method put(Object, Object) belongs to the raw type Map. References to generic type Map<K,V> should be parameterized.
    Type safety: The expression of type Map needs unchecked conversion to conform to Map<? extends AttributedCharacterIterator.Attribute, ?>
    I've also tried this:Map<TextAttribute, ?> map = myView.getMyJLabel().getFont().getAttributes();
    map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
    myView.getMyJLabel().setFont(new Font(map));But in this case I get the following error:
    The method put(TextAttribute, capture-of ?) in the type Map<TextAttribute, capture-of ?> is not applicable for the arguments (TextAttribute, Integer)
    Does anyone know how can I get rid of this warnings or maybe, a simpler way to underline a JLabel's text?
    Thanks in advance :)

    1) During field validation (data entry error by the
    user), the name of the field (via the registered
    label) is used in the error dialog
    2) During form validation (save button was
    clicked), required fields that are still blank are
    shown to the user in a dialog (again, using the text
    of the field's label).
    3) Required fields on the form get a red asterisk
    for the label's icon that get turned off after the
    field had been filled in. This is a requirement for
    us, but I gather not an uncommon one. The presenter
    informs the ui that a particular field
    isRequired(true/false). The ui looks up the label
    for that field and sets him to required(true/false),
    which will turn the asterisk icon on/off.
    In addition, we use JLabels for hyperlinks to other
    forms in our app. Yes, they are underlined. Perhaps
    not the best way to do it, but we subclassed JLabel
    to return the non-html text on the call to getText(),
    among other things.Ok, I think I get what you're talking about, but I think you're doingitwrong.com :P
    The view has two purposes in my book, 1) to take input data from user, and 2) to give output data to user. Some components like text fields do both. Labels on the other hand, only do output. So back in the model, you have a name of an input field, which you stick in the label after doing some hyperlinky/red-asterisky/whatever presentation stuff to it.
    IMHO, you should never be getting any data back from that view component. It's been tainted by transforming it for presentation. When you need to display that label's text elsewhere, you should go back to the model to get it, not the view. Only input data should come from the view. Since that label's output data, it should only ever go to the view.
    I'm trying to be insulting or anything, since I know that this is a pretty academic argument I'm making, and we all live in the Real World. I'm just really interested in all this. Now I'm off on a 4 day weekend to Dragon-Con, see you suckers later!

  • Not getting updated Text

    Hi,
    I have used CREATE_TEXT function module to create standard text which i am including in SAP Script using
    INCLUDE command.
    This script is attached to transaction PP40 now the problem i am facing is this Text is not getting updated even i change the Business Event , but i can see the updated text in SO10.
    Is it regarding Buffer refresh or Memory Refresh ?
    Can you please suggest me a way how to get the updated text in Script.
    Thanks & Regards,
    Amit Kade

    Hi Vijay,
    Thank you for your raply .
    I am getting the updated text in an Internal Table which i  am passing to CREATE_TEXT FM , and i can see the updated text in SO10 also but it's not reflecting in Script.
    I am using following Include statement ..
    INCLUDE ZTEXT1 OBJECT TEXT ID ST.
    Regards,
    Amit

  • Alter and update text from C#?

    Does anybody know if it's possible to alter and update text from C#?
    I've added a reference to Interop.Illustrator.dll COM type library and managed to cobble together have this bit of code
                Illustrator.Application app = new Illustrator.Application();
                Illustrator.Document doc = app.Open(
                    "c:\\MyIllustratorDoc.ai",
                    Illustrator.AiDocumentColorSpace.aiDocumentRGBColor,
                    null);
                foreach(Illustrator.TextFrame textFrame in doc.TextFrames)
                    Console.Write(textFrame.Contents);
    which just dumps out the contents of all the TextFrames but from the documentation I've found, Contents and everything else that gives access to any text, is read only.
    I was hoping to be able to automate the maintenance of various bits of text by picking them up from SQL Server and then amending them directly in the ai file where needed.  Any help would be greatly appreciated.
    Cheers,
    Tim

    Hi,
    IPQ-2007-08-20 YES is in 1 field ..
    At first is only 'IPQ-2007-08-20' in that field RM06I-LTEX2 now user want to fully utilize this long text field. so want to add something at RHS of this field.
    You may refer this link to get clearer idea, what is the user want.
    <a href="http://allyoucanupload.webshots.com/v/2003186583194973129">[IMG]http://aycu16.webshots.com/image/37295/2003186583194973129_rs.jpg[/IMG]</a>
    How should I insert 2 column of data (eg 'IPQ-2007-08-20'  and 'YES' ) into this 1 field (RM06I-LTEX2) without overwrite each other?
    Message was edited by:
            Peai Chun Ong

  • Updating text in a JLabel dynamically

    hi all
    I have a JTextField and a JLabel. Both of them should have the same text at all times. I want to type/change text in the JTextField and changes should be seen immediately in the JLabel. I do not want to press the enter key to see the changes. Change should be instantaneous. I used a KeyListener to listen to KeyEvents(key typed events), I think that is the right way, but I am not able to get it to work. If someone has already worked on similar lines, plz help me with code or suggestions.
    thanks a lot
    Mahesh :)

    Well keyTyped and keyPressed both wont work if the result required is immediate.
    import java.awt.event.*;
    import javax.swing.*;
    public class Test extends JFrame{
         class IvjEventHandler implements KeyListener {
              public void keyReleased(KeyEvent e){
    if (e.getSource() == text)
                   label.setText(text.getText());
              public void keyPressed(KeyEvent e){}
              public void keyTyped(KeyEvent e) {}
         IvjEventHandler ivjEventHandler = new IvjEventHandler();
         private JLabel label = null;
         private JTextField text = null;
         public Test() {
              super();
              setSize(250, 100);
              JPanel panel     = new JPanel();
              panel.setLayout(null);
              label     = new JLabel();
              label.setText("Check Me Out");
              label.setBounds(10, 25, 75, 25);
              panel.add(label);
              text     = new JTextField();
              text.setBounds(100, 25, 75, 25);
              panel.add(text);
              setContentPane(panel);
              text.addKeyListener(ivjEventHandler);
         public static void main(String args[]){
              Test aTest     = new Test();
              aTest.setVisible(true);
    cheers
    Happy Coding

  • Help!  Using GUI button to update text file

    Desperately needing help on the following:
    As you will see, I have created two classes - one for reading and writing to a text file on my hard drive, and one for the GUI with two buttons - Display and Update. The Display button works perfectly in that it displays text from a file path. The Update button, however, does not work correctly. I seek for the Update button to update any edits to the same exact text file I view using the Display button.
    Any help would be greatly appreciated. Thanks!
    Class TextFile
    import java.io.*;
    public class TextFile
        public String read(String fileIn) throws IOException
            FileReader fr = new FileReader(fileIn);
            BufferedReader br = new BufferedReader(fr);
            String line;
            StringBuffer text = new StringBuffer();
            while((line = br.readLine()) != null)
              text.append(line+'\n');
            return text.toString();
        } //end read()
        public void write(String fileOut, String text, boolean append)
            throws IOException
            File file = new File(fileOut);
            FileWriter fw = new FileWriter(file, append);
            PrintWriter pw = new PrintWriter(fw);
            pw.println(text);
            fw.close();
        } // end write()
    } // end class TextFileClass TextFileGUI
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    public class TextFileGUI implements ActionListener
        TextFile tf = new TextFile();
        JTextField filenameField = new JTextField (30);
        JTextArea fileTextArea = new JTextArea (10, 30);
        JButton displayButton = new JButton ("Display");
        JButton updateButton = new JButton ("Update");
        JPanel panel = new JPanel();
        JFrame frame = new JFrame("Text File GUI");
        public TextFileGUI()
            panel.add(new JLabel("Filename"));
            panel.add(filenameField);
            panel.add(fileTextArea);
            fileTextArea.setLineWrap(true);
            panel.add(displayButton);
            displayButton.addActionListener(this);
            panel.add(updateButton);
            updateButton.addActionListener(this);
            frame.setContentPane(panel);
            frame.setSize(400,400);
            frame.setVisible(true);
        } //end TextFileGUI()
        public void actionPerformed(ActionEvent e)
            if(e.getSource() == displayButton)
                String t;
                try
                    t = tf.read(filenameField.getText());
                    fileTextArea.setText(t);
                catch(Exception ex)
                    fileTextArea.setText("Exception: "+ex);
                } //end try-catch
            } //end if
            else if(e.getSource() == updateButton)
                try
                  tf.write(filenameField.getText());
                catch(IOException ex)
                    fileTextArea.setText("Exception: "+ex);
                } //end try-catch
            } //end else if
         } //end actionPerformed()
    } //end TextFileGUI

    Here's your working example.
    In my opinion u do not have to append \n when u reading the file
    Look the source, if u have some problem, please, ask me.
    Regards
    public class TextFileGUI implements ActionListener
    TextFile tf = new TextFile();
    JTextField filenameField = new JTextField(30);
    JScrollPane scrollPane = new JScrollPane();
    JTextArea fileTextArea = new JTextArea();
    JButton displayButton = new JButton("Display");
    JButton updateButton = new JButton("Update");
    JPanel panel = new JPanel();
    JFrame frame = new JFrame("Text File GUI");
    public static void main(String args[])
    new TextFileGUI();
    public TextFileGUI()
    panel.setLayout(new BorderLayout());
    JPanel vName = new JPanel();
    vName.setLayout(new BorderLayout());
    vName.add(new JLabel("Filename"), BorderLayout.WEST);
    vName.add(filenameField, BorderLayout.CENTER);
    panel.add(vName, BorderLayout.NORTH);
    scrollPane.setViewportView(fileTextArea);
    panel.add(scrollPane, BorderLayout.CENTER);
    fileTextArea.setLineWrap(true);
    JPanel vBtn = new JPanel();
    vBtn.setLayout(new FlowLayout());
    vBtn.add(displayButton);
    displayButton.addActionListener(this);
    vBtn.add(updateButton);
    updateButton.addActionListener(this);
    panel.add(vBtn, BorderLayout.SOUTH);
    frame.setContentPane(panel);
    frame.setSize(400, 400);
    frame.setVisible(true);
    } // end TextFileGUI()
    public void actionPerformed(ActionEvent e)
    if (e.getSource() == displayButton)
    String t;
    try
    t = tf.read(filenameField.getText());
    fileTextArea.setText(t);
    catch (Exception ex)
    ex.printStackTrace();
    else if (e.getSource() == updateButton)
    try
    tf.write(filenameField.getText(), fileTextArea.getText(), false);
    catch (IOException ex)
    ex.printStackTrace();
    } // end try-catch
    } // end else if
    } // end actionPerformed()
    } // end TextFileGUI
    class TextFile
    public String read(String fileIn) throws IOException
    String line;
    StringBuffer text = new StringBuffer();
    FileInputStream vFis = new FileInputStream(fileIn);
    byte[] vByte = new byte[1024];
    int vPos = -1;
    while ((vPos = vFis.read(vByte)) > 0)
    text.append(new String(vByte, 0, vPos));
    vFis.close();
    return text.toString();
    } // end read()
    public void write(String fileOut, String text, boolean append) throws IOException
    File file = new File(fileOut);
    FileWriter fw = new FileWriter(file, append);
    PrintWriter pw = new PrintWriter(fw);
    pw.println(text);
    fw.close();
    } // end write()
    } // end class TextFile

Maybe you are looking for

  • BPS and attributes change

    Hi, I'm currently working on BI-IP with planning function "Repost on Basis of Characteristic relationship" and it works well but i would like to know if there's something like this in BPS. Some old projects are in BPS and there are some derivation by

  • Expected End Of Statement Error

    I created an SQL statement which runs fine in MS-SQL2000. I paste the code in a DW 8 recordset that I create and run a test to make sure it works. No problem. Returns resutls as expected. I can also access the fields in the recordset. When I test the

  • Need help on accessing transaction?

    Hi, I am doing an SOD audit and come across one role where the user is given authorization to ME21N (create purchase order) for example in auth object S_TCODE. But he has been given display (and not create) authorization in Document Type in Purchase

  • Extract group owners from group

    How can you extract group owners from a group? ver. 3.0.9.8.5. I want to do two things; extract all groups that a user is the owner of, and find all the owners of a group. The code below will extract out all the users of a group, but how do you get t

  • The menu button is not working on my iPod Nano

    I cannot get back from anywhere. Once I have seleceted a track to play, the menu button does not work so that I cannot get back to all music or to choose other options such as radio. It does not make a click sound. It works occaisionally (once a week