Я пытаюсь использовать диспетчер макетов MigLayout для создания графического интерфейса, который позволяет перемещать элементы из одного списка в другой. Мне нужны стрелки, чтобы они были близко друг к другу (по вертикали). Проблема, с которой я сталкиваюсь, заключается в том, что верхняя стрелка находится наверху ячейки, и я не увенчался успехом, чтобы переместить ее вниз. Я пытаюсь использовать функцию Cell для MigLayout, но я буду использовать все, что работает. Спасибо.Java MigLayout Vertical Alignment
public class StackCode extends JPanel{
public StackCode(){
super(new MigLayout());
JButton run = new JButton("Okay");
JButton cancel = new JButton("Cancel");
JList uList = new JList(new String[]{"test1","test2","test3","test4","test5"});
JList nList = new JList();
uList.setBorder(new LineBorder(Color.black));
nList.setBorder(new LineBorder(Color.black));
uList.setPreferredSize(new Dimension(100,150));
nList.setPreferredSize(new Dimension(100,150));
add(run,"cell 0 0");
add(cancel,"cell 1 0 4 1");
add(new JLabel("List1"),"cell 0 1 2 1"); // List1 title label -- cell column row width height
add(new JLabel("List2"),"cell 4 1 2 1"); // List2 title label
add(uList,"cell 0 2 2 5"); // JList1
add(nList,"cell 4 2 2 5"); // JList 2
add(new JLabel("-->"),"cell 3 3 1 3, align center"); // eventually import arrow image
add(new JLabel("<--"),"cell 3 6 1 1, align center"); // eventually import arrow image
}
private static void createAndShowGUI(){
//Create and set up the window.
JFrame frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
StackCode newContentPane = new StackCode();
newContentPane.setOpaque(true); //content panes must be opaque
frame.setContentPane(newContentPane);
//Display the window.
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
отредактировано, чтобы включать в себя изображение желаемой графики.