I am developing a j2me midlet application with netbeans how ever I am new to java but I have developed all things i need. But I cannot change background color or image when I run the jar file on mobile it show a transparent or white color background is there any possible way to change background color or image any answered will be appreciated.
You cannot do anything about the background when working with High Level GUI (meaning Form stuff).
If you want to control the background, you'll need to use Canvas - but Form elements can't be used on a Canvas.
Best option then is to use LWUIT. It gives you a set of elements like you have with Form, but because it uses Canvas you have much more options and such.
Related
My friend and I are working together to write a Java program, and I am taking on the task of designing the GUI. Our GUI requires a background image for the JFrame, and the image needs to be able to change based on the user's actions. I have placed the images that I want to use as the background in the project as a resource, and I would like to ask for help finding the resource path, and setting the resource path as the background image in the JFrame.
I am using the Swing GUI Builder for NetBeans to design the GUI. Can someone please offer me some help? I have no experience with GUIs, and my friend has little experience with basic Java coding, so we are assigning parts based on our knowledge.
If you don't want to resize the images (as the frame changes), you could simply set the frames layout to BorderLayout and use a JLabel to display the images. Otherwise you will need to construct a custom component (using something like JPanel) and render the image yourself
Looking up embedded resources is a simple process of using something like getClass().getResource(...), where the parameter is the path to the resource, where the root is the top level source folder in your project.
Take a look at...
Java: maintaining aspect ratio of JPanel background image
Performing custom painting
2D Graphics
I want to make a transparent overlay for a foreign project to show live video. Sample of overlay is given in the image link below. In image you can see a overlay at right bottom corner showing face of a person, I also want to achieve same functionality using JMF to show face and then display the face in overlay using swing.
Sample Overley Imahe: http://www.ovostudios.com/images/vidsamsolo.jpg
Can someone help achieving this functionality?
If you're just starting the project and haven't actually got the JMF part up and running yet, then you might want to take a look at some alternatives before committing to it.
If you want to go ahead with Swing, to get the general overlay behaviour you want, you'll need to make use of Frame.setUndecorated() to turn off window borders and buttons, and Window.setAlwaysOnTop() to make sure the window stays on top of other windows. For the transparency, see this tutorial. However, I'm not sure whether transparency and video will work nicely together, so good luck!
You might also want to write a custom focus handler for the window so that it cannot be focused, although it is probably impossible for the overlay to be properly 'phantom' whereby clicks just pass through the overlay to the underlying desktop. That kind of behaviour might only be possible by using low-level graphics techniques i.e. by not creating a window at all, but by drawing directly onto the screen. That might require a native library.
Is it possible to simply paint() (or use some other function) to the screen in Java? As in draw over everything else on some coordinates of the screen itself, not inside some window.
If not, is it possible to make an invisible window that takes up the entire screen and use its glass pane to do it? Would complications arise from doing this? (Such as not being able to click on other applications)
Are there any other ways?
Thanks.
Edit: I'm not trying to do full screen with this, by the way.
When you paint() in Java, you're painting only within the confines of the size and location of what is being paint()ed.
If you're looking to do full screen stuff, there are tutorials for that:
http://download.oracle.com/javase/tutorial/extra/fullscreen/index.html
In theory, you can create an transparent undecorated maximized JFrame. This will allow you to "paint" over the desktop. Problems are obvious: if an application stays behind this window, it will not receive any mouse events.
Months ago, I made an evil cheat to draw directly on Windows Explorer's Desktop: mixing some .NET coding with JNI and Sun's internal classes - that's surreal, but works.
I am developing a Java applet which uses PNG-24 for icons. These icons are transparent but they simply refuse to be transparent in the app. The background always ends up white.
Is anyone familiar with this are and can give any pointers?
Thanks Mathias.
This page seems to give some ideas:
http://www.rgagnon.com/javadetails/java-0265.html
Katrien
I'm trying to create a java desktop application that holds desktop icons. The app will be a menu/panel that is invisible until you hover your cursor near the top of the screen, at which point the menu full of desktop icons will drop down. To add new icons to the menu one must simply drag icons from the desktop into the menu and they should snap to grid. As I am an intermediate level programmer but I havn't ever done a GUI app before in any language, I was wondering if someone could help me out, both with how to approach the problem and on the packages and methods I should be using. Also, I'm thinking of doing this with NetBeans unless you have any other suggestions.
Thanks,
Andrew
As an alternative to Chad's option, you could also do this by creating a frame and using Java's transparent window capability to make the frame transparent (or translucent, if you want a hint that it's there), and using mouse entered/exited events to return the frame to its normal "solid" opacity.
Personally I'd try this solution just because I'd rather use event-based notification than polling the mouse position, but I expect it's more work than the other alternative.
As to drag and drop, I haven't used it extensively enough in Java to give any solutions, but it's not immediately obvious (from a cursory internet search) of how to handle native desktop drag and drops. I'd suggest starting with some dnd tutorials within an application so that you really understand Java's drag and drop API and capabilities.
You can use java.awt.MouseInfo to get the location of the mouse at any point in time, even if you don't have any windows open.
So, you could start a java program, then in your main loop poll the mouse location. If it's in the 'top', then you can open a window.
You can use the easiest thing to do would be to use JButtons or JLabels with images to represent the desktop icons. Just load the image you want to use and stick that on as a label.
I'd start by going through swing tutorial and writing a few simple GUI programs to get the hang of it.
But the MouseInfo thing is what you need to tell when the mouse is at the top of the screen.