?? resultviewer.java
字號:
/*
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
author: Yuan yongfu lijin liyong lib 511,the College of Mathematics and Computer Science,HuNan Normal University,China
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
*/
package edu.hunnu.webjetchecker.viewer.prover;
import java.awt.*;
import java.io.RandomAccessFile;
import javax.swing.*;
import javax.swing.text.*;
public class ResultViewer extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
JFrame f = new JFrame("result viewer");
private JPanel jp = new JPanel(new BorderLayout());
private JScrollPane scrollPane1 = new JScrollPane();
private JScrollPane scrollPane2 = new JScrollPane();
JMenuBar mbar = new JMenuBar();
JMenu fileMenu = new JMenu(" File ");
JMenu editMenu = new JMenu("Edit ");
public void init(String s1, String filePath) {
Container dialogcontentpane = f.getContentPane();
dialogcontentpane.add(jp, BorderLayout.CENTER);
dialogcontentpane.add(mbar, BorderLayout.BEFORE_FIRST_LINE);
mbar.add(fileMenu);
mbar.add(editMenu);
fileMenu.setMnemonic('F');
editMenu.setMnemonic('E');
Box baseBox = Box.createHorizontalBox();
dialogcontentpane.add(baseBox);
Box box = Box.createVerticalBox();
String str = "";
try {
RandomAccessFile ra = new RandomAccessFile(filePath, "r");
long len = ra.length();
while (ra.getFilePointer() < len) {
str = str + ra.readLine() + "\n";
}
} catch (Exception ex) {
ex.getMessage();
}
if (str.contains("<!--the begining of BPEL slice")) {
JLabel label1 = new JLabel(
"**********checking result /the Pi-calculus***************");
JLabel label2 = new JLabel(
"**********BPEL4WS source file***********");
final JTextArea tf1 = new JTextArea(s1, 10, 60);
int begin = 0;
int end = 0;
begin = str.indexOf("<!--the begining of BPEL slice");
end = str.indexOf("<!--the end of BPEL slice");
final JTextPane tf2 = new JTextPane();
Document doc = tf2.getDocument();
setDoc(doc, str.substring(0, begin - 1), Color.BLACK, 12);
setDoc(doc, str.substring(begin - 1, end + 60), Color.RED, 12);
setDoc(doc, str.substring(end + 60), Color.BLACK, 12);
box.add(label1);
box.add(scrollPane1, BorderLayout.EAST);
box.add(label2);
box.add(scrollPane2, BorderLayout.EAST);
scrollPane1.setViewportView(tf1);
scrollPane2.setViewportView(tf2);
baseBox.add(box);
f.pack();
f.setLocation(250, 150);
f.show();
} else {
JLabel label1 = new JLabel(
"**********checking result***************");
box.add(label1);
box.add(scrollPane1, BorderLayout.EAST);
s1 += "\n" + "the path of the resouce file:" + "\n" + filePath;
final JTextArea tf1 = new JTextArea(s1, 10, 60);
scrollPane1.setViewportView(tf1);
baseBox.add(box);
f.pack();
f.setLocation(250, 150);
f.show();
}
}
private void setDoc(Document doc, String str, Color col, int FontSize) {
SimpleAttributeSet attriSet = new SimpleAttributeSet();
StyleConstants.setForeground(attriSet, col);
StyleConstants.setFontSize(attriSet, FontSize);
try {
doc.insertString(doc.getLength(), str, attriSet);
} catch (BadLocationException e) {
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -