1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
public class HelpSyntax extends MyDialog {
public HelpSyntax(JDialog parent, String title){
super(parent, title, false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
// Create an editor pane.
JEditorPane editorPane = createEditorPane();
JScrollPane editorScrollPane = new JScrollPane(editorPane);
int width = (int)Toolkit.getDefaultToolkit().getScreenSize().getWidth()*3/4;
int height = (int)Toolkit.getDefaultToolkit().getScreenSize().getHeight()/2;
editorScrollPane.setPreferredSize(new Dimension(width, height));
editorScrollPane.setWheelScrollingEnabled(true);
editorScrollPane.setOpaque(true);
// the layout
getContentPane().setLayout(new BorderLayout());
getContentPane().add(editorScrollPane,BorderLayout.CENTER);
//Display the window.
setResizable(false); // si on met ça à true, on a l'icone java... :-S
pack();
// setLocation(Dialog.getCenterPosition(this));
setLocationRelativeTo(null);
setVisible(true);
}
/**
* Creates the content of the window from a html file
* @return a JEditorPane instance
*/
private JEditorPane createEditorPane() {
JEditorPane editorPane = new JEditorPane();
editorPane.setEditable(false);
URL helpURL = ClassLoader.getSystemResource("Help.html"));
if (helpURL != null) {
try {
editorPane.setPage(helpURL);
} catch (IOException e) {
System.err.println("Attempted to read a bad URL: " + helpURL);
}
} else {
System.err.println("Couldn't find file: Syntaxe.html");
}
return editorPane;
}
public void escapeActionPerformed() {
dispose();
}
} |