How to set JLabel over(in) JLabel in Netbeans only using designer - java

Can you tell me please how to put Jlabel over/in another JLabel, but only using
Netbeans designer.
I make new form, drag 1st JLabek into it, i set icon (background image), and now
I want to drag new JLabel to be shown over 1st JLabel.
I need just a tip now to do this in designer. I have a code for this, but as I said i would like to know is it possible to do with designer
thanx

Yes, actually you can do it pretty easy with designer BUT you're going to need JPanel with null layout
Create form using netbeans (right click on package, new - JFrame Form...
Drag and drop panel
MOST IMPORTANT: right click on panel from navigator -set Layout -null Layout
now you can drag and drop your labels and put it one on another

Related

Is there is an equivalent of Jpanel in GWT?

Hi I am using GWT and I want to create a new panel whenever a button is clicked. Which widget in GWT will help me to create a new panel like that of Java's Jpanel?
http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/client/ui/Panel.html please look at "Direct Known Subclasses". You can add any, don't forget to add your panel to RootPanel or to a panel which is already visible.

java swing jpanel display when clicking a button

i'm new to swing. i've created a jpanel form using the swing palette design. It has jlabels, jtextfields and a jbutton. when the button is clicked, the data entered in the jtextfields is inserted in the database through the model.
i don't want the the jpanel to be always displayed so i would like to add another button that displays this jpanel form when i click on it. is it possible to perform this using the palette design knowing that the source code is locked in the initComponent private function, or do i have to re-code all the components and layout myself?
thanks for your time!
"knowing that the source code is locked in the initComponent private function"
You can edit the auto-generated source code, as see here in this answer.
"that displays this jpanel form when i click on it. is it possible to perform this using the palette design"
Sounds like you want to swap views. You can do that using CardLayout and yes, it can be done from the design view. You can see more at How to Use CardLayout with Netbeans GUI Builder

How to switch bewteen panels in WindowBuilder (Java)

i'm using Windowbuilder in Eclipse indigo.
I have a main JPanel, and I want to add a new Panel which will popup when I click a button.
How can I see the new Panel insted of the main panel in the Design frame?
thanks!
There should be a window that is part of the Structure View called "Components". Click on the new JPanel from there. I did this a while ago but I do not currently have windowbuilder installed so I am not 100% positive. I will confirm it when I can.
Edit: Ok i took a look at it. Here's how it works. If you made a new Application Window, make sure the palette view is open (Window->Show View->Palette). Now I am pretty sure the best way to switch between panels is by using a card layout. So drag the card layout from the palette to the window. Now if you drag JPanels from the palette to getContentPane() in the components window, you can switch between those panels with buttons and such.
Each panel should be created as its own subclass of JPanel in its own file. It is a very bad idea to use inner classes for something like this. WB intentionally does not support that style.

animation for drag and drop JLabel

I have ask alot of question about drag and drop for JLabel , but im learning from them ,im trying to drag and drop JLabel with image icon inside it , i want to be able to make a copy from it and drag it while user can see the image moving with the mouse and drop it in another JLabel , also i want to move it from one JPanel to another,how i can do this ?
In principle, you need the java.awt.dnd package.
Get a DragSource, associate it with your source JLabel. Create a DropTarget, associate it with your target JLabel.
Add the right listeners (DropTargetListener, DragSourceListener), and react on the method calls appropriately.
Okay, seriously: Read the tutorial, try to implement it, and come back if you have more concrete problems.

Netbeanw does not refresh JPanel after adding new components

this title may not best describe my problem. I'm using Netbean GUI builder to create a JFrame and several JPanels. I create each JPanel in a seperate class, then I drag the JPanel class to JFrame. The problem is after dragging the JPanel to JFrame, if I add components to JPanel, it does not show the additional components in the JPanel contained in JFrame. I tried "clean and build" but the new component still not showing in JFrame -> JPanel.
Matisse keeps a cached copy of any component you add to the palette. So, subsequent changes are not automatically picked up. To pick up the changes:
save and close your JFrame source
Make sure the JPanel component is compiled.
Click Tools > Palette > Swing/AWT Components
Right click on the tree and choose Refresh
Open your JFrame component. It should now be showing the updated components
I know what you mean; Matisse (NetBeans' GUI editor) lets you drag and drop self-assembled Containers (e.g. JPanels) into other Containers (e.g. JFrames), but any subsequent changes in the former will not be reflected in the latter. As far as I know, that's just the way it works, unfortunately.
It's one of the reasons I think Matisse can only be used for quick prototyping and toying around. For anything serious, the GUI must be hand-coded.
Had the same problem, all you have to do is:
1) re-compile the new JPanel subcomponent
2) close the form associated with the parent JPanel
3) re-open the parent Jpanel again from the Project tree
The refreshed subpanel should now be shown. Matisse only renders the subpanel when you either open a form or add the new subpanel. So, the only way to refresh the display without removing and re-adding the subpanel is to close and reopen it.

Categories

Resources