Java Swing: Make a dialog partially transparent. - java

I have a need to make my dialog partially transparent. Pull out a tab from google chrome to create a new window, while dragging the shape it makes is the shape that I want to make, minus see-through.
The point is that my dialog is a fairly simple and standard dialog, but I need one chunk of it cut out and transparent. Double points if that area is not part of the dialog so clicking there will lose focus from the dialog.

you can set the opacity.
http://java.sun.com/developer/technicalArticles/GUI/translucent_shaped_windows/#Setting-the-Opacity-Level-of-a-Window
I see what you mean by chrome page tab. In this case you may have to have an underlying panel which is transparent, this panel would then contain the tab in the top corner, and the rest of the page underneath. ie 2 separate components
hope that is what you very looking for

Related

How to get tab pane tabs rotated and visible when oriented on the left side?

I am currently trying to get the tabs on the tab pane to be rotated 90 degrees and visible completely.
My attempt has ended in this
Image
I was able to rotate it by adding a rotate styling to the tab itself, but i cannot resize the anchorpane, or tab at all.
After googling for a long time, I could only find this http:// javafx-jira.kenai.com/browse/RT-19547. It says that the only way they could do it is to "put the text into the tab's 'Graphic' to achieve this". I'm not sure what that means or how to accomplish that.
My end goal is to create tabs that have the same shape and feel as these (image)
In this solution:
http://oreilly.com/pub/a/mac/2002/03/22/vertical_text.html
The text was painted vertically and tried as an icon on the tab. This way you don't have to modify JTabbedPane you just use a custom Icon in the tab.
Of course you would also have to specify the tab placement to be on the Left.

How do I check to see if a whole component is on screen?

I'm working with a 3rd party plugin which includes a customized popup. This popup is added to a tab pane and when it appears, if to close to the JFrame border, only part of it will appear and the rest will draw off screen, as if it is behind the JFrame.
Is there anyway to check if a component bounds or its shape is completely visible to the user?
Check out the javadocs for SwingUtilities.convertPointToScreen.

Getting graphical buttons to line up in xml

I have a custom popup window with a custom image background in which I need to place three custom buttons with their own background images. I have only one set of images for all the components, so I want all the parts to scale appropriately. My question now is how do I make sure that the buttons line up with the appropriate parts of the background image of the popup window. I have been experimenting with all sorts of widths and heights and I can not make it look consistent on all my test devices. Can anyone give me some pointers?
EDIT: Just to make it as clear as possible, the image below illustrates the kind of thing I am talking about:
I want the graphical button to line up with the arrows which are a part of the popup window background image.
arrange buttons in an xml layout and set this view to your custom popup and you can set images to buttons from code.

Is it possible to make a window with a transparent background?

I was wondering if it would be possible to create a window using SWT that has either a transparent background or no background (i.e., just buttons and texts are shown floating).
I've tried using the setBackground() function like:
shell.setBackground(display.getSystemColor(SWT.TRANSPARENT));
but it will just show a window with a black background rather than a transparent one. any way to do this?
See How to Create Translucent and Shaped Windows (Java 7+).
..(SWT) uses the native window scheme, rather than an ugly/custom one. ..
Use Swing with the native PLAF.
Update 1
Me.
..you want component (button etc.), not Window (or ancestor) transparency?
To which you replied.
not necessarily the component itself, but the 'area' in which the component resides in. if you look at the Nested Layout Example above, you see the win 7's transparent border, then you see the normal gray background. I'd like that gray background to also be transparent.
You can create a window with per-pixel translucency, where each pixel has its own alpha value. With this feature you can, for example, create a window that fades away to nothing by defining a gradient in the alpha values.
And as an aside, that 3rd screenshot is actually the 2nd image ripped directly from the page that is linked in the 1st sentence of my reply (the same page where I got the above quote). Did you follow the link, read the page (look at the screenshots), try the working examples?

Swing: Floating panel next to the selected item in a JComboBox

I've created an app with a small window (the size of a combo box). I need to create a floating panel that sits outside the window, next to the selected item in a JComboBox. (See attached image).
I've been reading about the JComboBox.setRenderer(customRenderer) etc. But was just wondering before I go down this path, whether it is at all possible to render something outside the window. I suspect it is, as the combobox itself manages to render it's popup list outside the window.
I'm very new to Swing, so any advice would be appreciated.
It's not possible with the custom renderer since Swing components are light weight. That is, Java is given a native window and all the component drawing takes place in that window. In your case, that is the JFrame containing the combo box.
What you can do though is create a new undecorated window and set it's location accordingly and draw whatever you want inside it.
EDIT: When Java needs to paint outside it's window bounds (like the case of pop up messages or combo boxes drop downs) if the component falls inside the bounds it uses the swing light weight mechanism. But if the component falls out side the bounds it is automatically substituted with a awt heavy weight component that has it's own native drawing surface outside the active window.
I've implemented similar idea using combobox renderers and tooltips on them. Content of every item's tooltip can be customized and rendered using HTML. Location of the tooltip can be set outside of the item itself thus creating design very similar to the one presented in your question.
Here is the starting point for you:
http://www.java2s.com/Code/Java/Swing-Components/ToolTipComboBoxExample.htm

Categories