Java JButton mouse over color - java

I have a Java Swing application that's using "system" look and feel (as i'm using Windows, i'm getting "native Windows" controls in my app). Now, for "branding" reasons i'm trying to enforce particular color on my buttons but i have a problem. I prefer using UIManager but i can't find any property that would let me choose "button mouse over" color.
Take a look at the picture attached please:
Seems like i'm stuck with default Windows "light-blue" color for button mouse over (pointer is not visible in this screenshot).
How can i change that color?
For me only option is some sort of UIManager global variable, i simply can't afford to go through all buttons in my app and override some custom button or add listeners for "mouse enter" and "mouse exit".

The best way to do it is to customize the LAF of your application, using this library TinyLAF.
Very easy to use, with nice control panel to help do some theming and using the created theme file on your project.
Here is a small tutorial on how to use it in case the doc is not too clear
http://yourjavacode.blogspot.com.ng/2013/05/tinylaf-change-your-java-look-and-feel.html
I hope this helped out.

Related

Netbeans Swing UI designer - what does the hazard icon mean?

I'm working in the Design view of a Swing application and occassionally I see a small hazard warning symbol appear in the top corner of a component.
I assumed this was something to do with visibility overlap or similar but having adjusted things I can't match a guess against anything credible. Unfortunately it doesn't have a tool-tip and does not react to any mouse clicks.
Any ideas? Google does not seem to suggest anything either.
The NetBeans help topic, Java File and Object Node Icons, may help identify the icon in question. Tool tips on each icon indicate the relevant name. The one labeled error badge, for example, means "The file cannot be parsed."
It's a "free design" layout warning -- you put new component to panel/container without layout manager and need manually drag and resize it (e.g. attach it to container borders).

Auxiliary arrows in forms like in Eclipse

When you open a dialog in Eclipse, where is a form layout, you can see that when you hover your mouse over some item, its label or space between them, there's an auxiliary arrow shown. Screenshot:
My question is: is there any (simple) way to achieve the same in Java with SWT and JFace?
Regards
No there is no standard way to achieve this through SWT or JFace, as it is not a built in feature. It is not that difficult to add on your own though.
Have a look at this ConfigurationBlock.java file from the PDE source. This class is the base for all option blocks in PDE preference pages. This exact same code snippet is also used by JDT but it has a different copy in OptionConfigurationBlock.java.
The method that gets called for each combo control is ConfigurationBlock#addHighlight(..), which is responsible for adding the highlight when the control is in focus or when mouse is hovering over its label.

custom SWT component blinks when I interact with it

I'm building a small suite of widgets (here) for SWT.
I've done a Slider, but every time I change thevalue with the mouse wheel, it kinda blinks.
The source is available here.
What am I missing here?
I just added SWT.DOUBLE_BUFFERED to the component when instantiating they

How to make overlay for video in swing

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.

how to create a drop down menu java app on the desktop to hold desktop icons (java)

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.

Categories

Resources