Customise Application Icon

L

Leigh

I can't find where the main form's application icon is referenced in my
project code, or available as a Property to change. I would like to use
another icon(instead of the default coffee cup). How can I reference my
own icon?
 
A

Andrew Thompson

Leigh said:
I can't find where the main form's ..

Form? There is no 'form' in the J2SE. It sounds like
you are 'talking the language of your IDE'. I suggest
learning Java instead.
..application icon is referenced in my
project code, or available as a Property to change.

It a 'form' translates to a JFrame, then it would not.
You get the 'coffee cup' if no application icon has
been set on the JFrame. If you set the icon to 'null'
the JFrame will have no icon, or else you can set it
to any other image understood by Java.
..I would like to use
another icon(instead of the default coffee cup). How can I reference my
own icon?

<http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html#setIconImage(java.awt.Image
)>

--
Andrew Thompson
http://www.physci.org/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200801/1
 
L

Leigh

Andrew said:
Form? There is no 'form' in the J2SE. It sounds like
you are 'talking the language of your IDE'. I suggest
learning Java instead.
Thanks for your kind words Andrew. I used the word "form" in a generic
sense (perhaps influenced from prev experience with C++). I made the
basic NetBeans example Java Desktop application. this doesn't create a
JFrame, rather a frameView, whatever that is, as it's top level
container I think.

I am learning java, and I've always found not being afraid of asking
questions is a helpful aid. Bye the way, one needs to learn an ide as
well as java at the beginning. I don't want to learn java only using
the console. Life is too short for that.

Gosh, it's not easy is it? I am finding it tricky so far to create an
image object to put in the user code field in the IconImage property of
a test JFrame I added to my project to try your suggestion. I can't yet
find an Image class in the java.awt.Image package. Hmmm, I'll struggle on.
 
L

Leigh

Andrew said:
>
> Form? There is no 'form' in the J2SE. It sounds like
> you are 'talking the language of your IDE'. I suggest learning Java instead.
>
Thanks for your kind words Andrew. I used the word "form" in a generic
sense (perhaps influenced from prev experience with C++). I made the
basic NetBeans example Java Desktop application. this doesn't create a
JFrame, rather a frameView, whatever that is, as it's top level
container I think.

I am learning java, and I've always found not being afraid of asking
questions is a helpful aid. Bye the way, one needs to learn an ide as
well as java at the beginning. I don't want to learn java only using
the console. Life is too short for that.

cup). How can I reference my own icon?
Gosh, it's not easy is it? I am finding it tricky so far to create an
image object to put in the user code field in the IconImage property of
a test JFrame I added to my project to try your suggestion. I can't yet
find an Image class in the java.awt.Image package. Hmmm, I'll struggle on.
 
A

Andrew Thompson

Leigh said:
Thanks for your kind words Andrew.

(dismissive) Puh! The only kindness I will generally
offer to posters is to reply. Thereafter I usually aim for
'techically specific' - which although it is not 'unkind' it
often ends up being 'direct and blunt'.
..I used the word "form" in a generic
sense (perhaps influenced from prev experience with C++).

I don't understand that comment. Surely the C++ compilers
are just as finicky as the Java compilers, but if you're refering
to the C++ usenet groups - I can only assume that it takes
longer to get to a positive result that way.
..I made the
basic NetBeans example Java Desktop application. this doesn't create a
JFrame, rather a frameView, whatever that is, as it's top level
container I think.

You think? This is the sort of comment that inspires
me to say 'understand it from the command line first'.

The fact is that NetBeans (last time I checked) had
relatively ways to see the 'inheritance tree' of any Java
object, so it should be relatively easy to tell others what
this 'frameView' actually is. Further, the lower case initial
'f' suggests this is a reference variable name, rather than
a class. E.G. ..
// FrameView is a class, frameView is a reference to an instance of
FrameView.
FrameView frameView = new FrameView("Frame Title");

Please try to wuote class names, rather than the name of
the variable (and if the class name is truly 'frameView' - it
seems whoever wrote it was a nonser and the code should
probably be avoided completely).
I am learning java, and I've always found not being afraid of asking
questions is a helpful aid. Bye the way, one needs to learn an ide as
well as java at the beginning.

That is something I strongly disagree with.
Ant and a simple editor is all that is needed to 'learn Java',
and gives a good foundation for understanding any IDE.
..I don't want to learn java only using
the console. Life is too short for that.

I warrant you will waste a lot more time trying to 'figure
the IDE' that way, and ultimately (over a long period)
that will lead to lower productivity.

So to put it back to you..
" Life is too short for 'learning' IDEs."
Gosh, it's not easy is it?

There are some 'roundabout'* factors in creating an icon
image for an app.
..I am finding it tricky so far to create an
image object to put in the user code field in the IconImage property of
a test JFrame I added to my project to try your suggestion. I can't yet
find an Image class in the java.awt.Image package. Hmmm, I'll struggle on.

Hmm.. well I realise you were not asking specifically for further
help, but I will include a simplistic* example anyway.

<sscce>
import java.awt.*;
import javax.swing.*;
import java.net.URL;

class FrameWithIcon {
public static void main(String[] args) throws Exception {
final URL url = new URL(
"http://forum.java.sun.com/images/answer-correct-24x24.gif");
Runnable r = new Runnable() {
public void run() {
Image icon = Toolkit.
getDefaultToolkit().
createImage(url);
JFrame frame = new JFrame("Icon");
frame.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE);
frame.setIconImage(icon);
frame.setSize(400,400);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
};
EventQueue.invokeLater(r);
}
}
</sscce>

* The example avoids some 'where is my sh*t?' hassles
by grabbing the image direct from the net, rather than
from the jar archive that contains the application. The
second situation might encounter some problems finding
the URL to the image, especially if called from the main()
method.

--
Andrew Thompson
http://www.physci.org/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200801/1
 
C

colinbankier

Hi,

I think I can give you a little more help. Netbeans uses the Swing
Application Framework as the basis of desktop example projects. The
FrameView object is part of this framework.
You can use Andrew's example to see how to create an Image (stored in
the variable 'icon'), then you can simply call:
getFrame().setIconImage(icon);
from inside the contructor of the FrameView.

The docs for the Swing Application Framework can be found at
https://appframework.dev.java.net/nonav/javadoc/AppFramework-1.03/index.html

Cheers,
Colin.
 
C

cartimon

I can't find where the main form's application icon is referenced in my
project code, or available as a Property to change.  I would like to use
another icon(instead of the default coffee cup).  How can I reference my
own icon?

...
...
//
import java.awt.Toolkit;
import java.awt.Image;

/**
* The application's main frame.
*/
public class Adm0View extends FrameView {

public Adm0View(SingleFrameApplication app) {
super(app);
// change default icon
Toolkit kit = Toolkit.getDefaultToolkit();
Image frameIcon = kit.getImage("FD2.jpg");
getFrame().setIconImage(frameIcon);
// PATH ..\Adm0\"FD2.jpg";

initComponents();

...
...
 
Joined
Mar 7, 2009
Messages
1
Reaction score
0
Andrew You are a miserable piece of crap as a human being. Perhaps you should think (if that's possible) before you reply. Your inability to understand the meaning of the original posters comments shows that you are the ignorant one. Clearly his reference to 'form' is appropriate in the context. To belittle one simply because he didn't use language you approve of demonstrates an infantile personality. Maybe you should get out of the business of replying to questions if you are not intelligent enough to interpret the query.

So in Classic English I say **** Off you piece of ****.

Andrew Thompson said:
Leigh wrote:

It a 'form' translates to a JFrame, then it would not.

Andrew Thompson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top