changing Java GUI titlebar icon

changing the icon in the titlebar of a gui window

Page 1 of 1

3 Replies - 5413 Views - Last Post: 08 August 2009 - 05:42 AM Rate Topic: -----

#1 drummer_sniper  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 70
  • Joined: 05-August 09

changing Java GUI titlebar icon

Posted 08 August 2009 - 03:29 AM

hi can someone help me change the icon in the title bar of my gui window?
i already did this but it doesn't change the icon.

public GuiMsV2() {
		setTitle(" Magic Square");
		setSize(500,130);
		setLocation((1024-200)/2,(768-700)/2);
	   
		ImageIcon ImageIcon = new ImageIcon("d:\\16x16.jpg");	//these are the added code
		Image Image = ImageIcon.getImage();							   //these are the added code
		this.setIconImage(Image);												  //these are the added code



		inputPanel.setLayout(new GridLayout(4,2));
		buttonsPanel.setLayout(new GridLayout(1,2));

		inputPanel.add(lbl_1);		  inputPanel.add(txt_dimension);
		inputPanel.add(lbl_2);		  inputPanel.add(lbl_space);
		inputPanel.add(lbl_x);		  inputPanel.add(txt_x);
		inputPanel.add(lbl_y);		  inputPanel.add(txt_y);

		buttonsPanel.add(btn_solve);
		buttonsPanel.add(btn_clear);

		btn_solve.addActionListener(this);
		btn_clear.addActionListener(this);

		add(inputPanel,BorderLayout.NORTH);
		add(buttonsPanel,BorderLayout.CENTER);
		setResizable(false);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setVisible(true);
	}




Is This A Good Question/Topic? 0
  • +

Replies To: changing Java GUI titlebar icon

#2 abgorn  Icon User is offline

  • sudo apt-get install brain
  • member icon

Reputation: 30
  • View blog
  • Posts: 1,410
  • Joined: 05-June 08

Re: changing Java GUI titlebar icon

Posted 08 August 2009 - 03:54 AM

Use this as your frame method: setIconImage(new ImageIcon("[path]").getImage()) Though double check your path to the image.
Was This Post Helpful? 1

#3 drummer_sniper  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 70
  • Joined: 05-August 09

Re: changing Java GUI titlebar icon

Posted 08 August 2009 - 05:09 AM

thanks.. that solved my problem

This post has been edited by drummer_sniper: 08 August 2009 - 05:11 AM

Was This Post Helpful? 0
  • +
  • -

#4 abgorn  Icon User is offline

  • sudo apt-get install brain
  • member icon

Reputation: 30
  • View blog
  • Posts: 1,410
  • Joined: 05-June 08

Re: changing Java GUI titlebar icon

Posted 08 August 2009 - 05:42 AM

*cough, cough* This post was...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1