use of jmri.util.swing.JmriPanel in project JMRI by JMRI.
the class JmriJFrameInterface method show.
@Override
public void show(final JmriPanel child, JmriAbstractAction act, Hint hint) {
// display cached frame if available
JmriJFrame frame = frames.get(child);
if (frame != null) {
frame.setVisible(true);
return;
}
// create frame
frame = new jmri.util.JmriJFrame();
// cache if single instance
if (!child.isMultipleInstances()) {
frames.put(child, frame);
}
// add gui object, responsible for own layout
frame.add(child);
// add menus if requested
List<JMenu> list = child.getMenus();
JMenuBar bar = frame.getJMenuBar();
if (bar == null) {
bar = new JMenuBar();
}
for (JMenu menu : list) {
bar.add(menu);
}
frame.setJMenuBar(bar);
// add help menu if requested
if (child.getHelpTarget() != null) {
frame.addHelpMenu(child.getHelpTarget(), true);
}
// set title if available
if (child.getTitle() != null) {
frame.setTitle(child.getTitle());
}
// if multi-instance, arrange to run dispose on close
if (child.isMultipleInstances()) {
frame.addWindowListener(new java.awt.event.WindowAdapter() {
jmri.util.swing.JmriPanel c;
{
c = child;
}
@Override
public void windowClosed(java.awt.event.WindowEvent e) {
c.dispose();
}
});
}
// pack and show
frame.pack();
frame.setVisible(true);
}
use of jmri.util.swing.JmriPanel in project JMRI by JMRI.
the class LicenseAction method makePanel.
@Override
public jmri.util.swing.JmriPanel makePanel() {
jmri.util.swing.JmriPanel p = new JmriPanel();
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
JScrollPane jScrollPane = new JScrollPane();
JTextPane textPane = new JTextPane();
// get the file
// NOI18N
InputStream is = FileUtil.findInputStream("resources/COPYING", FileUtil.Location.INSTALLED);
String t;
try (// file stored as ASCII // NOI18N
InputStreamReader isr = new InputStreamReader(is, "US-ASCII");
BufferedReader r = new BufferedReader(isr)) {
StringBuilder buf = new StringBuilder();
while (r.ready()) {
buf.append(r.readLine());
buf.append("\n");
}
t = buf.toString();
} catch (IOException ex) {
t = "JMRI is distributed under a license. For license information, see the JMRI website http://jmri.org";
}
textPane.setText(t);
// set up display
textPane.setEditable(false);
jScrollPane.getViewport().add(textPane);
p.add(jScrollPane);
// start scrolled to top
JScrollBar b = jScrollPane.getVerticalScrollBar();
b.setValue(b.getMaximum());
return p;
}
Aggregations