/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* OnLineHelpDialog.java
*
* Created on 16 janv. 2011, 10:29:38
*/
package feuille.karaoke.dialog;
import java.io.IOException;
import java.net.URISyntaxException;
import feuille.lib.Language;
/**
* <p>This is a dialog for information about JRuby and Java.<br />
* C'est une boîte de dialogue qui informe sur JRuby et Java..</p>
* @author The Wingate 2940
*/
public class OnLineHelpDialog extends javax.swing.JDialog {
private ButtonPressed bp;
private Language localeLanguage = feuille.MainFrame.getLanguage();
public enum ButtonPressed{
NONE, OK_BUTTON, CANCEL_BUTTON;
}
/** <p>Creates new form OnLineHelpDialog.<br />
* Crée un nouveau formulaire OnLineHelpDialog.</p> */
public OnLineHelpDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
if(localeLanguage.getValueOf("titleOHD")!=null){setTitle(localeLanguage.getValueOf("titleOHD"));}
if(localeLanguage.getValueOf("buttonClose")!=null){Close_Button.setText(localeLanguage.getValueOf("buttonClose"));}
if(localeLanguage.getValueOf("messTools")!=null){jLabel1.setText(localeLanguage.getValueOf("messTools"));}
}
/** 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
lblJavaSun = new javax.swing.JLabel();
lblRubyLang = new javax.swing.JLabel();
lblRubyProg = new javax.swing.JLabel();
lblRubyDoc = new javax.swing.JLabel();
lblJRuby = new javax.swing.JLabel();
Close_Button = new javax.swing.JButton();
lblJython = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Online help...");
setResizable(false);
jLabel1.setBackground(new java.awt.Color(255, 255, 255));
jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel1.setText(" Here are tools and resources you can use to have more skills dealing with scripts : ");
jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204)));
jLabel1.setOpaque(true);
lblJavaSun.setForeground(java.awt.Color.blue);
lblJavaSun.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/20px-Crystal_Clear_app_internet.png"))); // NOI18N
lblJavaSun.setText("<html>Java - Oracle : http://www.oracle.com/technetwork/java/index.html");
lblJavaSun.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lblJavaSunMouseClicked(evt);
}
public void mouseEntered(java.awt.event.MouseEvent evt) {
lblJavaSunMouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
lblJavaSunMouseExited(evt);
}
});
lblRubyLang.setForeground(java.awt.Color.blue);
lblRubyLang.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/20px-Crystal_Clear_app_internet.png"))); // NOI18N
lblRubyLang.setText("<html>Ruby - A programmer's best friend : http://www.ruby-lang.org");
lblRubyLang.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lblRubyLangMouseClicked(evt);
}
public void mouseEntered(java.awt.event.MouseEvent evt) {
lblRubyLangMouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
lblRubyLangMouseExited(evt);
}
});
lblRubyProg.setForeground(java.awt.Color.blue);
lblRubyProg.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/20px-Crystal_Clear_app_internet.png"))); // NOI18N
lblRubyProg.setText("<html>Ruby - Programming Ruby : http://www.ruby-doc.org/docs/ProgrammingRuby/");
lblRubyProg.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lblRubyProgMouseClicked(evt);
}
public void mouseEntered(java.awt.event.MouseEvent evt) {
lblRubyProgMouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
lblRubyProgMouseExited(evt);
}
});
lblRubyDoc.setForeground(java.awt.Color.blue);
lblRubyDoc.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/20px-Crystal_Clear_app_internet.png"))); // NOI18N
lblRubyDoc.setText("<html>Ruby - Ruby-Doc.org : http://www.ruby-doc.org/");
lblRubyDoc.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lblRubyDocMouseClicked(evt);
}
public void mouseEntered(java.awt.event.MouseEvent evt) {
lblRubyDocMouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
lblRubyDocMouseExited(evt);
}
});
lblJRuby.setForeground(java.awt.Color.blue);
lblJRuby.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/20px-Crystal_Clear_app_internet.png"))); // NOI18N
lblJRuby.setText("<html>JRuby - JRuby : http://jruby.org/");
lblJRuby.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lblJRubyMouseClicked(evt);
}
public void mouseEntered(java.awt.event.MouseEvent evt) {
lblJRubyMouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
lblJRubyMouseExited(evt);
}
});
Close_Button.setText("Close");
Close_Button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Close_ButtonActionPerformed(evt);
}
});
lblJython.setForeground(new java.awt.Color(0, 0, 255));
lblJython.setIcon(new javax.swing.ImageIcon(getClass().getResource("/feuille/images/20px-Crystal_Clear_app_internet.png"))); // NOI18N
lblJython.setText("Jython - The Definitive Guide to Jython : http://www.jython.org/jythonbook/en/1.0/");
lblJython.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lblJythonMouseClicked(evt);
}
public void mouseEntered(java.awt.event.MouseEvent evt) {
lblJythonMouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
lblJythonMouseExited(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblJython, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 616, Short.MAX_VALUE)
.addComponent(Close_Button, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblJavaSun, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblRubyLang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblRubyProg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblRubyDoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblJRuby, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblJavaSun, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblRubyLang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblRubyProg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblRubyDoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblJRuby, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblJython)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(Close_Button)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void Close_ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Close_ButtonActionPerformed
// TODO add your handling code here:
bp = ButtonPressed.OK_BUTTON;
dispose();
}//GEN-LAST:event_Close_ButtonActionPerformed
private void lblJavaSunMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblJavaSunMouseClicked
launchLink("http://www.oracle.com/technetwork/java/index.html");
}//GEN-LAST:event_lblJavaSunMouseClicked
private void lblRubyLangMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRubyLangMouseClicked
launchLink("http://www.ruby-lang.org");
}//GEN-LAST:event_lblRubyLangMouseClicked
private void lblRubyProgMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRubyProgMouseClicked
launchLink("http://www.ruby-doc.org/docs/ProgrammingRuby/");
}//GEN-LAST:event_lblRubyProgMouseClicked
private void lblRubyDocMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRubyDocMouseClicked
launchLink("http://www.ruby-doc.org/");
}//GEN-LAST:event_lblRubyDocMouseClicked
private void lblJRubyMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblJRubyMouseClicked
launchLink("http://jruby.org/");
}//GEN-LAST:event_lblJRubyMouseClicked
private void lblJavaSunMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblJavaSunMouseEntered
lblJavaSun.setText("<html>Java - Oracle : <u>http://www.oracle.com/technetwork/java/index.html");
}//GEN-LAST:event_lblJavaSunMouseEntered
private void lblJavaSunMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblJavaSunMouseExited
lblJavaSun.setText("<html>Java - Oracle : http://www.oracle.com/technetwork/java/index.html");
}//GEN-LAST:event_lblJavaSunMouseExited
private void lblRubyLangMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRubyLangMouseEntered
lblRubyLang.setText("<html>Ruby - A programmer's best friend : <u>http://www.ruby-lang.org");
}//GEN-LAST:event_lblRubyLangMouseEntered
private void lblRubyLangMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRubyLangMouseExited
lblRubyLang.setText("<html>Ruby - A programmer's best friend : http://www.ruby-lang.org");
}//GEN-LAST:event_lblRubyLangMouseExited
private void lblRubyProgMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRubyProgMouseEntered
lblRubyProg.setText("<html>Ruby - Programming Ruby : <u>http://www.ruby-doc.org/docs/ProgrammingRuby/");
}//GEN-LAST:event_lblRubyProgMouseEntered
private void lblRubyProgMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRubyProgMouseExited
lblRubyProg.setText("<html>Ruby - Programming Ruby : http://www.ruby-doc.org/docs/ProgrammingRuby/");
}//GEN-LAST:event_lblRubyProgMouseExited
private void lblRubyDocMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRubyDocMouseEntered
lblRubyDoc.setText("<html>Ruby - Ruby-Doc.org : <u>http://www.ruby-doc.org/");
}//GEN-LAST:event_lblRubyDocMouseEntered
private void lblRubyDocMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRubyDocMouseExited
lblRubyDoc.setText("<html>Ruby - Ruby-Doc.org : http://www.ruby-doc.org/");
}//GEN-LAST:event_lblRubyDocMouseExited
private void lblJRubyMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblJRubyMouseEntered
lblJRuby.setText("<html>JRuby - JRuby : <u>http://jruby.org/");
}//GEN-LAST:event_lblJRubyMouseEntered
private void lblJRubyMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblJRubyMouseExited
lblJRuby.setText("<html>JRuby - JRuby : http://jruby.org/");
}//GEN-LAST:event_lblJRubyMouseExited
private void lblJythonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblJythonMouseClicked
launchLink("http://www.jython.org/jythonbook/en/1.0/");
}//GEN-LAST:event_lblJythonMouseClicked
private void lblJythonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblJythonMouseEntered
lblJython.setText("<html>Jython - The Definitive Guide to Jython : <u>http://www.jython.org/jythonbook/en/1.0/");
}//GEN-LAST:event_lblJythonMouseEntered
private void lblJythonMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblJythonMouseExited
lblJython.setText("<html>Jython - The Definitive Guide to Jython : http://www.jython.org/jythonbook/en/1.0/");
}//GEN-LAST:event_lblJythonMouseExited
/** <p>Show the dialog.<br />
* Montre la dialogue.</p> */
public boolean showDialog(){
setVisible(true);
if(bp.equals(ButtonPressed.OK_BUTTON)){
return true;
}else{
return false;
}
}
/** <p>Launch the selected link and open a browser.<br />
* Lance le lien sélectionné et ou un navigateur.</p> */
private void launchLink(String link){
boolean hasResult = true;
if(java.awt.Desktop.isDesktopSupported()){
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if(desktop.isSupported(java.awt.Desktop.Action.BROWSE)){
try {
try {
desktop.browse(new java.net.URI(link));
} catch (IOException ex) {hasResult = false;}
} catch (URISyntaxException ex) {hasResult = false;}
}else{
hasResult = false;
}
}else{
hasResult = false;
}
if(hasResult==false){
java.util.Properties sys = System.getProperties();
String os = sys.getProperty("os.name").toLowerCase();
try {
if(os.contains("windows")==true){
Process proc = Runtime.getRuntime().exec("cmd /c start "+link);
}else{
Process proc = Runtime.getRuntime().exec("start "+link);
}
} catch (java.io.IOException e) {
// unsupported
}
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
OnLineHelpDialog dialog = new OnLineHelpDialog(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton Close_Button;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel lblJRuby;
private javax.swing.JLabel lblJavaSun;
private javax.swing.JLabel lblJython;
private javax.swing.JLabel lblRubyDoc;
private javax.swing.JLabel lblRubyLang;
private javax.swing.JLabel lblRubyProg;
// End of variables declaration//GEN-END:variables
}