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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
/**
* JFractionLab
* Copyright (C) 2005 jochen georges, gnugeo _ at _ gnugeo _ dot _ de
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
package jfractionlab.jflDialogs;
import org.debian.tablelayout.TableLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import jfractionlab.JFractionLab;
public class InfoDialog extends JDialog implements ActionListener{
static final long serialVersionUID = JFractionLab.serialVersionUID;
private JEditorPane jep_info = new JEditorPane();
private JButton btn_OK = new JButton("");
private String fontdefend="</b></font>";
private String dialogText = "";
private String dialogTitle = "";
private int xsize = 500;
private int ysize = 500;
public InfoDialog(String title, String txt){
this.dialogTitle = title;
this.dialogText = txt;
setTitle(dialogTitle);
makeGUI();
}
public InfoDialog(String title, String txt, int x, int y){
this.dialogTitle = title;
this.dialogText = txt;
this.xsize = x;
this.ysize = y;
setTitle(dialogTitle);
makeGUI();
}
/**
*
*
*/
private void makeGUI(){
double sizes[][] = {{
10, TableLayout.FILL, 10
},{
10, TableLayout.FILL, 50,10
}}; //Spalten / Zeilen
getRootPane().setDefaultButton(btn_OK);
Container content = getContentPane();
content.setLayout(new TableLayout(sizes));
content.setBackground(Color.white);
jep_info.setContentType("text/html");
String str = JFractionLab.jep_fontface + "<b>" + dialogText + fontdefend;
jep_info.setText(str);
jep_info.setEditable(false);
jep_info.setFocusable(false);
content.add(new JScrollPane(jep_info), "1,1");
btn_OK.addActionListener(this);
btn_OK.setText(lang.Messages.getString("OK"));
content.add(btn_OK, "1,2,c,c");
setModalityType(JDialog.ModalityType.APPLICATION_MODAL);
setLocation(150, 150);
setSize(xsize,ysize);
setResizable(false);
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
setVisible(true);
}//makeGUI
public void actionPerformed(ActionEvent e){
Object obj = e.getSource();
if (obj == btn_OK){
setVisible(false);
dispose();
}
}//actionPerformed
public void setDialogText(String dialogText) {
this.dialogText = dialogText;
}
public void setDialogTitle(String dialogTitle) {
this.dialogTitle = dialogTitle;
}
}//class InfoDialog
|