@PostConstruct protected void init() { // Button listeners: jb_add.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { add(); } }); jb_addAndClose.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addAndClose(); } }); jb_cancel.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cancel(); } }); jb_file.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectFile(); } }); // Default button: getRootPane().setDefaultButton(jb_add); // Layout: Container c = getContentPane(); c.setLayout(new BorderLayout()); { // Center JPanel jp = new JPanel(new BorderLayout()); JPanel jp_west = new JPanel(new GridLayout(3, 2)); jp_west.add(new JLabel(" Content type: ")); jp_west.add(new JLabel(" File name: ")); jp_west.add(new JLabel(" File: ")); jp.add(jp_west, BorderLayout.WEST); JPanel jp_center = new JPanel(new GridLayout(3, 2)); jp_center.add(jp_contentType.getComponent()); jp_center.add(UIUtil.getFlowLayoutPanelLeftAligned(jtf_fileName)); JPanel jp_file = new JPanel(new FlowLayout(FlowLayout.LEFT)); jp_file.add(jtf_file); jp_file.add(jb_file); jp_center.add(jp_file); jp.add(jp_center, BorderLayout.CENTER); c.add(jp, BorderLayout.CENTER); } { // South JPanel jp = new JPanel(); jp.setLayout(new FlowLayout(FlowLayout.RIGHT)); jp.add(jb_cancel); jp.add(jb_add); jp.add(jb_addAndClose); c.add(jp, BorderLayout.SOUTH); } pack(); }