I need to create a panel which is partially transparent and which blurs what appears behind the panel. Such as the title bar in widows 7. Help me if someone knows how to do this very simply
Related
I was trying to make a simple GIF capturing app, but I needed to make a hole/transparent space in a JFrame based on a JPanel.
I tried many things, from per-pixel transparency (only works with undecorated windows...), custom shapes (again, undecorated windows only), etc...
This is what I want (edited):
This is what I have:
In .NET Framework, it's as simple as setting the TransparencyKey color of the form, and setting the panel's background color to that color.
I'm wondering if this is possible....
I have jLabel with an icon wanna put in right top corner , in Netbeans design view I place it to a desired position , After running program it is stay there fine ! But when I maximize the window it doesn't horizontally move to the corner and keep its position. It becomes like in the middle.
Thanks
Don't use a design tool to create the GUI. Its sounds like Netbeans is using a absolute layout which is not what your want.
Use a proper layout manager. Maybe a FlowLayout that is right aligned.
Read the section from the Swing tutorial on How to Use Flow Layout for more information and working examples.
I have some JButtons in a JFrame (its layout is null). The background Color of the buttons are set Black. I have made the JFrame Transparent by using this code.
AWTUtilities.setWindowOpacity(this, 0);
But the problem is it also makes all the buttons transparent as well. I don't want that. I want to see the buttons remaining black but the other portions of the JFrame becoming transparent (so that I can see the desktop background). Please someone help me.
Thanks in advance.
What about using the call button.setOpaque(true) ?
Yeh, the problem was opacity set to zero. Any non-zero value with all button.setOpaque(true), will display buttons clearly. For me, AWTUtilities.setWindowOpacity(frame, 0.7f) works too.
I'm developing a graphic interface using Java and Swing, and I'm having a hard time getting the JButtons to stay in their position while changing from one panel to another.
There are three buttons in a row aligned in the left bottom of each panel, all the panels the same size, but somehow they manage to change their position a little when I run the application (on the design preview they show up in the right place). It's getting a bit annoying. I'd appreciate any help
Are you trying to do tabs? If you are, a JTabbedPane will do this much better than a button.
Since you are using the Netbeans GUI Builder, look at the options in the Component panel on the left. It has Swing tabbed panes and AWT panes if you really want.
i am decent with java programming, but very new to GUI development. i wanted to make a console blackjack game i made years ago into one where people can play via a GUI i build using netbeans. i think that without a GUI, most people won't take the game seriously when i add it to my working portfolio
i created a JFRAME with the size set to 1000X700 pixels and on top of that is a JPanel with a background of dark green to simulate a blackjack table.
on top of the the dark green JPanel I have a small 60X93 JLabel with the icon set to be the back of a playing card. this represents the dealer and i wanted to CENTER it horizontally and vertically on top of the JPanel on which it rests.
however, in the netbeans tool bar for the particular GUI the "center horizontally" and "center vertically" options are greyed out and not clickable even when i select the JLabel which is the dealer. i even tried shift clicking to select both the JLabel AND the JPanel on which it rests but still the "center horizontally" and "center vertically" options are greyed out.
can someone please help me or offer guidance please? thank you... i have spent 2 days googling and i don't understand how others have not run into this same problem.
Interesting question. I've been working with NetBeans for years, and to be honest I've never even noticed those icons before until you just pointed them out. I'm unable to make them do anything either.
However, if you're new to GUI development in Java... you should read about layout managers, and spend some time with the GridBagLayout tutorial. GridBagLayout is by far the most popular layout manager in Swing development. You could get by using it exclusively if you wanted, as there are really only a handful of real-word situations in which it makes more sense to use another layout manager.
For your immediate purposes: In your Inspector view, right-click on the JPanel and select "Set Layout -> Grid Bag Layout". You'll now see your layout manager in the Inspector tree view right below your JPanel. Right-click on it and select "Customize". A window will pop-up, and there you can click on any component you're interested in and adjust all kinds of settings (e.g. margins, padding, etc). The setting in which you are interested is "Anchor", and the value you want is "Center". With your JLabel selected, you can adjust this setting either from the pull-down menu at the top-left... or graphically at the top-bottom.
One way or the other, if you're going to do any kind of Java GUI development beyond the most trivial of "Hello World" examples... you're going to be using GridBagLayout very soon. So you might as well dive in!
Let me provide some explanation about the tool button options "Center Horizontally" and "Center Vertically"
All the six toolbar buttons provided on the Matisse Designer are for alignment of the components related to each other. Those buttons only get activated when you select more that one component on the designer.
When we select two or more components on the designer window, may it be JPanel or JFrame, and click the "Center Horizontally" button all the selected controls (components) are aligned one below the other such that the center points of all the components are in one vertical line. That means they are moved in the horizontal direction to make them align exactly one below the other.
The "Center Vertically" button does this alignment in the vertical direction. So to answer your question the tools you are using for centering a component in JFrame are incorrect tools. They are for aligning components relatively to each other and not the container.
If you select a JPanel and a component inside the JPanel the tool buttons get disabled. The alignment setting buttons are available only when components are selected in the same container, in other words the components who are under same container.
To arrange a component in the center of the JFrame you may have to add some custom code or use some other layout manager other that Group Layout which is used by default by the designer.
with regards
Tushar Joshi, Nagpur