I converted the FancyBox BSH GUI to Netbeans code, but the compiled version did not shown scrollbars if the window was too small to show all controls.
So I added a scroll pane at the end:
// Tabbed pane
JTabbedPane tabs = new JTabbedPane() {
{
add(generalPanel, "General");
add(webPanel, "Web page");
add(indexPanel, "Index page");
add(linksPanel, "Links");
add(slidePanel, "Slide page");
add(mapPanel, "Map");
add(musicPanel, "Music");
add(aboutPanel, "About");
}
};
JScrollPane scrollPane = new JScrollPane(tabs, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED) {
{
scrollPane.setBorder(BorderFactory.createEmptyBorder());
scrollPane.setOpaque(false);
scrollPane.getViewport().setOpaque(false);
add("hfill vfill", scrollPane);
}
};
{
add("vtop hfill vfill", tabs);
putClientProperty("helpPage", "https://www.andrewolff.nl/SkinsManual/");
}
};
// Set the UI
window.setSkinUI(ui);
window.pack();
}
}
This was compiled without errors in NetBeans, but after I loaded it in the skin I get a crash:
Stack trace for jAlbum 22.0.4 using skin FancyBox 3.0.0:
se.datadosen.util.ScriptException: java.lang.NullPointerException in onload.bsh at line number 1
at se.datadosen.util.ScriptException.of(ScriptException.java:59)
at se.datadosen.jalbum.AlbumBean.processScript(AlbumBean.java:2579)
at se.datadosen.jalbum.JAlbumFrame.executeScript(JAlbumFrame.java:1282)
at se.datadosen.jalbum.JMainSettingsPanel$5$1.run(JMainSettingsPanel.java:313)
Caused by: javax.script.ScriptException: bsh.TargetError: Sourced file: inline evaluation of: ``new FancyBox(engine); ;'' : Object constructor : at Line: 1 : in file: inline evaluation of: ``new FancyBox(engine); ;'' : new FancyBox ( engine )
Target exception: java.lang.NullPointerException
in inline evaluation of: ``new FancyBox(engine); ;'' at line number 1
at bsh.BshScriptEngine.evalSource(BshScriptEngine.java:90)
at bsh.BshScriptEngine.eval(BshScriptEngine.java:57)
at java.scripting/javax.script.AbstractScriptEngine.eval(Unknown Source)
at se.datadosen.jalbum.AlbumBean.doProcessExpression(AlbumBean.java:2636)
at se.datadosen.jalbum.AlbumBean.processExpression(AlbumBean.java:2621)
at se.datadosen.jalbum.AlbumBean.processScript(AlbumBean.java:2577)
... 2 more
Caused by: java.lang.NullPointerException
at FancyBox$1$10.<init>(FancyBox.java:2004)
at FancyBox$1.<init>(FancyBox.java:2002)
at FancyBox.<init>(FancyBox.java:136)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Line 2003 is the line starting with
JScrollPane scrollPane = new JScrollPane(
What do I wrongly?
Edit:
This was ofcourse not my own code, I did copy it from Pluto, but the Pluto code
JScrollPane scrollPane = new JScrollPane(tabs, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
scrollPane.setOpaque(false);
scrollPane.getViewport().setOpaque(false);
add("hfill vfill", scrollPane);
showed red lines below the last 4 lines. I could remove these ony by adding brackets as you see above.
Edit2:
I solved the crash with this code:
JScrollPane scrollPane = new JScrollPane(tabs, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED) {
{
setBorder(BorderFactory.createEmptyBorder());
setOpaque(false);
getViewport().setOpaque(false);
}
};
{
add("hfill vfill", scrollPane);
add("vtop hfill vfill", tabs);
putClientProperty("helpPage", "https://www.andrewolff.nl/SkinsManual/");
}
};
// Set the UI
window.setSkinUI(ui);
window.pack();
}
}
But I see no scrollbars on small windows, also not if I interchange the last 2 add statements.
Edited by: AndreWolff on 15-Oct-2020 10:47
Edited by: AndreWolff on 15-Oct-2020 10:55