Change the default position of the laid out component

This commit is contained in:
Sergey Malenkov
2014-10-20 16:18:45 +04:00
parent 631701078b
commit fb19e737bf
3 changed files with 12 additions and 12 deletions
@@ -112,12 +112,12 @@ public final class HorizontalLayout implements LayoutManager2 {
@Override
public void addLayoutComponent(String name, Component component) {
synchronized (component.getTreeLock()) {
if (name == null || CENTER.equalsIgnoreCase(name)) {
myCenter.add(component);
}
else if (LEFT.equalsIgnoreCase(name)) {
if (name == null || LEFT.equalsIgnoreCase(name)) {
myLeft.add(component);
}
else if (CENTER.equalsIgnoreCase(name)) {
myCenter.add(component);
}
else if (RIGHT.equalsIgnoreCase(name)) {
myRight.add(component);
}
@@ -242,7 +242,7 @@ public final class HorizontalLayout implements LayoutManager2 {
if (result == null) {
result = new Dimension();
}
else if (aligned) {
else if (aligned && center != null) {
int leftWidth = left == null ? 0 : left.width;
int rightWidth = right == null ? 0 : right.width;
result.width += Math.abs(leftWidth - rightWidth);
@@ -112,12 +112,12 @@ public final class VerticalLayout implements LayoutManager2 {
@Override
public void addLayoutComponent(String name, Component component) {
synchronized (component.getTreeLock()) {
if (name == null || CENTER.equalsIgnoreCase(name)) {
myCenter.add(component);
}
else if (TOP.equalsIgnoreCase(name)) {
if (name == null || TOP.equalsIgnoreCase(name)) {
myTop.add(component);
}
else if (CENTER.equalsIgnoreCase(name)) {
myCenter.add(component);
}
else if (BOTTOM.equalsIgnoreCase(name)) {
myBottom.add(component);
}
@@ -242,7 +242,7 @@ public final class VerticalLayout implements LayoutManager2 {
if (result == null) {
result = new Dimension();
}
else if (aligned) {
else if (aligned && center != null) {
int topHeight = top == null ? 0 : top.height;
int bottomHeight = bottom == null ? 0 : bottom.height;
result.width += Math.abs(topHeight - bottomHeight);
@@ -66,9 +66,9 @@ final class Banner extends JPanel {
}
else {
if (i > 0) {
myLeftPanel.add(HorizontalLayout.LEFT, RelativeFont.HUGE.install(new JLabel("\u203A")));
myLeftPanel.add(RelativeFont.HUGE.install(new JLabel("\u203A")));
}
myLeftPanel.add(HorizontalLayout.LEFT, RelativeFont.BOLD.install(new JLabel(name)));
myLeftPanel.add(RelativeFont.BOLD.install(new JLabel(name)));
}
i += 2;
}