Displaying Jtimer in the title bar of jframe

we have an urgent requirement to display Time (should run continously) and Date in the title bar of the java
application. Please give input..

To update a frame's title, call setTitle:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TitleUpdater {
    public static void main(String[] args) {
        final JFrame f = new JFrame("TitleUpdater");
        JButton btn = new JButton("press here");
        btn.addActionListener(new ActionListener(){
            int count = 0;
            public void actionPerformed(ActionEvent evt) {
                ++count;
                f.setTitle("pressed: " + count + " times.");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(btn, BorderLayout.NORTH);
        f.setSize(400,100);
        f.setLocationRelativeTo(null);
        f.setVisible(true);
}

Similar Messages

  • Displaying the username in the title bar of jframe

    hi
    how to display the username entered by the user in the title bar of jframe

    I'm not sure what you mean by 'entered' but does the following help?
    import javax.swing.*;
    public class DisplayUserNameInTitleOfJFrame extends JFrame
        public DisplayUserNameInTitleOfJFrame()
            setTitle(System.getProperty("user.name"));
            setSize(640, 480);
        public static void main(String[] args)
            new DisplayUserNameInTitleOfJFrame().setVisible(true);
    }

  • How to draw on the title bar of JFrame ?

    Is there any way in which I can draw on the title bar of the JFrame. I want to display animation on the JFrame title bar. Is it possible in Swing! For example I want to display a set of concentric circles increasing and decreasing in radii.

    What child window are you referring to? Do you mean a browser window opened with web.show_document?
    If so, you can use javascript to hide browser toolbars and so on. Search the forum for some javascript examples where windows are opened with toolbar=no.

  • Any way to get at the title bar in JFrame?

    I'd like to either add a button to the title bar (title pane?) or override the behavior of the resize button. As far as I can tell, the LookNFeel classes don't allow you to add anything, just change colors, icons, etc. The WindowListener classes don't let you get at the resize button. I don't want to override Component.setSize() (that causes other problems), I just want to have the resize button do something different (or add another button).
    I'd appreciate any ideas!

    1) You could create your own frame that extends JWindow. This would be quite involved, since you'd need to make it respond to mouse drags, mouse resizing etc explicitly (if you wanted that functionality), but you would be able to add your own custom border, which you could make to look like a system border, or you could make comletely different.
    2) I don't know this could be persuaded to do what you want, but you could try adding a ComponentListener to the JFrame to check for resizes, and take action accordingly

  • Unicode in the Title bar of JFrame

    Hi
    I have a unicode application and I am using the font Arial Unicode MS. I want to show unicode charecters in the title of my JFrame. I am able to show unicode chars in all other controls except for the title of the main JFrame.
    I read several posts on the forum and came to an understanding that, the title bar of the JFrame is controlled by the OS.
    So I changed the fonts used in my windows also to Arial Unicode MS. But still I see only ??? in place of unicode characters.
    Need urgent help.
    Thanks
    Vineet

    import java.awt.*;
    import javax.swing.*;
    public class X {
        public static void main(String[] args) {
            JFrame.setDefaultLookAndFeelDecorated(true);
            JFrame f = new JFrame("ABCabcXYZxyz");
            Font font = new Font("Lucida Bright", Font.BOLD|Font.ITALIC, 14);
            Container cp = f.getContentPane();
            JLayeredPane lp = f.getLayeredPane();
            for(int i=0, ub=lp.getComponentCount(); i<ub; ++i) {
                Component child = lp.getComponent(i);
                if (child != cp)
                    child.setFont(font);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setSize(500,400);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }1. You have to use a LAF that draws its own title bar. If your platform is drawing your title bar, you'll
    have to go the JNI route :-(
    2. If you have a menu bar, it'll be in the layered pane as well, so you'll have to skip over the way
    content pane is skipped over...

  • Displaying image in the Title bar

    hi ,
    can any one help me to display image in the JFrame Title Bar Left Corner, Right Corner, orMiddle ..

    double post http://forum.java.sun.com/thread.jsp?forum=57&thread=554453

  • How to catch drag event in the title bar of a jframe

    Hi
    I want to catch the drag event in the title bar for jframe, because I have a few more window, dialogs, which I want to move along with my main window
    Thanks

    you can use a listener like tih one below...it works if you don't move to quickly.....
    class SynchroMover extends ComponentAdapter{
      private JFrame master;
      private JFrame[]slaves;
      private int currentX;
      private int currentY;
      public SynchroMover(JFrame master,JFrame[]slaves){
        this.master = master;
        this.slaves = slaves;
        currentX =(int) master.getLocation().getX();
        currentY =(int) master.getLocation().getY();
      public void componentMoved(ComponentEvent e){
        int dx = (int)master.getLocation().getX() - currentX;
        int dy = (int)master.getLocation().getY() - currentY;
        System.out.println(dx+" "+dy);
        for(int i=0;i<slaves.length;i++)
          slaves.setLocation((int)(slaves[i].getLocation().getX()+dx),(int)(slaves[i].getLocation().getY()+dy));
    currentX = (int)master.getLocation().getX();
    currentY = (int)master.getLocation().getY();
    the code isn't optimized...so you can probably do better

  • Is there a way to modify the name displayed in the Title Bar at the top of the Audition Window?

    It's not uncommon for me to have a copy of Audition versions 1.5, 2.0 and 3.0 all open at the same time if I'm doing some editing for a complex project. 
    It would be handy for me to quickly see which window I have open without having to recognise the icons of the different versions.  At the moment, each Title Bar just displays the Audition icon and the words "Adobe Audition".  I'd like to add the version number to the name, if it's possible.  I'm happy to edit the Windows Registry, if that is what is needed.
    Does anybody know where the Title Bar information is stored?

    I have an answer you might like Howard.
    You could simply export one title to a PRTL file, then duplicate it using an Excel VB macro to change the name of the file based on a list in an excel file. You could type in a couple of dates, then just drag down to the 365th row and all of the dates would be there waiting for the macro to rename the file. Then, if you are really talented, you could find the appropriate text in the XML file and change it to match the name of the title, but without the PRTL extension.
    That way the font and position and style would all be right and the effort would be in a file you could share with the world.
    Hmmm. I might have to try that myself one of these days. Could come in handy. If you are more comfortable with Word than Excel, create the dates in Excel and paste them into a table in Word. Just be careful not to mess up the
    Edit: Oh, and of course, you import the titles back into Premiere Pro.

  • How do you make the title bar display different text than the page title?

    I'm looking for a way for the title bar display of my web page to be different than the text in the actual nav bar created by iWeb. For instance, I'd like the nav bar to just say Home for my main page, but in the title bar in the browser say "blah blah blah."
    I know there has to be a way to do this. iWeb has actually done it on one page already, but I can't figure out how. I think it picked up the title bar text from the first text box in the page. For instance, the page name in the navigation bar is "blahs for today" but the browser title bar when you open that page says "blah blah," which happens to be the first line of text on the page. The page title in iWeb.app, though, is "blahs for today." But if I look at the source code it lists title as "blah blah."
    I'm guessing I might be able to work around by making an invisible text box with the text that I want in the title bar as the very first thing on the page, and hope iWeb makes that the title bar text. I'd rather have a more correct way of doing it.
    Is there a way of doing this in the source code without having to change a lot of stuff?
    Thanks for any help.

    Richard Kirkman1 wrote:
    I think it picked up the title bar text from the first text box in the page. (...) I'm guessing I might be able to work around by making an invisible text box with the text that I want in the title bar...
    Richard ~ The key is the default Title box that iWeb creates for every new page — it's that which you need to edit, not another text box you've created. And to make the text in that Title box invisible, see here.

  • Embedding HTML in the Title Bar of a JFrame

    Hi Folks,
    I have a simple question. Do you know I can I employ an HTML-enabled script in the title bar of a JFrame? I would like to make use of the subscript tag in HTML <sub>, yet it didn't work out:
    public class MyFrame extends JFrame{
    super("<html>KPC<sub>V.10</sub></html>");
    }I don't know what I am doing wrong, but the title appears with the HTML tags, not in the way I would like it to be formatted. What would you suggest?
    Regards,

    The frame title is (typically) set in a native OS frame, which is not controlled by Java.
    Perhaps if you tell Java to let the L&F control the frame decorations it might work, but probably not, as it would probably just try to mimic what the OS does anyway, which is to not support HTML.
    So basically, you can't.

  • How to change the image in title bar for JFrames

    plz give me a small code to change the image of the JFrame in the Title bar.
    i know how to change the name of the title bar .
    import javax.swing.*;
    class Rathna1 extends JFrame
    Rathna1()
    super("rathna project ");
    public class Rathna
    public static void main(String ax[])throws Exception
    Rathna1 r=new Rathna1();
    r.setVisible(true);
    r.setSize(400,400);
    Like this how to change the image of the title bar
    Message was edited by:
    therathna

    hi,
    JFrame frame;
    frame.setVisible(true);
    frame.setIconImage(new ImageIcon("icons/img007.gif").getImage());
    frame.setSize(800,600);
    i think the thing u r searching is :
    frame.setIconImage(new ImageIcon("icons/img007.gif").getImage());
    ~~~radha

  • Displaying our own icon at the title bar of a frame.

    Hai,
    How do i display an Icon of my choice at the title bar of a frame or a dialog box.
    Thank you.

    Thank you shahidjava for the kind reply,
    I tried your code as follows but I'am getting an exception saying "wrong number of arguments in the method.".
    Can you please help this out.
    import java.awt.*;
    import java.awt.event.*;
    public class testIcon extends Frame
         public testIcon()
         setVisible(true);
         setTitle("mohammad afzal....!");
         setBounds(100,100,200,200);
         getIconImage("afzal.gif");
         public static void main(String args[])
         testIcon ti=new testIcon();
    }

  • Changing the logo in the Title Bar of a JFrame

    How do I change the logo in the left hand corner of the Title Bar of a JFrame window.

    Hi Sverigeterje
    Thanks.
    That's very neat. All done with one line of code, as opposed to the two lines of code I found in an answer (dated Jan 8, 2001) from Alexander Smirnov in response to a similar question (dated Sep 16, 2000) from Shawn Barker. (http://forums.java.sun.com/thread.jsp?forum=31&thread=49970 - Jan 8, 2001)
    ImageIcon image = new ImageIcon("CustomIcon.gif");
    this.setIconImage(image.getImage());
    Once again many thanks.
    George (aka cyberking1)

  • Displaying an icon in the title bar of a web page

    Hi Friends,
    Pls temme how 2 display a given icon in the title bar of a web - page, i mean in the title bar of the web - browser which loads the page.
    Thanks in advance,
    Kottayam Achayan

    Hi Friends,
    Pls temme how 2 display a given icon in the title bar
    of a web - page, i mean in the title bar of the web -
    browser which loads the page.
    Thanks in advance,
    Kottayam AchayanIn web.xml, you can use the <icon> element to specify the image to be used.
        <icon>
            <small-icon><!-- Specify a 16X16 GIF or JPG --></small-icon>
            <large-icon><!-- Specify a 32X32 GIF or JPG --></large-icon>
        </icon>Hope this helps.
    Annie.

  • Setting an icon in the title bar of a JFrame...

    Hi,
    how do I set an image (icon) in the title bar of a JFrame (in the top left corner)?
    In JInternalFrame there is a method
    public void setFrameIcon(Icon icon)to set an image in the title bar of this internal frame - but in a JFrame I didn't find any method like this...
    Thanks in advance
    - Stephan

    Thanks ICE, that works for me...
    this.setIconImage(new ImageIcon("img\\foo.jpg").getImage());- Stephan

Maybe you are looking for

  • How do I hide the red "1" badge in the Settings app?

    I have no intention of updating from iOS 6 to 7, as I understand it runs slowly on iPhone 4. Just today the little red "1" badge showed up on the Settings app icon and I'd like to make it go away. I tried Settings>Notifications, but Settings isn't in

  • [SOLVED] i915: no gpu acceleration with 3.18.0

    Hi, I compiled the new vanilla kernel using the same .config as the previous one (also self compiled), but with 3.18 intel gpu accleration fails to start. Xorg.bin log says "Failed to submit rendering commands, disabling acceleration". As a result Gn

  • Is there a way to re-compress the audio of a clip without re-exporting the video?

    Hey guys, I have 500 clips that took me 2 days to render to ProRes just to find out that the audio is not the right format. What do i do now? I don't want to have to re-export all those 500 files again and wait 2 more days. Is there a way to run thos

  • ADC to VGA, I think?

    I have an old G4 Cube that I no longer use. I bought a monitor that I think is called a studio display (not the flat panel cinema display, but big and heavy like an old TV). It has what I believe is an ADC connection that draws power from the G4 Cube

  • SCCM 2012 and PXE

    I have a client assigned to site PR1 and I deploy a pxe task sequence to my imaging collection which this machine belongs too.  I can see the task sequence in the deployment tab of the properties for the client.    I also have verified the deployment