How to change JFrame Defult Shape ?

Hello All,
JFrame defult shape is rectanguler, i want to change it
in oval shape or circluer shape or any other shape.
Any body tell me how it is posible, if any example code then please
Help.
i m thanksfull.
Arif.

Its somehow a tedious job and I havent tryied that!
You have to make use of JNI.

Similar Messages

  • Know how to change the outline shape of a tooltip?

    Hi All,
    I was wondering if anybody knows how to change the shape of a tooltip popup box?
    I've implemented my own UI delegate for ToolTipUI and overridden the paint( Graphics g, JComponent c ) method which I thought would have allowed me to completely control the rendering of the tooltip, box and all. But what I discovered was that even when I did nothing inside this method, the rectangular popup window was still appearing (I stepped through the code, and the correct instance of UI was being used, not the one that may have been defined by UIManager.set( "ToolTipUI", "foo.Bar" )) After a little more investigation, I ended up in ToolTipManager.showTipWindow() which eventually calls
    PopupFactory popupFactory = PopupFactory.getSharedInstance();
    tipWindow = popupFactory.getPopup(insideComponent, tip, location.x, location.y);
    tipWindow.show();To try to overcome this, as a test I extended JButton with the following constructor:
    public TestButton() {
        super();
        setUI( new MyCustomUI() );
        ToolTipManager.sharedInstance().unregisterComponent( this );
    }but this didn't solve the problem either. Has anybody got any ideas on this?
    Cheers,
    Paul.

    Try this.
    regards,
    Stas
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.awt.geom.*;
    public class Test {
        JScrollPane scroll;
        JPanel p=new JPanel(new BorderLayout());
        Robot robot=new Robot();
        public Test()  throws Exception {
            final JFrame frame=new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.getContentPane().add(p);
            JButton b=new JButton("Test balloon!");
            b.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    TransparentFrame frame1=new TransparentFrame();
                    int x=frame.getX()-100;
                    if (x<0) x=0;
                    int y=frame.getY()-100;
                    if (y<0) y=0;
                    frame1.setBounds(x,y,100,100);
                    frame1.createBalloon();
                    frame1.setVisible(true);
            frame.getContentPane().add(b);
            frame.setBounds(200,200,120,50);
            frame.show();
        public static void main(String[] args) throws Exception {
            new Test();
    class TransparentFrame extends JWindow {
        Robot robot;
        BufferedImage screenImg;
        Rectangle screenRect;
        MyPanel contentPanel=new MyPanel();
        boolean userActivate=false;
        Area Balloon;
        public TransparentFrame() {
            super();
            createScreenImage();
            contentPanel.Balloon=Balloon;
            this.setContentPane(contentPanel);
            this.addComponentListener(new ComponentAdapter() {
                public void componentHidden(ComponentEvent e) {}
                public void componentMoved(ComponentEvent e) {
                    resetUnderImg();
                    repaint();
                public void componentResized(ComponentEvent e) {
                    resetUnderImg();
                    repaint();
                public void componentShown(ComponentEvent e) {}
            this.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                public void windowClosed(WindowEvent e) {
                public void windowOpened(WindowEvent e) {
                public void windowIconified(WindowEvent e) {
                public void windowDeiconified(WindowEvent e) {
                public void windowActivated(WindowEvent e) {
                public void windowDeactivated(WindowEvent e) {
                    Balloon=null;
        protected void createScreenImage() {
            try {
                if (robot==null)
                    robot=new Robot();
            catch (AWTException ex) {
                ex.printStackTrace();
            Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
            screenRect=new Rectangle(0,0,screenSize.width,screenSize.height);
            screenImg=robot.createScreenCapture(screenRect);
        public void createBalloon() {
            Rectangle bounds=new Rectangle(0,0,getWidth(),getHeight());
            Balloon=new Area(new Rectangle(bounds));
            System.err.println(Balloon.getBounds());
            RoundRectangle2D content=new RoundRectangle2D.Double(0,0,getWidth(),getHeight()/3,20,20);
            Polygon polygon=new Polygon(new int[] {20,getWidth()/2,getWidth()},new int[] {getHeight()/3,getHeight()/3,getHeight()},3);
            Area a=new Area(new Rectangle(bounds));
            a.subtract(new Area(content));
            a.subtract(new Area(polygon));
            Balloon.subtract(a);
            contentPanel.Balloon=Balloon;
        public void resetUnderImg() {
            if (robot!=null && screenImg!=null) {
                Rectangle frameRect=getBounds();
                int x=frameRect.x;
                contentPanel.paintX=0;
                contentPanel.paintY=0;
                if (x<0) {
                    contentPanel.paintX=-x;
                    x=0;
                int y=frameRect.y;
                if (y<0) {
                    contentPanel.paintY=-y;
                    y=0;
                int w=frameRect.width;
                if (x+w>screenImg.getWidth())
                    w=screenImg.getWidth()-x;
                int h=frameRect.height;
                if (y+h>screenImg.getHeight())
                    h=screenImg.getHeight()-y;
                contentPanel.underFrameImg=screenImg.getSubimage(x,y,w,h);
    class MyPanel extends JPanel {
        BufferedImage underFrameImg;
        Area Balloon;
        int paintX=0;
        int paintY=0;
        public MyPanel() {
            super();
            setOpaque(true);
        public void paint(Graphics g) {
            super.paint(g);
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawImage(underFrameImg,paintX,paintY,null);
            if (Balloon!=null) {
                g.setColor(Color.yellow);
                ((Graphics2D)g).fill(Balloon);
            g.setColor(Color.red);
            g.drawString("Balloon test!",10,20);
    }

  • How to change save defults so it saves to the location and file opened?

    When I open a document and change it on my PC it then saves it to the location I opened it in. on my new Macbook air the file does not. I then have to change the defult and I can only get into main folders not the subfolders, so I then have to move it. this is very time consuming and there must be a way of setting a defult so I can save it to the original location. but I can not see it. Please help. I

    Assuming you don't have any utilies installed that changes the behavior of the File Selector (such as Default Folder), you should see the behavior you are describing. When you create a new Document you are normally defaulted to the Documents folder or Pictures folder (whichever is appropriate for the program you are using). In that case you can navigate through the folders to find the subfolder you want or with a little prep work you can pre-select folders.
    In the Finder open a window so you can see a subfolder you frequently want to save to and drag it left into the sidebar. You can also drag items out of the sidebar as well as drag them up and down to put them in the order you prefer. Now when you save a file look to the left side of the File Selector - you have the same sidebar as the Finder. Click on the folder you want to save it and you jump there.

  • Changing JFrame/JWindow shape

    Hi,
    Is there a way to change the shape of a JFrame of JWindow?
    So instead of the usual rectangle, say, a circle or anything else
    I choose?
    Cheers.

    I don't believe so. You can take a look at the source code (free to download) for those classes and see if anything can be done in the painting to make part of the window transparent. I suspect there is native code involved in rendering a JFrame or JWindow so I don't think you'll have much luck.
    Take a look at http://www.l2fprod.com/index.php. They have custom shapes but it appears just for Windows (requires native code).

  • How to change mx:Iris shap to circle

    The default shap is square. I want to change it to circle. There is no shap attribute in mx:Iris.

    I would try entering an SMTP Route. Enter the old hostname for the domain and then add the new machine as the destination.
    You could also use the (undocumented) command delivernow but that will deliver ALL mail and if it runs into any issues like rate limits it will cause mail to bounce.

  • How we can change JFrame Border Color Not Background.

    How we change jframe border color not background
    if any body know about that then plz tell me
    at this [email protected]
    i m thanksfull to ..... .

    hi Shafr
    beleive it or not, i got it using trial and error. i keep
    trying words in the function setStyle until the color changed. i
    dont know why it is not documented.
    var periodBarColor:SolidColor = new
    SolidColor(taskSchedColorChooser.selectedColor, 1);
    periodBar.setStyle("fill",periodBarColor);
    //where taskSchedColorChooser is colorPicker component. you
    can replace it by any color you want

  • How to change shape properties after having created one?

    Photoshop CC 2014 -- latest update as of October 06, 2014
    Windows 7
    How can I change a shapes properties after having created one.
    I have created a simple ellipse.
    When I drew the ellipse with the tool, I had the option for the fill color/style and stroke, etc.
    After I have created said ellipse, I wish to change its properties.
    I can use the Paint Bucket, gradient tool, etc for the fill, but is there way to get back to the original set of tools with which I created the ellipse in the first place?
    If I use Edit > Stroke... it adds a new stroke around the existing shape.
    If I use Edit > Fill... the entire layer is filled.
    There must surely be a way to reenter the tool set to edit an existing shape. No?
    Thanks,

    Hi everyone,
    Thanks for the helpful tips, advice, etc.
    I didn't explain myself very well--I apologize.
    However, with your tips I figured it out:
    When I create a rectangle or ellipse, I can later click on its layer and the Properties window appears with options to change their "Live Shape Properties."
    However, not so with the Polygon and Shape tools. With them, the Properties window shows only the Masks, but the Toolbar still shows some basic properties I can change.
    I was stymied by the above differences while working only on a Shape.
    I've attached two JPEG screenshots.
    I didn't need to change the actual shape, just the fill/stroke, etc.
    Later, I may wish to change the actual shape, but that appears to be done by simply creating something new.
    Thanks much!!

  • 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

  • How to change the JFrame's titlebar's icon's context menu's font?

    Hi everyone.
    I want to know how to change the font of the text that appears in the context menu originated from right clicking at the icon that's all the way to the left in the titlebar of JFrames that use the default look and feel for decoration (JFrame.setDefaultLookAndFeelDecorated(true); // which uses the Metal L&F, Ocean theme).
    I searched around and found nothing. I thought that I could use what I learned at https://forums.oracle.com/message/9221826, but I couldn't come up with something that worked.
    Thanks in advance.t

    After some more messing around, I finally made it! I like Java so much that it makes me a bit sad how hard it is to do stuff like this. Anyway, I found a method here to recursively change the font of all components from a JFileChooser, but it doesn't work on the JPopupMenu (now I know the name) that pops up from the titlebar's icon. So I messed around with that method, used some casting, and was able to change the JMenuItems' font:
    public static void setSubComponentFont (Component comp[], Font font) {
        for (int x = 0; x < comp.length; x++) {
            if (comp[x] instanceof Container) {
                setSubComponentFont(((Container)comp[x]).getComponents(), font);
            try {
                //comp[x].setFont(font);
                if (comp[x].toString().contains("JMenu")) {
                    for (Component y : ((JMenu)comp[x]).getPopupMenu().getComponents()) {
                        if (y.toString().contains("JMenu")) {
                            y.setFont(font);
            } catch (Exception ex) {}
    I was inspired to use .toString().contains() by this thread.
    I also did this with nested loops, so the path to the menu items can be seen:
    for (Component a : frame.getLayeredPane().getComponents()) {
        System.out.println(a.toString());
        if (a.toString().contains("MetalTitlePane")) {
            for (Component b : ((Container)a).getComponents()) {
                System.out.println(b.toString());
                if (b.toString().contains("SystemMenuBar")) {
                    for (Component c : ((Container)b).getComponents()) {
                        System.out.println(c.toString());
                        for (Component d : ((JMenu)c).getPopupMenu().getComponents()) {
                            System.out.println(d.toString());
                            if (d.toString().contains("JMenu")) {
                                d.setFont(font);
    Every System.out.println() gives a hint to what should go on the following if condition, so they should be used one at a time. This doesn't work for the JFileChooser's title font though. When I have time I'll either look further into it or ask another question.
    So, if someone else needs it like I did, here it is. As a tip, System.out.println() and .toString() are your friends! That's how I learned what was contained in each object, and what path I needed to take to get to the objects of interest.
    Thanks anyway!

  • HELP! Desperate, All my shape tools are doing something very strange, must have changed a setting but cannot figure out how to change back!

    Hi Everyone,
    I am not sure how I changed the settings however whenever I go to draw a circle or line/shape, the below keeps happening. I have tried closing down and starting Illustrator up again, but it is still doing the same thing! 

    Ella,
    You may try to see whether your Tilde key ~ is stuck.

  • How to change colors in 2 different shapes one at the time?

    I have 4 different groups. Every group has 4 different shapes/colors. If i change Group 1 Shape 1 color then I want that Shape 2 in Group 2 color would be automatically same as Shape 1 in Group 1. Is it possible?

    That can be done in Illustrator, if vector-based artwork is a possible alternative.
    Have a look at the concept of a "global color" in Illustrator.
    This concept does not have a direct counterpart in Photoshop. Indexed colour mode comes close—but an image in indexed colour mode can't have layers.

  • How to change the icon of the Frame(JFrame)

    my doubt is,
    how to change the by default icon(sun coffee cup) icon of a frame to a small user defined icon.
    thank you,
    Ranjith.M

    Take a look at this method:
    http://java.sun.com/j2se/1.4/docs/api/java/awt/Frame.html#setIconImage(java.awt.Image)

  • IHow do I know what the bit details are on an image and how to change it?

    I wanted to send some wildlife images to a magazine who required us to send  quality size 10
    saved at 300dpi and then to send a copy of the same images at 72dpi and 8bit NOT 16bit.
    I have no idea what they are requesting so please:-
    1) How do I discover the details of my photograhs ie resolution 300dpi or 72dpi and how do I change it.
    2) How do I discover the bit on images and again how do I change it as requested by the magazine.
    Please please keep it simple as I am getting on a bit  (pardon the pun) and do not understand computers.
    Photoshop Elements 8  seems so complicated
    Thank you for any help.
    Brian Holland

    Hi Barbara,
    Firstly I hope you had a great Christmas and I wish you a happy and healthy
    new year.
    I have been experimenting with colour changes in my Photoshop Elements 8 and
    am encouraged having changed the colour of my car in the image.
    I now would like to know how I change images that are black i.e. a crow in a
    photograph or change the white in a photograph i.e. a swan.
    I have looked at the Adjust Hue and Saturation and then the 'Master' but
    there does not seem to be a facility to change black and white.
    Also confused by Magenta and Cyan what colours do they represent please
    should I ever need to use them?.
    Thank you again for your help.
    Brian.
    PS Have also been experimenting with text and shapes and can now alter the
    colours of each and with text vary the font, colour, and style. Progress for
    an old chap of seventy three.

  • How to change button colors in a loop?

    I am working on a task that should imitate an elevator. I have two vertical
    rows of round buttons "Up" and "Down" When a circle is selected randomly by
    the program, the circle becomes yellow and the elevator moves to that
    button.
    Here is what I did:
    1. created a class Circle where I save buttons' parameters
    2. saved Circle objects in an array
    3. drew the buttons depending on their parameters
    4. generated a random number, matched it with an array index and assigned
    the object color to yellow.
    Everything is fine except that I can't figure out how to change colors of my
    buttons in a loop.
    import javax.swing.*;
    import java.awt.*;
    import java.util.*;
    public class Elevator3 extends JPanel
    private int n = 40;
    private int width = 200;
    private int floors = 10;
    private int interval = 1000;
    private boolean selected = false;
    private Circle[] buttons = new Circle[2*(floors-1)];
    public Elevator3()
    build();
    JFrame frame = new JFrame("Elevator3");
    setBackground(Color.WHITE);
    setFont(new Font("SansSerif", Font.PLAIN, Math.round(n/3)));
    frame.getContentPane().add(this);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(width, n*(floors+2) );
    frame.setVisible(true);
    public void build()
    Random r = new Random();
    int buttonPick;
    int timeUntilNextButton = r.nextInt(interval);
    for (int k =0; ; k++)
    if (timeUntilNextButton-- ==0)
    buttonPick = r.nextInt(2*(floors-1));
    //populate my buttons array here - how??
    timeUntilNextButton = r.nextInt(interval);
    //adding "Down" buttons
    for (int i=1, count=0; i < floors; i++, count++)
    if (count == buttonPick)
    selected = true;
    else
    selected = false;
    buttons[count]= new Circle(n*2, n*i, selected, Math.round(n/2));
    //build an array of "Up" circles
    for (int i=2, count=floors-1; i < floors+1; i++, count++)
    if (count == buttonPick)
    selected = true;
    else
    selected = false;
    buttons[count]= new Circle(n, n*i, selected, Math.round(n/2));
    public static void main(String[] args)
    new Elevator3();
    protected void paintComponent(Graphics g)
    super.paintComponent(g);
    //draw buttons
    for (int i=0; i < buttons.length; i++)
    g.setColor(buttons.getColor());
    g.fillOval(buttons[i].getX(), buttons[i].getY(), buttons[i].getWidth(), buttons[i].getWidth());
    class Circle
    private int x;
    private int y;
    private Color c;
    private boolean pressed;
    private int width;
    public Circle(int xCoordinate, int yCoordinate, boolean selected, int diameter)
    x = xCoordinate;
    y = yCoordinate;
    pressed = selected;
    width = diameter;
    if (pressed)
    c = Color.YELLOW;
    else
    c = Color.LIGHT_GRAY;
    public Color getColor()
    return c;
    public int getX()
    return x;
    public int getY()
    return y;
    public int getWidth()
    return width;

    hi,
    am sorry, i couldn't make out what exactly the problem, but as ur subject line says...
    may be the code give below will help you to change button colors in a loop..
              for(int i = 0; i < button.length; i++){
                   int color1 = (int)(250*Math.random());
                   int color2 = (int)(250*Math.random());
                   int color3 = (int)(250*Math.random());
                   Color c = new Color(color1,color2,color3);
                   button[i] = new JButton("button name");
                   button.addActionListener(this);
                   //to check the r, g, b combination.
                   //System.out.println(c);
                   button[i].setBackground(c);
                   button[i].setForeground(Color.white);
    //adding into the panel
                   panel.add(button[i]);
    hope this would help you.

  • How to change the title of an object in the build order window?

    In Keynote '09 v5.1.1 (1034)... How to change the title of an object in the build order window from the default "dropped image" to a specific title?
    I'm running the following:
      Model Name: MacBook Pro
      Model Identifier: MacBookPro2,1
      Processor Name: Intel Core 2 Duo
      Processor Speed: 2.33 GHz
      Number Of Processors: 1
      Total Number Of Cores: 2
      L2 Cache: 4 MB
      Memory: 2 GB
      Bus Speed: 667 MHz
      Boot ROM Version: MBP21.00A5.B08
      SMC Version (system): 1.14f5

    Custom names can't be applied to objects in the build list.
    They are labeled as either; text, shape, table, chart or the filename of an image

Maybe you are looking for