-
-
Save uncoded-ro/79ef77a38dc1737cdbf91ec4610d8a23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ro.virtualcampus.gui; | |
import java.awt.*; | |
import javax.swing.*; | |
public class BoxLayoutApp { | |
public static void main(String args[]) { | |
JFrame container = new JFrame("Box Layout"); | |
JPanel panou = new JPanel(); | |
panou.setLayout(new BoxLayout(panou, BoxLayout.Y_AXIS)); | |
JButton buton1, buton2, buton3; | |
panou.add(buton1 = new JButton("Buton 1")); | |
buton1.setAlignmentX(Component.LEFT_ALIGNMENT); | |
panou.add(Box.createRigidArea(new Dimension(0, 10))); | |
panou.add(buton2 = new JButton("Buton 2")); | |
buton2.setAlignmentX(Component.CENTER_ALIGNMENT); | |
buton2.setMinimumSize(new Dimension(100, 25)); | |
buton2.setMaximumSize(new Dimension(500, 500)); | |
panou.add(Box.createVerticalGlue()); | |
panou.add(buton3 = new JButton("Buton 3")); | |
buton3.setAlignmentX(Component.RIGHT_ALIGNMENT); | |
container.add(panou); | |
container.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
container.pack(); | |
container.setVisible(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment