java - Using different layouts in GUIs -
That's my program should look like this and I'm a little confused why I should use different layouts.
I have a window class that calls the panel class and the panel calls the class input panel and the display panel class. My InputPlan class calls my details panel, the Cranial Panel and the Button Panel classes so that they can be seen under the input tab. I was asked to use a border line for the entire window, and that the DetailsPanel (left panel) and Crime Panel should have a grid layout.
What this means should be:
- Border layout code in the panel and the grid layout code in the Crime panel and details panel or
- Borders in the window Keep the layout code and gridlove code in the panel?
OK, your description is a bit confusing (or I am still very tired or not enough caffeine yet).
But as far as I can see it, your first option is correct.
Normally you nest on object runtime, it may look like this:
InputPanel + (Border Layout) + - DescriptionPanel (put in border layout. West ; Gridlove is). + - Name label | + - NameTextField | + --... + - Crim Panel (enter in border layout, North; is grid layout). + - KillReadyButton | + - Arnson Radiot Button | + --... + - ButtonPanel (Border layout has been inserted; Grid layout) + - Button
You usually do this in the appropriate category manufacturer:
public class input page {public input panel () {this.setLayout (new border layout ()); This.add (new detailspanel), border layout. West); This.add (New Crop Panel (), Border Layout. North); This.add (new button (panel), border layout .a); }} Public Class Details Panel {JLabel nameLabel; JTextField nameField; // ... public statementPanel () {this.setLayout (new gridlate (5, 1)); Name label = new jlabel ("name"); NameField = new JTextField (); // ... this.add (nameLabel); This.add (nameField); // ...}} ...
However, I see a small problem here: Since GridLayout
is used to span multiple columns Do not allow other panels to be nested in the DetailsPanel
on the left side, you can participate with a single GridBagLayout
, which has the necessary capabilities, or you are there Nestle the other panels:
DetailsPanel (is the border layout) + - Panel 1 (Grid layout with 2 rows Enter in column 1; border layout. North) | + - Name label | + - NameField + - panel2 (grid layout with 3 rows, 2 columns; borderout has been inserted in the seatier) + - Defined + - Delal + + - Monthfield + --...
Comments
Post a Comment