List of buttons in swing - java

I would like to implement a list of interactive buttons using Swing. It is something similar as on the picture (from NetBeans UI designer):
You can drag and drop the items to a canvas, or single click on the item and then single click on the canvas. However, I don't know which swing components I should use. Are that JList or JButtons or something different?

There is a tutorial avalaible on how to achieve such functionality. It is utilizing the NetBeans Palette API, which makes you dependent on NetBeans as Framework, not IDE.

Depending on the goal, you might want to look into developing for the NetBeans Platform.

Related

How to show GUI design view in java.class?

I'm linking a database to NetBeans now and I need to create a interface for this. But when I need to adjust the position of button, label is difficult. Is it possible that show a GUI design view that easy for me to adjust without use the JFrame component?
If I understood your question correctly, you're looking for a GUI builder for Swing.
Netbeans ships with the Matisse Swing GUI Builder which will help you build GUIs easily and quickly. Tutorials aren't uncommon (such as the official tutorial or some user created videos on YouTube).
Some folks are fine with this work flow (since it speeds up development quite a bit). Others want to use custom frameworks and have requirements to use specific layouts in which case I recommend reading about different layout managers.
Take your pick and happy development! :)
Instead of trying to design your entire application in the GUI editor, you may be able to adapt the approach shown here. This will let you focus on a single container at a time. Also, remember to backup your .form files; more here.

How to create the windows 8 FLAT native look in Java Swing programming?

I am creating a java swing application and I am badly need to get the flat GUI look like in windows 8 to my swing application. But I couldn't find it yet. Can you help me?
You can PROBABLY use the default look and feel of swing apps, undecorate everything, and for those icons; I would use buttons with internal panels, images, labels, etc. To get the scroll functionality you should use mouse listeners to detect scrolling and slide the ui accordingly.

Netbeans Java Swing Components undragable

I am trying to learn Java Swing with the aid of the Netbeans IDE. Following this tutorial, I find myself stuck when I try adding a Panel to a JFrame.
The Panel, or any other component from the Swing Container, does not add to my design view.
I have tried dragging and right-clicking the component without success.
When I right-click the Panel component, I get various menu options including "paste item" but it is greyed out and inactive.
Just click on the palette "Swing Containers" Panel button. In 7.2 and 7.2.1 it is a toggle switch. Then go to your JPanel and you will see your new JPanel moving along with your cursor. Move it to the location you want to have it and click again. Then you can resize it to the dimensions you like...
Netbeans IDE is an excellent production tool. If you are in the learning phase however, it is always better to avoid using powerful GUI-editors, in order to gain a better understanding of the concepts. You can do that using simple text editors.
You will find these links helpful: The Swing Tutorial, Java2s tutorial and Java Beginner Tutorial. And certainly you can ask Stackoverflow if you get stuck at some point, or want an opinion
...

Regarding swing containers

I was doing a research, I have the below application in that we have the following swing layout..
Now the thing is that this same ting I want to develop I was using swing designer of google framework ..
Please advise me what container layout and extras other things do I need t build this same forat through swing designer and I aslo later want to customize it.
As I understand, your problem is resizing two buttons equally? Well, I'd use Mig Layout, create two columns, that will scale 50% each.

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