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

Similar Messages

  • 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

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

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

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

  • 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

  • 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

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

  • 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

  • How can I change the width and color of the title bar of the JFrame

    I would like to use the UImanager to change the look and feel of the title bar on all of my JFrames. How is this possible.
    Thanks in advance.

    I appologize for being rude, and thank you for your response.
    The reason I did not respond was that I don't think that your answer solves the question of top level containers (specifically JFrame). I have been researching the net and some of the text books to come up with an answer before I respond. To this point, I believe that the answer has something to do with changing the boundary. If this is the case I'm within four or five hours of the solution, and will publish. If not, back to the drawing board.

  • How to replace the icon in the title bar and minimized window

    I am not sure if this is a Swing question. But since nobody answered it in the Java Programming forum, let me place it here:
    I would like to set my own icon in the title bar and in the minimized window of my java application, replacing the java coffee cup icon.
    I am using:
    frame.setIconImage(new ImageIcon("image.gif").getImage())
    as was suggested previously in the Java Programming forum at:
    http://forum.java.sun.com/thread.jspa?forumID=31&threadID=5212059
    This does create the icon in both places. However, it only works when I run the program from JBuilder 2006. It doesn't work if I run the program from the .jar or the .exe file.
    How can I make it work for my .jar and .exe file?
    Please help! Thanks!

    It doesn't work if I run the program from the .jar...working example for a .jar
    import javax.swing.*;
    import java.awt.*;
    class Testing
      public void buildGUI()
        JFrame f = new JFrame();
        Image img;
        try
          java.net.URL url = new java.net.URL(getClass().getResource("Save.gif"), "Save.gif");//correct capitalization required
          if (url != null)
            img = javax.imageio.ImageIO.read(url);
            f.setIconImage(img);
        catch(Exception e){}//do nothing - default will display
        f.setSize(200,200);
        f.setLocationRelativeTo(null);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setVisible(true);
      public static void main(String[] args)
        SwingUtilities.invokeLater(new Runnable(){
          public void run(){
            new Testing().buildGUI();
    }

  • Removing title bar from JFrame after it isDisplayable

    I know if a frame is not in a Displayable mode, ie not visible you can remove the title bar from the frame with myFrame.setUndecorate(true) in JDK 1.4.0, but I was wondering if you can remove the title bar from the jframe once it is displayed, and conversly if already removed, can you add the title bar back to the jframe. If there is no java solution, is there a jni solution.

    if you remove the title bar from a JFrame, wouldn't you be create a JWindow?

  • Button into the title of a JFrame

    How can I put Buttons or Icons (which can handle the mouse click) into the title bar of a JFrame? Is it possible anyway?
    Fast reply will be pleased.
    Bye Zafir

    I used a JWindow and created my title bar, add a mouseListener as sort of a secert code to get out of the app.
    private JLabel setBanner(){
        banner = new JLabel();
        banner.setBackground( Color.blue );
        banner.setBounds(0,0,screenW, 15 );
        banner.addMouseListener (new java.awt.event.MouseAdapter () {
            public void mouseReleased (java.awt.event.MouseEvent evt) {
              // do your work or whatever in here
         return banner;
       // add the banner
       mainPanel.add(setBanner());Of course you lose the icon and min max close

  • How to customize the title bar on my own Look And Feel?

    Hi all!
    I am creating my own Look and Feel which extends from NimbusLookAndFeel. What I'm doing is overwriting UIDefaults values??, referring to the Painters. For example:
    +uiDefault.put ("Button [Enabled]", new ButtonEnabledPainter());+
    But now I need is to customize the title bar of the JFrame's, but I do not see this option in Painter's values ??can be overwritten by Nimbus (http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/_nimbusDefaults . html).
    You know as possible? I have to overwrite an existing UI component? The idea is I want to make the look and feel like SeaGlass, but the code seems a bit complex to know where to begin.
    I hope you can guide me on this issue.
    Thank you very much for everything! And excuse my English!.
    Greetings!

    very simple example, with direct methods
    import java.awt.*;
    import java.awt.event.*;
    import java.util.LinkedList;
    import java.util.Queue;
    import javax.swing.*;
    public class NimbusBorderPainterDemo extends JFrame {
        private static final long serialVersionUID = 1L;
        private JFrame frame = new JFrame();
        private JPanel fatherPanel = new JPanel();
        private JPanel contentPanel = new JPanel();
        private GradientPanel titlePanel = new GradientPanel(Color.BLACK);
        private JLabel buttonPanel = new JLabel();
        private Queue<Icon> iconQueue = new LinkedList<Icon>();
        public NimbusBorderPainterDemo() {
            iconQueue.add(UIManager.getIcon("OptionPane.errorIcon"));
            iconQueue.add(UIManager.getIcon("OptionPane.informationIcon"));
            iconQueue.add(UIManager.getIcon("OptionPane.warningIcon"));
            iconQueue.add(UIManager.getIcon("OptionPane.questionIcon"));
            JButton button0 = createButton();
            button0.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    frame.setExtendedState(ICONIFIED);
            JButton button1 = createButton();
            button1.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    frame.setExtendedState(MAXIMIZED_BOTH | NORMAL);
                }//quick implemented, not correct you have to override both methods
            JButton button2 = createButton();
            button2.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    int confirm = JOptionPane.showOptionDialog(frame,
                            "Are You Sure to Close Application?", "Exit Confirmation",
                            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
                            null, null, null);
                    if (confirm == JOptionPane.YES_OPTION) {
                        System.exit(1);
            buttonPanel.setLayout(new GridLayout(0, 3, 5, 0));
            buttonPanel.setPreferredSize(new Dimension(160, 30));
            buttonPanel.add(button0);// JLabel is best and cross_platform JComponents
            buttonPanel.add(button1);// not possible put there witouth set Dimmnesion
            buttonPanel.add(button2);// and LayoutManager, work in all cases better
            titlePanel.setLayout(new BorderLayout());//than JPanel or JCompoenent
            titlePanel.add(new JLabel(nextIcon()), BorderLayout.WEST);
            titlePanel.add(new JLabel("My Frame"), BorderLayout.CENTER);
            titlePanel.setBorder(BorderFactory.createLineBorder(Color.GRAY));
            titlePanel.add(buttonPanel, BorderLayout.EAST);
            JTextField field = new JTextField(50);
            JButton btn = new JButton("Close Me");
            btn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    System.exit(1);
            contentPanel.add(field);
            contentPanel.add(btn);
            fatherPanel.setLayout(new BorderLayout());
            fatherPanel.add(titlePanel, BorderLayout.NORTH);
            fatherPanel.add(contentPanel, BorderLayout.CENTER);
            frame.setUndecorated(true);
            frame.add(fatherPanel);
            frame.setLocation(50, 50);
            frame.pack();
            frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
            frame.setVisible(true);
            ComponentMover cm = new ComponentMover(frame, titlePanel);
            //by camickr http://tips4java.wordpress.com/2009/06/14/moving-windows/
        private JButton createButton() {
            JButton button = new JButton();
            button.setBorderPainted(false);
            button.setBorder(null);
            button.setFocusable(false);
            button.setMargin(new Insets(0, 0, 0, 0));
            button.setContentAreaFilled(false);
            button.setIcon(nextIcon());
            button.setRolloverIcon(nextIcon());
            button.setPressedIcon(nextIcon());
            button.setDisabledIcon(nextIcon());
            nextIcon();
            return button;
        private Icon nextIcon() {
            Icon icon = iconQueue.peek();
            iconQueue.add(iconQueue.remove());
            return icon;
        private class GradientPanel extends JPanel {
            private static final long serialVersionUID = 1L;
            public GradientPanel(Color background) {
                setBackground(background);
            @Override
            public void paintComponent(Graphics g) {
                super.paintComponent(g);
                if (isOpaque()) {
                    Color background = new Color(168, 210, 241);
                    Color controlColor = new Color(230, 240, 230);
                    int width = getWidth();
                    int height = getHeight();
                    Graphics2D g2 = (Graphics2D) g;
                    Paint oldPaint = g2.getPaint();
                    g2.setPaint(new GradientPaint(0, 0, background, width, 0, controlColor));
                    g2.fillRect(0, 0, width, height);
                    g2.setPaint(oldPaint);
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
                    } catch (Exception fail) {
                    UIManager.getLookAndFeelDefaults().put("nimbusFocus", Color.RED);
                    NimbusBorderPainterDemo nimbusBorderPainterDemo = new NimbusBorderPainterDemo();
    }

Maybe you are looking for

  • UnsatisfiedLinkError when loading library from within package

    I have a piece of working code (simplified for easier reading): NativeLibraryLoader.java public class NativeLibraryLoader{      static { System.loadLibrary("TheLibrary"); }      public static native void someFunction(String someVariable);      public

  • Can I revert back to Snow Leopard from Lion?

    Hey guys, Last night i upgraded to Lion.  Have since found out my Focusrite 24 DSP audio interface wont work with Lion (No Drivers yet).... can i simply re-install Leopard from the install discs that came with my imac until such time as drivers becom

  • Is JBoss a right solution for me?

    Hi, I want to develop web services using Apache XML-RPC and standard Java Objects, no EJB's. I require "Connection Pooling" feature available in JBoss. I am planning to use MySQL Transactions available in MySQL Connector /J and caching in MySQL using

  • Reset Slide with Audio on Enter CP7 HTML5

    I have a slide with some audio and animation (captions fading in and out) on the timeline that is triggered by a play/pause button with some Advanced Actions attached to it to toggle the buttons and resume and pause the timeline. However, if I naviga

  • Font issues & Missing Links

    Hello, I was wondering if anyone can shed some light on the issue of fonts & missing links!? Basically, when we create a document in Indesign using Mac 1, and save it on the server (for someone else to open) , When the user on Mac 2 opens it the font