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);
}

Similar Messages

  • 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.

  • Simple layout issue: positioning text atop a JButton image

    (I apologize for the cross-post; I assumed that this forum was for relatively advanced Swing topics, and therefore initially posted this question in the "New to Java Technology" forum.)
    I've got a newbie Swing problem that I just can't seem to figure out. Basically, I'd like to place text for a JButton in a certain location within the image I'm using for the button. If I use the following code:
    String buttonText = MyStringFactory.getString();
    JButton myButton = new JButton(buttonText, new ImageIcon("myimage.png"));
    myButton.setHorizontalTextPosition(SwingConstants.CENTER);
    myButton.setVerticalTextPosition(SwingConstants.CENTER);The text will display within the button, but it will be exactly centered atop the image. What I'd like is to have the text displayed on top of the image, but to be left-aligned. So, instead of:
    |        Test        |
    ----------------------I want:
    | Test               |
    ----------------------Where the image behind the word "Test" is the image specified when I created the myButton JButton object. The string can be of varying length and must support various fonts (i.e., simply using a monospaced font and padding on the right-side of the string with spaces isn't an option). In more explicit terms, what I want is a way to center the text vertically with respect to the background image, and place it (the text) X pixels from the left-hand side of the background image.
    I've looked at using OverlayLayout to solve this problem, creating a JButton and a JLabel and placing them both within a JPanel. However, when I do this, the JLabel is always rendered behind the JButton, so I can't see it. Is there any way to specify the z-ordering of objects in a JPanel when using OverlayLayout?
    Or is there a much simpler solution to this (seemingly) simple problem?
    Thanks in advance for any assistance!

    hello guy,
    well, you seem to want your text to be in a very specific position since you mention x pixels.
    i don't think you can tell a JButton where exactly to draw the text and icon.
    if you want to do that, you'll have to create you own button.
    something like that:
    class CustomButton extends JButton {
    String text;
    ImageIcon icon;
    public CustomButton(String text, ImageIcon icon) {
    // only use the default constructor of the JButton
    // and save the text and icon separately
    super();
    this.text = text;
    this.icon = icon;
    // set some preferred size so that the layout
    // manager has some idea of how big your button will be
    this.setPreferredSize(new Dimension(
    icon.getIconWidth(),
    2*icon.getIconHeight()));
    // override paintComponent()
    public void paintComponent(Graphics g) {
    // first call this method in the super class
    // this will draw your button color, outline, borders..
    super.paintComponent(g);
    // now draw your icon whereever you want it on
    // your button
    g.drawImage(icon.getImage(),5,
    getHeight()/2-icon.getIconHeight()/2,null,this);
    // and draw your string.
    // using FontMetrics to get the dimensions of your
    // string will allow it to be independent of
    // font type and size
    g.drawString(text, icon.getIconWidth()+10,
    getHeight()/2+g.getFontMetrics().getAscent()/2);
    hope that helps a bit :)
    cheers, alex.

  • 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!

  • 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

  • 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!!! :)

  • 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

  • Text won't print on Canon LBP5050 after software update, Text won't print on Canon LBP5050 after software update

    I'm running OSX, 10.6.7 on a Mac mini and on a macbook pro. Since I've run an update, neither of them will print text, only pictures, on my Canon LBP5050 printer (which I bought from Apple). I've checked the drivers, and I'm already using the latest. I've reset the print process and that had no effect either. Anyone got any ideas? It rather makes the printer useless.
    Thanks,
    Ariane

    Solution found! Delete old printer driver, restart machine then go to http://support-au.canon.com.au/contents/AU/EN/0900772205.html
    With the CAPT driver installed, to add the printer, you do need to click the More Printers button. This will be located in the bottom left hand corner of the Add Printer browser.
    Restart machine again and turn printer on, hopefully then you'll be able to print text and images without any problems at all! works for me and I'm on a Macbook Pro running 10.6.8

  • How to update TEXT in Sales order header

    Hello ,
    I have requirement in which I am creating SO via IDOC calling BAPI_SALESORDER_CREATEFROMDAT2.
    Question: Can any one help me in finding a solution to update the TEXT in sales order header which is confogured IN TEXT CONTROL in SD.
    I have tried various option using CREATE_TEXT but it is only updating STXH table , the text is not coming in the sales order.
    If someone knows about this , <removed by moderator>.
    Edited by: Thomas Zloch on Nov 15, 2010 4:20 PM - please do assign priorities > normal

    Sounds like a text determination config issue - have you assigned the text in VOTXN?  Have you run the text determination analysis from VA02 in the document?

  • Can't update text in JTextArea! Can you help?

    [Update: If I remove the transparency everything is fine. However, I really need the transparency..]
    Hi,
    I have the simplest question, but I can't seem to get an answer to it. The problem is very simple: I have defined a JTextArea and I'm reading text into it. The problem is that the old text does not disappear, and the new text is pasted on top, making it unreadable. As an "act of desperation" I fixed this by setting the area invisible, updating it and setting it visible again, as you can see in the code. It works, but now it blinks in the screen (quite annoying!).
    Is there a smarter way to to this? I need this on a transparent window (see class init below), overlayed on another JFrame.
    I am on Mac OS X.
    I hope some of you can help me with this problem
    Thanks a lot in advance
    Lele
    public void UpdateOverlay(){
            try{
                BufferedReader b = this.ReadUrl("http://localhost/~"+System.getProperty("user.name")+"/overlaytext.txt");
                this.Overlay.setVisible(false);
                this.OverlayText.read(b, null);
                this.Overlay.setVisible(true);
            }catch(Exception e){
                e.printStackTrace();
        }Here you can see how I have initialized the class
    public class MyClass {
        //Overlay section
        public JFrame Overlay=new JFrame("Overlay");
        public Color OverlayColor=new Color(0.0f,0.0f,0.0f,0.0f);
        public JTextArea OverlayText=new JTextArea();
        public long Refresh_time=200;//ms
        /** Creates a new instance of MyClass */
        public MyClass(AWT1UpFrame f) {
            int width=270,height=170,border_x=20,border_y=20;
            //Initialize Overlay
            this.Overlay.setVisible(false);
            this.Overlay.setBackground(this.OverlayColor);
            this.Overlay.setLocationRelativeTo(null);
            this.Overlay.setUndecorated(true);
            this.Overlay.setSize(width,height);
            System.out.println("loc="+f.getLocation());
            int x = f.getLocation().x+border_x;
            int y = f.getLocation().y +f.getSize().height - border_y - height;
            this.Overlay.setLocation(x, y);
            this.Overlay.add(this.OverlayText);
            this.Overlay.setAlwaysOnTop(true);
            this.OverlayText.setLineWrap(true);
            this.OverlayText.setWrapStyleWord(true);
            this.OverlayText.setForeground(Color.GREEN);
            this.OverlayText.setBackground(this.OverlayColor);
            this.OverlayText.setFont(new Font("Arial", Font.ROMAN_BASELINE, 16));
    /* and so on*/Edited by: Lele on Oct 25, 2007 4:22 PM

    Hi, so this is the class. If I keep it like this, it simply overwrites old text with the new (like JTextArea thinks that the old text is a part of the background to be buffered). If I set it invisible and back to visible it works, but it blinks.
    How can I let JTextArea understand that it shouldn't consider the old window as a background? Should I use another class?
    Pls keep in mind that I'm on Mac, so maybe it's a Mac-specific thing, but I'd like to know..
    Thanks
    Lele
    package transparency;
    import java.net.*;
    import javax.swing.*;
    import javax.xml.parsers.*;
    import java.awt.*;
    import java.awt.font.*;
    import java.io.*;
    import java.lang.*;
    import java.util.*;
    import java.util.List;
    import apple.awt.CTextArea;
    public class Overlay {
        //Overlay section
        public JFrame Overlay=new JFrame("Overlay");
        public Color OverlayColor=new Color(0.0f,0.0f,0.0f,0.0f);
        public JTextArea OverlayText=new JTextArea();
        public long Refresh_time=200;//ms
        /** Creates a new instance of Overlay */
        public Overlay() {
            int width=270,height=170,border_x=20,border_y=20;
            //Initialize Overlay
            this.Overlay.setVisible(false);
            this.Overlay.setBackground(this.OverlayColor);
            this.Overlay.setLocationRelativeTo(null);
            this.Overlay.setUndecorated(true);
            this.Overlay.setSize(width,height);
            //System.out.println("loc="+f.getLocation());
            //int x = f.getLocation().x+border_x;
            //int y = f.getLocation().y +f.getSize().height - border_y - height;
            //this.Overlay.setLocation(x, y);
            this.Overlay.add(this.OverlayText);
            this.Overlay.setAlwaysOnTop(true);
            this.OverlayText.setLineWrap(true);
            this.OverlayText.setWrapStyleWord(true);
            this.OverlayText.setForeground(Color.GREEN);
            this.OverlayText.setBackground(this.OverlayColor);
            this.OverlayText.setFont(new Font("Arial", Font.ROMAN_BASELINE, 16));
            this.Overlay.setVisible(true);
        public void UpdateOverlay(){
            try{
                //Reading URL
                //String Address="http://localhost/~"+System.getProperty("user.name")+"/overlaytext.txt";
                //URL url= new URL(Address);
                //BufferedReader b = new BufferedReader(new InputStreamReader(url.openStream()));
                //this.Overlay.setVisible(false);
                //this.OverlayText.read(b, null);
                //this.Overlay.setVisible(true);
                //Test
                //this.Overlay.setVisible(false);
                String RandomText="The time is: "+System.currentTimeMillis();
                this.OverlayText.setText(RandomText);
                //this.Overlay.setVisible(true);
            }catch(Exception e){
                e.printStackTrace();
    }.. and this is the main
    package transparency;
    import java.net.*;
    import javax.swing.*;
    import javax.xml.parsers.*;
    import java.awt.*;
    import java.awt.font.*;
    import java.io.*;
    import java.lang.*;
    import java.util.*;
    import java.util.List;
    import transparency.*;
    public class Main {
        /** Creates a new instance of Main */
        public Main() {
        public static void main(String[] args) {
            JFrame f=new JFrame();
            f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
            f.setVisible(true);
            Overlay ov=new Overlay();
            try{
                while(f.isVisible()){
                    ov.UpdateOverlay();
                    Thread.sleep(100);
            }catch(Exception e){
                e.printStackTrace();
    }Edited by: Lele on Oct 26, 2007 3:40 AM

Maybe you are looking for

  • My MacBook won't boot to Ubuntu on my external hard drive. Please help!

    I installed Ubuntu on my 500 GB hard drive, however, when I hold the option key down at startup to load boot manager, Ubuntu isn't there. The same thing occurs when I look at start up disks in system preferences. The Ubuntu boot loader is installed o

  • Cant read the sessionstore.bak/js file

    After firefox updated to the latest version it crashed constantly. With the latest crash all my tabs were gone. I made multiple backups so this should not be that much of an issue. Only problem is, replacing the sessionstore.js file with the .bak doe

  • Updating OSX 10.6.8 to OSX 10.9

    Hi, I have OSX 10.6.8 on my MacBookPro 8,2 with Bootcamp having Windows 7. I would like to update OSX to 10.9 through software update or apple store option on MAC OSX. 1. Will this cause any problems to my dual boot setup or my windows partition? 2.

  • App speed problems - development domain VS production domain.

    Hi, all! I deployed my app. in two versions - one version to development mode domain and other to production mode domain. After deployment I can see that first visits to my app. pages through my browser (and maybe other visits) ON PRODUCTION MODE DOM

  • [svn:osmf:] 11880: Update to add filtering tags for platform unified ASLR

    Revision: 11880 Revision: 11880 Author:   [email protected] Date:     2009-11-16 17:37:51 -0800 (Mon, 16 Nov 2009) Log Message: Update to add filtering tags for platform unified ASLR as follows:        @langversion 3.0        @playerversion Flash 10