added padding

This commit is contained in:
COLIN Cyril 2019-10-16 13:50:27 +02:00
parent 7a1ca1ef65
commit 7df6aef090
3 changed files with 9 additions and 1 deletions

View File

@ -43,11 +43,13 @@ public class ElevatorApplication implements ActionListener {
canvas.setAlignmentY(Component.TOP_ALIGNMENT);
pane.add(canvas);
pane.add(Box.createRigidArea(new Dimension(40, 0)));
FloorPanels fp = new FloorPanels(5, simulation);
fp.setAlignmentY(Component.TOP_ALIGNMENT);
pane.add(fp);
pane.add(Box.createRigidArea(new Dimension(20, 0)));
pane.add(Box.createRigidArea(new Dimension(40, 0)));
ElevatorPanel elevatorPanel = new ElevatorPanel(5, simulation);
elevatorPanel.setAlignmentY(Component.TOP_ALIGNMENT);

View File

@ -1,6 +1,7 @@
package gui;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import commandSystem.ElevatorListener;
@ -26,6 +27,7 @@ class ElevatorPanel extends JPanel {
}
});
this.add(buttons[i]);
this.add(Box.createRigidArea(new Dimension(0, 5)));
}
emergencyStop.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@ -33,6 +35,7 @@ class ElevatorPanel extends JPanel {
}
});
add(emergencyStop);
this.add(Box.createRigidArea(new Dimension(0, 5)));
cancelEmergencyStop.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
l.cancelEmergency();

View File

@ -22,6 +22,7 @@ class FloorPanels extends JPanel {
floors[i] = new JPanel();
floors[i].setLayout(new BoxLayout(floors[i], BoxLayout.LINE_AXIS));
floors[i].add(new JLabel("" + i));
floors[i].add(Box.createRigidArea(new Dimension(5, 0)));
if (i < nbFloors - 1) {
final int j = i;
JButton upButton = new JButton("");
@ -31,6 +32,7 @@ class FloorPanels extends JPanel {
}
});
floors[i].add(upButton);
floors[i].add(Box.createRigidArea(new Dimension(5, 0)));
}
if (i > 0) {
final int j = i;
@ -43,6 +45,7 @@ class FloorPanels extends JPanel {
floors[i].add(downButton);
}
this.add(floors[i]);
this.add(Box.createRigidArea(new Dimension(0, 5)));
}
}
}