public SongDetailsDialog(Lied lied) { DialogUtils.assignMusikgehirnIconToWindow(this); JPanel panel = new JPanel(new BorderLayout()); panel.add(createSongInformationPanel(lied), BorderLayout.CENTER); setContentPane( new JScrollPane( panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); if (StringUtils.isNotEmpty(lied.getCoverPfad())) { try { JLabel coverImage = new JLabel(new ImageIcon(ImageLoadUtil.loadImage(lied.getCoverPfad(), 100))); panel.add(coverImage, BorderLayout.NORTH); setMinimumSize(new Dimension(500, 300)); } catch (IOException e) { LOGGER.error("Cover image could not get loaded"); setMinimumSize(new Dimension(500, 200)); } } else { setMinimumSize(new Dimension(500, 200)); } setResizable(false); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); }
private Component createSongInformationPanel(Lied lied) { JPanel panel = new JPanel(); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup(); JLabel titleLabel = new JLabel( "<html><b>" + MusikbrainMessages.getString(MusikbrainMessages.TITEL) + "</html></b>"); JLabel interpretLabel = new JLabel( "<html><b>" + MusikbrainMessages.getString(MusikbrainMessages.INTERPRET) + "</html></b>"); JLabel albumLabel = new JLabel( "<html><b>" + MusikbrainMessages.getString(MusikbrainMessages.ALBUM) + "</html></b>"); JLabel durationLabel = new JLabel( "<html><b>" + MusikbrainMessages.getString(MusikbrainMessages.DAUER) + "</html></b>"); JLabel filepathLabel = new JLabel( "<html><b>" + MusikbrainMessages.getString(MusikbrainMessages.DATEIPFAD) + "</html></b>"); JLabel title = new JLabel(lied.getTitel()); JLabel interpret = new JLabel(lied.getInterpret()); JLabel album = new JLabel(lied.getAlbum()); JLabel duration = new JLabel(lied.getDauer().toString()); JLabel filepath = new JLabel(lied.getFile().getAbsolutePath()); hGroup.addGroup( layout .createParallelGroup() .addComponent(titleLabel) .addComponent(interpretLabel) .addComponent(albumLabel) .addComponent(durationLabel) .addComponent(filepathLabel)); hGroup.addGroup( layout .createParallelGroup() .addComponent(title) .addComponent(interpret) .addComponent(album) .addComponent(duration) .addComponent(filepath)); layout.setHorizontalGroup(hGroup); GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup(); vGroup.addGroup( layout .createParallelGroup(Alignment.BASELINE) .addComponent(titleLabel) .addComponent(title)); vGroup.addGroup( layout .createParallelGroup(Alignment.BASELINE) .addComponent(interpretLabel) .addComponent(interpret)); vGroup.addGroup( layout .createParallelGroup(Alignment.BASELINE) .addComponent(albumLabel) .addComponent(album)); vGroup.addGroup( layout .createParallelGroup(Alignment.BASELINE) .addComponent(durationLabel) .addComponent(duration)); vGroup.addGroup( layout .createParallelGroup(Alignment.BASELINE) .addComponent(filepathLabel) .addComponent(filepath)); layout.setVerticalGroup(vGroup); return panel; }