001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.dialogs; 003 004import static org.openstreetmap.josm.tools.I18n.tr; 005 006import java.awt.Dimension; 007import java.awt.GridBagLayout; 008 009import javax.swing.JLabel; 010import javax.swing.JPanel; 011import javax.swing.JScrollPane; 012 013import org.openstreetmap.josm.Main; 014import org.openstreetmap.josm.gui.ExtendedDialog; 015import org.openstreetmap.josm.gui.widgets.JosmEditorPane; 016import org.openstreetmap.josm.tools.GBC; 017 018/** 019 * Generic dialog with message and scrolling area 020 * @author Alexei 021 * @since 5114 022 */ 023public class LogShowDialog extends ExtendedDialog { 024 025 /** 026 * Constructs a new {@code LogShowDialog}. 027 * @param title The text that will be shown in the window titlebar 028 * @param msg Single-line Label 029 * @param log Multi-line log 030 */ 031 public LogShowDialog(String title, String msg, String log) { 032 super(Main.parent, title, tr("OK")); 033 setButtonIcons("ok"); 034 setContent(build(msg, log)); 035 } 036 037 protected final JPanel build(String msg, String log) { 038 JPanel p = new JPanel(new GridBagLayout()); 039 JLabel lbl = new JLabel(msg); 040 041 lbl.setFont(lbl.getFont().deriveFont(0, 14)); 042 043 p.add(lbl, GBC.eol().insets(5, 0, 5, 0)); 044 JosmEditorPane txt = new JosmEditorPane(); 045 txt.setContentType("text/html"); 046 txt.setText(log); 047 txt.setEditable(false); 048 txt.setOpaque(false); 049 050 lbl.setLabelFor(txt); 051 052 JScrollPane sp = new JScrollPane(txt); 053 sp.setOpaque(false); 054 sp.setPreferredSize(new Dimension(600, 300)); 055 056 p.add(sp, GBC.eop().insets(5, 15, 0, 0).fill(GBC.HORIZONTAL)); 057 058 return p; 059 } 060}