A complete 3D game development suite written purely in Java.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
jmonkeyengine/sdk/jme3-welcome-screen/src/com/jme3/gde/welcome/WelcomeScreenTopComponent.java

185 lines
7.7 KiB

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.jme3.gde.welcome;
import com.jme3.gde.welcome.rss.RssFeedParser;
import java.io.IOException;
import java.net.URL;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.html.StyleSheet;
import org.netbeans.api.settings.ConvertAsProperties;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.HtmlBrowser.URLDisplayer;
import org.openide.util.Exceptions;
import org.openide.windows.TopComponent;
import org.openide.util.NbBundle.Messages;
/**
* Top component which displays something.
*/
@ConvertAsProperties(
dtd = "-//com.jme3.gde.welcome//WelcomeScreen//EN",
autostore = false)
@TopComponent.Description(
preferredID = "WelcomeScreenTopComponent",
//iconBase="SET/PATH/TO/ICON/HERE",
persistenceType = TopComponent.PERSISTENCE_ALWAYS)
@TopComponent.Registration(mode = "editor", openAtStartup = true)
@ActionID(category = "Window", id = "com.jme3.gde.welcome.WelcomeScreenTopComponent")
@ActionReference(path = "Menu/Window" /*, position = 333 */)
@TopComponent.OpenActionRegistration(
displayName = "#CTL_WelcomeScreenAction",
preferredID = "WelcomeScreenTopComponent")
@Messages({
"CTL_WelcomeScreenAction=WelcomeScreen",
"CTL_WelcomeScreenTopComponent=WelcomeScreen Window",
"HINT_WelcomeScreenTopComponent=This is a WelcomeScreen window"
})
public final class WelcomeScreenTopComponent extends TopComponent implements HyperlinkListener {
private final RssFeedParser parser = new RssFeedParser("http://jmonkeyengine.org/feed/rdf/");//"http://www.chip.de/rss/rss_tests.xml");
public WelcomeScreenTopComponent() {
initComponents();
jScrollPane2.setOpaque(false);
jScrollPane2.getViewport().setOpaque(false);
jScrollPane3.setOpaque(false);
jScrollPane3.getViewport().setOpaque(false);
setName(Bundle.CTL_WelcomeScreenTopComponent());
setToolTipText(Bundle.HINT_WelcomeScreenTopComponent());
jTextPane1.setEditorKit(parser.getEditorKit());
jTextPane1.setDocument(parser.getDocument());
jTextPane1.addHyperlinkListener(this);
jEditorPane1.addHyperlinkListener(this);
// StyleSheet sheet = new StyleSheet();
// sheet.addRule("background-color: transparent;");
// parser.getEditorKit().setStyleSheet(sheet);
try {
jEditorPane1.setPage(new URL("http://jmonkeyengine.org/wiki/doku.php/sdk:welcome?do=export_xhtmlbody"));
// jEditorPane1.setPage(new URL("nbres:/com/jme3/gde/core/docs/core-about.html"));
} catch (IOException ex) {
try {
jEditorPane1.setPage(new URL("nbres:/com/jme3/gde/core/docs/core-about.html"));
} catch (IOException ex1) {
Exceptions.printStackTrace(ex1);
}
}
// jEditorPane2.setBackground(new Color(0, 0, 0, 128));
// jTextPane1.setBackground(new Color(0, 0, 0, 128));
parser.updateFeed();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new GradPanel();
jScrollPane3 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jScrollPane2 = new javax.swing.JScrollPane();
jEditorPane1 = new javax.swing.JEditorPane();
setBackground(java.awt.Color.white);
jPanel1.setBackground(new java.awt.Color(255, 255, 255));
jScrollPane3.setBorder(null);
jScrollPane3.setOpaque(false);
jTextPane1.setEditable(false);
jTextPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(WelcomeScreenTopComponent.class, "WelcomeScreenTopComponent.jTextPane1.border.title"))); // NOI18N
jTextPane1.setFont(new java.awt.Font("Lucida Grande", 2, 12)); // NOI18N
jTextPane1.setForeground(new java.awt.Color(0, 0, 204));
jTextPane1.setCaretColor(new java.awt.Color(255, 255, 255));
jTextPane1.setDisabledTextColor(new java.awt.Color(0, 0, 204));
jTextPane1.setOpaque(false);
jScrollPane3.setViewportView(jTextPane1);
jScrollPane2.setOpaque(false);
jEditorPane1.setEditable(false);
jEditorPane1.setCaretColor(new java.awt.Color(255, 255, 255));
jEditorPane1.setOpaque(false);
jScrollPane2.setViewportView(jEditorPane1);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jScrollPane2)
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE))
.addContainerGap())
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JEditorPane jEditorPane1;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JTextPane jTextPane1;
// End of variables declaration//GEN-END:variables
@Override
public void componentOpened() {
// TODO add custom code on component opening
}
@Override
public void componentClosed() {
// TODO add custom code on component closing
}
void writeProperties(java.util.Properties p) {
// better to version settings since initial version as advocated at
// http://wiki.apidesign.org/wiki/PropertyFiles
p.setProperty("version", "1.0");
// TODO store your settings
}
void readProperties(java.util.Properties p) {
String version = p.getProperty("version");
// TODO read your settings according to their version
}
public void hyperlinkUpdate(HyperlinkEvent he) {
if (he.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
URLDisplayer.getDefault().showURL(he.getURL());
}
}
}