org.jpedal.examples.viewer.commands.Help Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of OpenViewerFX Show documentation
Show all versions of OpenViewerFX Show documentation
Open Source (LGPL) JavaFX PDF Viewer
/*
* ===========================================
* Java Pdf Extraction Decoding Access Library
* ===========================================
*
* Project Info: http://www.idrsolutions.com
* Help section for developers at http://www.idrsolutions.com/support/
*
* (C) Copyright 1997-2017 IDRsolutions and Contributors.
*
* This file is part of JPedal/JPDF2HTML5
*
@LICENSE@
*
* ---------------
* Help.java
* ---------------
*/
package org.jpedal.examples.viewer.commands;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.*;
import org.jpedal.display.GUIDisplay;
import org.jpedal.gui.GUIFactory;
import org.jpedal.utils.BrowserLauncher;
import org.jpedal.utils.LogWriter;
/**
* Code to handle Help button we display in demo versions of Viewer
*/
public class Help {
public static void execute(final Object[] args, final GUIFactory currentGUI) {
if (args == null) {
getHelpBox(currentGUI);
}
}
private static void getHelpBox(final GUIFactory currentGUI) {
final JPanel panel = new JPanel();
final JPanel top = new JPanel();
top.setLayout(new BoxLayout(top, BoxLayout.Y_AXIS));
final JPanel labelPanel = new JPanel();
labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.X_AXIS));
labelPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
final JLabel label = new JLabel("Visit our website to find lots of example code, documentation and FAQs:
");
label.setAlignmentX(JLabel.LEFT_ALIGNMENT);
labelPanel.add(label);
labelPanel.add(Box.createHorizontalGlue());
top.add(labelPanel);
final JPanel linkPanel = new JPanel();
linkPanel.setLayout(new BoxLayout(linkPanel, BoxLayout.X_AXIS));
linkPanel.add(Box.createHorizontalGlue());
linkPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
final JLabel url = new JLabel("https://www.idrsolutions.com/jpedal/support/");
url.setAlignmentX(JLabel.LEFT_ALIGNMENT);
url.setForeground(Color.blue);
url.setHorizontalAlignment(JLabel.CENTER);
//Create cursor handling
url.addMouseListener(new MouseListener() {
@Override
public void mouseEntered(final MouseEvent e) {
if (GUIDisplay.allowChangeCursor) {
panel.getTopLevelAncestor().setCursor(new Cursor(Cursor.HAND_CURSOR));
}
url.setText("https://www.idrsolutions.com/jpedal/support/ ");
}
@Override
public void mouseExited(final MouseEvent e) {
if (GUIDisplay.allowChangeCursor) {
panel.getTopLevelAncestor().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
url.setText("https://www.idrsolutions.com/jpedal/support/");
}
@Override
public void mouseClicked(final MouseEvent e) {
try {
BrowserLauncher.openURL("https://www.idrsolutions.com/jpedal/support/");
} catch (final Exception e1) {
// JPanel errorPanel = new JPanel();
// errorPanel.setLayout(new BoxLayout(errorPanel, BoxLayout.Y_AXIS));
//
// JLabel errorMessage = new JLabel("Your web browser could not be successfully loaded. " +
// "Please copy and paste the URL below, manually into your web browser.");
// errorMessage.setAlignmentX(JLabel.LEFT_ALIGNMENT);
// errorMessage.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
//
// JTextArea textArea = new JTextArea("http://www.idrsolutions.com/java-pdf-library-support/");
// textArea.setEditable(false);
// textArea.setRows(5);
// textArea.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
// textArea.setAlignmentX(JTextArea.LEFT_ALIGNMENT);
//
// errorPanel.add(errorMessage);
// errorPanel.add(textArea);
//
// showMessageDialog(errorPanel,"Error loading web browser",JOptionPane.PLAIN_MESSAGE);
LogWriter.writeLog("Exception attempting launch browser: " + e1);
}
}
@Override
public void mousePressed(final MouseEvent e) {
}
@Override
public void mouseReleased(final MouseEvent e) {
}
});
linkPanel.add(url);
linkPanel.add(Box.createHorizontalGlue());
top.add(linkPanel);
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.add(top);
currentGUI.showMessageDialog(panel, "JPedal Tutorials and documentation", JOptionPane.PLAIN_MESSAGE);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy