0

I have created a jframe in java with following code . this is creating the custom icon of the image passed in the given url . but its size is very small can i change the shape of it from rectangular to circular pls help

 class newframe extends JFrame 
  {

 Container cp;
   newframe()
   {
      cp=this.getContentPane();
      cp.setLayout(null);
    }

    public static void main(String args[])
    {
      newframe frm= new newframe(); 

      frm.setbounds(0,0,1000,800);
      frm.setVisible(true);
      ImageIcon im1= new ImageIcon("path upto image");
      frm.setIconImage(im1.getImage());
     }
    }
adesh kumar
  • 129
  • 3
  • 10
  • 3
    This is the second question where the same advice is given to you. – Guillaume Polet Oct 15 '12 at 09:39
  • 2
    Please learn java naming conventions and stick to them. And while you are at learning - make sure to learn all about LayoutManagers (null isn't an option in Swing :-) – kleopatra Oct 15 '12 at 09:54
  • btw: my downvote is for not taking advice given in earlier questions - if you insist in doing stuff incorrectly, there is no reason at all for anybody to give it, is there? – kleopatra Oct 15 '12 at 10:01

2 Answers2

1

you can't change the size of Icon for JFrame, because properties of Top-Level Container came from Native OS, AFAIK and because

  • Icon can

    a) fill all available area

    b) smaller than available area

    c) only part of Icon is visible, because is larger than available area

  • size of Icon is platform sensitive (WinXP == 16 x 16, Win7 depends of current theme 16 x 16 or 32 x 32 )

  • there are two Custom Look and Feels that implementing own injections to the properties for Top-Level Container came from Native OS, one of them is Substance L&F, 2nd isn't important to mentioned, because touched shadowed area, and required to remove toolbar and returns modified back (dirty hacks)

  • for JFrame based on JSR296 in Netbeans isn't possible to change Icon for Top-Level Containers, because this Swing Framework to override and protected some important methods, have to override RootPane (please don't do that, required tons of hacks and result will be only Borders (transparent window without contens) without ContentPane, no way back)

Community
  • 1
  • 1
mKorbel
  • 109,525
  • 20
  • 134
  • 319
0

ONLY BY WINDOWS 7!

When you set the Width on 32x32 pixels, the icon of the JFrame Window in the the superbar is bigger. It bust be this Size, because when it isn't 32x32 it shows only 16x16 pixels.

Gordon
  • 312,688
  • 75
  • 539
  • 559