How do I overlap a table on java - java

I want two or more tables to be shown/overlapping each other.
Currently using netbeans
I'm using jFrame form so not manually creating a layout.
Can this be done?

Its possible using null as the layout manager (absolute positioning). You might also want to place each table in a separate JInternalFrame container as this will allow you to move and resize the tables freely withing the main window.

Related

Java - Placing of few buttons and textboxes using SWT

I need to place few buttons one under another and few textboxes in the same way using SWT.
When I'm doing that, they are next to each other and I cannot change it even using
button1.setLocation(new Point(100,20));
button2.setLocation(new Point(400,10));
Can I add those things to something similiar to SWING's JPanel and move/position it freely as I need? Or maybe another solution? As to let You know - I cannot use SWING here. It has to be SWT. The reason is that I have already a chart made with SWT. The buttons and textboxes should be placed so they won't be covering my chart.
You can dynamically add a new control to the existing layout, but make sure you call the layout() on the parent Composite, where you have set the layout.
If you want to place a SWT control relative to another control, you can use org.eclipse.swt.layout.FormLayout.

Dynamically resizable tables on a GUI

I have a GUI with a few JTextFields and JTables, and I would like to get the possibility to dynamically re-size the tables after running the application, so the user can increase the size of the tables by clicking on the border and dragging it.
I am considering this option or this post, but not sure if that´s what I need.
JTables are combined with table scrollers, and the GUI uses a JPanel with JGoodiesFormLayout, since it makes very easy to work with rows and columns.
Use JSplitPanes to divide the GUI where you want to allow the user to specify the component limits.

Cardlayout and objects?

Hi I am doing a small project using forms. Presently I used netbeans but my classes became very complex as all jpanel ie cards within one class which is a frame. I was asked to simplify.
My question is If I put one jpanel and it contents in one class.and make objects.
Can I use cardlayout on these objects? So that cards change within a single frame?
This problem stems from using the NetBeans GUI editor to manage the top-level container and everything in it. Instead, use the approach shown here to manage multiple separate forms that can be used in your frame's layout. See also Card Layout Actions, cited here.

how to add panel/jpanel or any panel of any package to composite in java?? (using RAP, SWT)

I am creating an RAP application in JAVA.
i want to have a GUI like master detail. in which left side has panel that has a tree (like in windows 7) and on the right side there will be text fields which will be changing when different TreeItem is selected.
So i have to add two panels, but i don't know how to add panels into composite.
Please help
use frame.getContentPane() to the the master contentpane. Set its layout as new GridLayout(1,2).
Now create two panels and add them to the frame. http://docs.oracle.com/javase/tutorial/uiswing/components/panel.html
There are also more complex solutions depending on what you want to do. For example if you want to make the division of the space between left and right side cosumizable use jsplitpanes (http://docs.oracle.com/javase/tutorial/uiswing/components/splitpane.html).
SWT is one thing, Swing is another. If you already have something written in SWT and want to add Swing components, then you have to use the SWT/AWT Bridge. You can find a tutorial on how to do this here.

Adding more than one JPanel in a single JFrame

I have created a JFrame - now I want to add the 4 JPanel in that frame at a particular location. How can set the location of panels in the frame?
Use (possibly nested1) layouts for the logic. See Laying Out Components Within a Container for details. They can:
Include default spacing in the constructor (often)
Calculate how big the GUI needs to be in order to display the components (in whatever PLAF, on whatever system the app. is deployed).
Extra spacing can be organized by adding an EmtpyBorder to child components.
See the nested layout example
Placing components in a container is quite a complicated subject in Swing. Instead of defining the exact places for your components, you would normally use a layout manager that arranges them in a certain way.
Here is the tutorial you should read to get a (visual) clue about the different layout managers: A Visual Guide to Layout Managers
However, the standard layout managers of Swing can be cumbersome for more complex layouts. Either, you could use nested layouts to get the desired result, or you could use a very powerful third-party library: JGoodies Forms. The downside is of course that you have to learn yet another library. Therefore, I would only recommend it for a bigger project.
For me it is good way to set GridbagLayout for the container of the frame. There are several visual swing GUI editors available to do this easily. You can use NetBeans GUI editor or GWT Designer (https://developers.google.com/web-toolkit/tools/gwtdesigner/) for complex GUI designing tasks
If its 4 locations, you can use BorderLayout,by default its the CENTRE, but it also have EAST, WEST , NORTH, SOUTH locations for the placement of the components. You can also use setLocation to put the panels in the appropriate locations, if a layout isn't used.
Its even better to use GroupLayout developed my NetBeans team in 2005, use Windows Builder Pro, now provided by google for free.
set the layout of the Frame to be null via setLayout(null)
create 4 JPanel and set their location using setLocation method
add these panels using JFrame's add method

Categories