franksisca
13-09-2006, 16:14
Ragazzi, devo creare la guida del mio programmino, mi dite come posso fare???
mi hanno consigliato di usare un JDialog, e ho provato a fare questo:public class Guida
extends JDialog {
JPanel panel1 = new JPanel();
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
JButton chiudi = new JButton();
JScrollPane scroller = new JScrollPane();
JEditorPane html;
public Guida(Frame frame, String title, boolean modal) {
super(frame, title, modal);
try {
jbInit();
//pack();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public Guida() {
this(null, "", false);
}
private void jbInit() throws Exception {
panel1.setLayout(borderLayout1);
chiudi.setText("Chiudi");
this.setResizable(false);
this.setTitle("Guida");
this.setSize(600,500);
chiudi.addActionListener(new ActionListener(){
/**
* actionPerformed
*
* @param e ActionEvent
*/
public void actionPerformed(ActionEvent e) {
hide();
}
});
getContentPane().add(panel1);
try {
URL url = null;
// System.getProperty("user.dir") +
// System.getProperty("file.separator");
String path = null;
try {
path = "files/Guida.html";
url = getClass().getResource(path);
}
catch (Exception e) {
System.err.println("Failed to open " + path);
url = null;
}
if (url != null) {
html = new JEditorPane(url);
html.setEditable(false);
//html.addHyperlinkListener(createHyperLinkListener())
}
}
catch (MalformedURLException e) {
System.out.println("Malformed URL: " + e);
}
catch (IOException e) {
System.out.println("IOException: " + e);
}
panel1.add(jPanel1, BorderLayout.SOUTH);
jPanel1.add(chiudi, null);
panel1.add(scroller, BorderLayout.CENTER);
scroller.getViewport().add(html, null);
}
}
naturalmente alcune chiamate sono vecchie e deprecate, ma a me non fà vedere niente, mi spegate il motivo???
mi hanno consigliato di usare un JDialog, e ho provato a fare questo:public class Guida
extends JDialog {
JPanel panel1 = new JPanel();
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
JButton chiudi = new JButton();
JScrollPane scroller = new JScrollPane();
JEditorPane html;
public Guida(Frame frame, String title, boolean modal) {
super(frame, title, modal);
try {
jbInit();
//pack();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public Guida() {
this(null, "", false);
}
private void jbInit() throws Exception {
panel1.setLayout(borderLayout1);
chiudi.setText("Chiudi");
this.setResizable(false);
this.setTitle("Guida");
this.setSize(600,500);
chiudi.addActionListener(new ActionListener(){
/**
* actionPerformed
*
* @param e ActionEvent
*/
public void actionPerformed(ActionEvent e) {
hide();
}
});
getContentPane().add(panel1);
try {
URL url = null;
// System.getProperty("user.dir") +
// System.getProperty("file.separator");
String path = null;
try {
path = "files/Guida.html";
url = getClass().getResource(path);
}
catch (Exception e) {
System.err.println("Failed to open " + path);
url = null;
}
if (url != null) {
html = new JEditorPane(url);
html.setEditable(false);
//html.addHyperlinkListener(createHyperLinkListener())
}
}
catch (MalformedURLException e) {
System.out.println("Malformed URL: " + e);
}
catch (IOException e) {
System.out.println("IOException: " + e);
}
panel1.add(jPanel1, BorderLayout.SOUTH);
jPanel1.add(chiudi, null);
panel1.add(scroller, BorderLayout.CENTER);
scroller.getViewport().add(html, null);
}
}
naturalmente alcune chiamate sono vecchie e deprecate, ma a me non fà vedere niente, mi spegate il motivo???