ArduinoDialogHelp.java
/*******************************************************************************
* jArduino: Arduino C++ Code Generation From Java
* Copyright 2020 Tony Washer
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package net.sourceforge.jarduino.gui;
import net.sourceforge.jarduino.ArduinoException;
import javax.swing.JDialog;
import javax.swing.JFrame;
import java.awt.Dialog;
/**
* Dialog for help.
*/
public class ArduinoDialogHelp {
/**
* The master frame.
*/
private final JFrame theFrame;
/**
* The main window.
*/
private final ArduinoPanelMain theMain;
/**
* The help panel.
*/
private final ArduinoPanelHelp theHelp;
/**
* The help dialog.
*/
private JDialog theDialog;
/**
* Constructor.
* @param pFrame the frame
* @param pMain the main window
* @throws ArduinoException on error
*/
ArduinoDialogHelp(final JFrame pFrame,
final ArduinoPanelMain pMain) throws ArduinoException {
/* Store parameters */
theFrame = pFrame;
theMain = pMain;
/* Create the help panel */
theHelp = new ArduinoPanelHelp();
}
/**
* Show the dialog.
*/
void showDialog() {
/* If we have no dialog */
if (theDialog == null) {
theDialog = makeDialog();
}
/* If the dialog is not currently displayed */
if (!theDialog.isVisible()) {
/* Fix location and display */
theDialog.setLocationRelativeTo(theFrame);
theDialog.setVisible(true);
}
}
/**
* create the dialog.
* @return the dialog
*/
private JDialog makeDialog() {
/* Create the dialog */
final JDialog myDialog = new JDialog(theFrame);
myDialog.setModalityType(Dialog.ModalityType.MODELESS);
myDialog.setTitle("jArduino Help");
/* Attach the help panel to the dialog */
myDialog.getContentPane().add(theHelp.getComponent());
myDialog.pack();
return myDialog;
}
}