Set theme properties on main pane of manual

master
skylarmt 10 years ago
parent c22ee3dea1
commit 6e76dcbb04

@ -101,9 +101,18 @@
<Component class="javax.swing.JEditorPane" name="topicBrowser"> <Component class="javax.swing.JEditorPane" name="topicBrowser">
<Properties> <Properties>
<Property name="editable" type="boolean" value="false"/> <Property name="editable" type="boolean" value="false"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
<Property name="contentType" type="java.lang.String" value="text/html" noResource="true"/> <Property name="contentType" type="java.lang.String" value="text/html" noResource="true"/>
<Property name="text" type="java.lang.String" value="&lt;html&gt;&#xd;&#xa; &lt;head&gt;&#xd;&#xa;&#xd;&#xa; &lt;/head&gt;&#xd;&#xa; &lt;body&gt;&#xd;&#xa; &lt;p style=&quot;margin-top: 0&quot;&gt;&#xd;&#xa; &#xd;Hi there&#xa; &lt;/p&gt;&#xd;&#xa; &lt;/body&gt;&#xd;&#xa;&lt;/html&gt;&#xd;&#xa;"/> <Property name="text" type="java.lang.String" value="&lt;html&gt;&#xd;&#xa; &lt;head&gt;&#xd;&#xa;&#xd;&#xa; &lt;/head&gt;&#xd;&#xa; &lt;body&gt;&#xd;&#xa; &lt;p style=&quot;margin-top: 0&quot;&gt;&#xd;&#xa; &#xd;Hi there&#xa; &lt;/p&gt;&#xd;&#xa; &lt;/body&gt;&#xd;&#xa;&lt;/html&gt;&#xd;&#xa;"/>
</Properties> </Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="topicBrowserMouseClicked"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="topicBrowser.setEditorKit(kit);"/>
</AuxValues>
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>

@ -31,6 +31,8 @@ import java.awt.Color;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.Calendar; import java.util.Calendar;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;
/** /**
* *
@ -40,40 +42,48 @@ public class Help extends javax.swing.JInternalFrame {
// True if this is a manual, false if about window // True if this is a manual, false if about window
private boolean topicOnLoad = true; private boolean topicOnLoad = true;
private final HTMLEditorKit kit;
private final StyleSheet styleSheet;
private final StyleSheet dark = new StyleSheet();
private final StyleSheet light = new StyleSheet();
/** /**
* Creates new form Help * Creates new form Help
*/ */
public Help() { public Help() {
kit = new HTMLEditorKit();
initComponents(); initComponents();
styleSheet = kit.getStyleSheet();
loadStyleSheets();
loadTheme(); loadTheme();
} }
/** private void loadStyleSheets() {
* Load the About window. dark.addRule("body { background-color: #293134; }");
* dark.addRule("h1 { color: #ffffff; }");
* @param about set it to whatever. dark.addRule("h2 { color: #ffffff; }");
*/ dark.addRule("p { color: #ffffff; }");
public Help(boolean about) { light.addRule("body { background-color: #ffffff; }");
initComponents(); light.addRule("h1 { color: #000000; }");
setSize(450, 352); light.addRule("h2 { color: #000000; }");
jSplitPane1.setDividerSize(0); light.addRule("p { color: #000000; }");
jSplitPane1.setDividerLocation(0.0);
jSplitPane1.setResizeWeight(0.0);
topicOnLoad = false;
loadTopic("about");
} }
private void loadTheme() { private void loadTheme() {
if (PrefStorage.getSetting("theme").equals("dark")) { if (PrefStorage.getSetting("theme").equals("dark")) {
topicList.setBackground(Color.BLACK); topicList.setBackground(new Color(41, 49, 52));
topicList.setForeground(Color.WHITE); topicList.setForeground(Color.WHITE);
styleSheet.addStyleSheet(dark);
styleSheet.removeStyleSheet(light);
setBackground(Color.DARK_GRAY); setBackground(Color.DARK_GRAY);
} else { } else {
topicList.setBackground(Color.WHITE); topicList.setBackground(Color.WHITE);
topicList.setForeground(Color.BLACK); topicList.setForeground(Color.BLACK);
styleSheet.addStyleSheet(light);
styleSheet.removeStyleSheet(dark);
setBackground(Color.LIGHT_GRAY); setBackground(Color.LIGHT_GRAY);
} }
loadTopic(topicList.getSelectedValue().toString().toLowerCase());
} }
public void loadTopic(String name) { public void loadTopic(String name) {
@ -182,8 +192,15 @@ public class Help extends javax.swing.JInternalFrame {
jSplitPane1.setLeftComponent(jScrollPane1); jSplitPane1.setLeftComponent(jScrollPane1);
topicBrowser.setEditable(false); topicBrowser.setEditable(false);
topicBrowser.setBorder(null);
topicBrowser.setContentType("text/html"); // NOI18N topicBrowser.setContentType("text/html"); // NOI18N
topicBrowser.setText("<html>\r\n <head>\r\n\r\n </head>\r\n <body>\r\n <p style=\"margin-top: 0\">\r\n \rHi there\n </p>\r\n </body>\r\n</html>\r\n"); topicBrowser.setText("<html>\r\n <head>\r\n\r\n </head>\r\n <body>\r\n <p style=\"margin-top: 0\">\r\n \rHi there\n </p>\r\n </body>\r\n</html>\r\n");
topicBrowser.setEditorKit(kit);
topicBrowser.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
topicBrowserMouseClicked(evt);
}
});
jScrollPane2.setViewportView(topicBrowser); jScrollPane2.setViewportView(topicBrowser);
jSplitPane1.setRightComponent(jScrollPane2); jSplitPane1.setRightComponent(jScrollPane2);
@ -224,6 +241,10 @@ public class Help extends javax.swing.JInternalFrame {
} }
}//GEN-LAST:event_formComponentResized }//GEN-LAST:event_formComponentResized
private void topicBrowserMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_topicBrowserMouseClicked
loadTheme();
}//GEN-LAST:event_topicBrowserMouseClicked
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane2;

@ -27,5 +27,6 @@
<br><b></b> <br><b></b>
<br><b></b> <br><b></b>
<br><b></b> <br><b></b>
</p>
</body> </body>
</html> </html>

Loading…
Cancel
Save