Results 1 to 14 of 14
- 10-20-2008, 12:50 PM #1
[SOLVED] how to cahnge the background color of the frame?
hi all,
can anyone please tell me how can i change the background color of my form. I am developing a desktop application using NetBeans IDE.
can i use any image/icon as the icon for th frame? if yes, how?
thanks in advance!
regardsThanks and Regards,
Pranav
- 10-20-2008, 01:04 PM #2
1. One way: change the background color of a JPanel using setBackground(...) and set that JPanel as the contentPane of the JFrame.
2. JFrame#setIconImage(...)
db
- 10-20-2008, 02:20 PM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Yes you can. Did you search on the web?
Java Code:ImageIcon imageBack = new ImageIcon(image_goes_here); JLabel background = new JLabel(imageBack); background.setBounds(0, 0, imageBack.getIconWidth(), imageBack.getIconHeight()); getLayeredPane().add(background, new Integer(Integer.MIN_VALUE)); jPanel1.setOpaque(false); setContentPane(jPanel1);
- 10-21-2008, 08:47 AM #4
how can i replace the java icon with my icon in a JFrame.
I am using NetBeans IDE.
pls tell me.Thanks and Regards,
Pranav
- 10-21-2008, 09:17 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
What you mean by java icon. You can use any icon there.
- 10-21-2008, 09:24 AM #6
Eranga, I think pranav13 is referring to the title bar icon. The answer to that is at #2, and shouldn't have anything to do with the choice of IDE :)
db
- 10-21-2008, 09:26 AM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Ah, I'm confusing with his message title and the content of the message.
- 10-21-2008, 12:29 PM #8
hey, sry i hv clubbed 2 questions n confused u.
i gt the solution from bruke`s suggestion.
Actually, i was trying to set the icon property of the form in properties window in NetBeans IDE. But it is not setting. Thats why i have written it manually using setIconImage().
Thanks for your suggestions!Thanks and Regards,
Pranav
- 10-21-2008, 12:47 PM #9
Well there is also a property IconImage (and also IconImages) that can be set from the NetBeans property list. But looking at it, it's easier to just write the code yuorself :)
As in the case of many other features of the Visual Editor.
db
- 10-21-2008, 01:49 PM #10
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I think write code your self is the best. Even that the above code segment I've written on NetBeans.
- 10-21-2008, 01:50 PM #11
thanks darryl bruke!
i got one more problem. I am running a Process in a background thread. and i want to stop that process when i click a button.
i cudnt access the obj of Process from the button click event. i also tried to declare it as static but in vain.
pls suggest me possible workarounds.Thanks and Regards,
Pranav
- 10-21-2008, 02:05 PM #12
Umm, I think you should post a fresh topic for that. And to have a chance of getting good responses, you need to follow the advice here:
How To Ask Questions The Smart Way
db
- 10-21-2008, 02:30 PM #13
ok bruke.
i ll post it in a new post.
thank you.Thanks and Regards,
Pranav
- 10-21-2008, 02:32 PM #14
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Choose the correct sub-forum with a nice explanation. ;)
Similar Threads
-
How to Run a .exe in background???
By jazz2k8 in forum New To JavaReplies: 9Last Post: 01-21-2011, 11:27 AM -
BackGround & ForeGround
By hungleon88 in forum Advanced JavaReplies: 3Last Post: 08-31-2008, 07:20 AM -
setting background color of JFrame form with NetBeans 6.1
By onefootswill in forum New To JavaReplies: 4Last Post: 08-12-2008, 07:02 AM -
JButton onClick change color background
By behrk2 in forum AWT / SwingReplies: 6Last Post: 07-09-2008, 04:54 PM -
window background color?
By javan00b in forum New To JavaReplies: 3Last Post: 01-29-2008, 10:43 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks