import java
import java
import java
import java
import java
import java
import java
import java
import java
import java
import java
import java
import javax
import javax
import javax
import javax
import javax
import javax
import javax
import javax
import javax
import javax
import javax
import javax
import javax
import javax
import javax
import javax
import javax
import javax
import javax
import javax
import javax
import javax
public class RunJava extends JFrame {
private JTextField textField_
private JTextField textField;
private String url = System
private JTextPane textArea_
private JTextArea textArea;
private static String cmd =
private static Process pro = null;
private Thread InPutThread = null;
private Thread OutPutThread = null;
private Thread ErrorThread = null;
private JMenu File
private JMenuBar Part;
private JMenuItem Open
private File file;
private String [] Keyword = {
public static void main(String args[]) {
EventQueue
public void run() {
try {
RunJava frame = new RunJava();
frame
} catch (Exception e) {
e
}
}
});
}
public RunJava() throws Exception {
super(
File = new JMenu(
Part = new JMenuBar();
Edit = new JMenu(
Part
Part
Open = new JMenuItem(
Open
public void actionPerformed(final ActionEvent arg
JFileChooser fileChooser = new JFileChooser(); // 實例化文件選擇器
fileChooser
if (fileChooser
String fileName = fileChooser
System
file = new File(fileName);
InputData();
}
}
});
Save = new JMenuItem(
Save
public void actionPerformed(final ActionEvent arg
if(file==null){
JFileChooser fileChooser = new JFileChooser(); // 實例化文件選擇器
fileChooser
if (fileChooser
String fileName = fileChooser
System
file = new File(fileName);
OutputData();
}
}else{
OutputData();
}
}
});
SaveAs = new JMenuItem(
SaveAs
public void actionPerformed(final ActionEvent arg
JFileChooser fileChooser = new JFileChooser(); // 實例化文件選擇器
fileChooser
if (fileChooser
String fileName = fileChooser
file = new File(fileName);
OutputData();
}
}
});
Exit = new JMenuItem(
Exit
public void actionPerformed(final ActionEvent arg
int j=JOptionPane
if (j == JOptionPane
System
}
}
});
File
File
File
File
InsertMain = new JMenuItem(
InsertMain
public void actionPerformed(final ActionEvent arg
String str =
+
+
+
textArea_
textField
}
});
MarkColor = new JMenuItem(
MarkColor
public void actionPerformed(final ActionEvent e) {
String str =
+
+
+
int a = str
// System
setDocs(str
}
});
Edit
Edit
setJMenuBar(Part);
getContentPane()
setBounds(
setDefaultCloseOperation(JFrame
final JPanel panel = new JPanel();
panel
panel
getContentPane()
textArea_
panel
final JPanel panel_
panel_
panel_
panel_
panel_
getContentPane()
textArea = new JTextArea();
panel_
try {
UIManager
} catch (Exception ex
try {
UIManager
} catch (Exception ex
UIManager
}
}
SwingUtilities
textField = new JTextField();
textField
textField
getContentPane()
final JLabel label = new JLabel();
label
label
getContentPane()
setResizable(false);// 屏蔽最大化按鈕
textField_
textField_
textField_
getContentPane()
final JButton button_
button_
public void actionPerformed(final ActionEvent arg
cmd = textField_
}
});
button_
button_
getContentPane()
final JButton button_
button_
public void actionPerformed(final ActionEvent arg
String name = textField
if (name
textField
}
FileOut(textField
File file = new File(url + textField
if (file
file
}
String exe =
try {
pro = Runtime
if (InPutThread != null)InPutThread
if (OutPutThread != null)InPutThread
if (ErrorThread != null)InPutThread
InPutThread = new Thread(new RunTimeInput());
OutPutThread = new Thread(new RunTimeOutput(new InputStreamReader(pro
ErrorThread = new Thread(new RunTimeOutput(new InputStreamReader(pro
InPutThread
OutPutThread
ErrorThread
exec(
Thread
exec(
} catch (Exception e) {
e
}
}
});
button_
button_
getContentPane()
}
public void FileOut(String name
File file = new File(url + name);
if (file
file
try {
file
FileOutputStream out = new FileOutputStream(file);
byte buf[] = Content
out
out
out
} catch (Exception ex) {
ex
}
}
public class RunTimeInput implements Runnable {
private BufferedWriter bw = null;
public void run() {
bw = new BufferedWriter(new OutputStreamWriter(pro
while (true) {
try {
if (cmd != null && cmd
bw
bw
cmd = null;
}
Thread
} catch (Exception e) {
e
}
}
}
}
public class RunTimeOutput implements Runnable {
InputStreamReader isr = null;
public RunTimeOutput(InputStreamReader is) {
isr = is;
}
private BufferedReader br = null;
public void run() {
br = new BufferedReader(isr);
while (true) {
try {
String s = br
if (s != null) {
textArea
textArea
}
Thread
} catch (Exception e) {
e
}
}
}
}
public void exec(String Content) {
cmd = Content;
}
public String getName(String str) {
String name =
if (str
String[] s = str
for (int i =
if (s[i]
if ((i +
name = s[i +
int a =
if((a=name
name= name
}
}
}
}
return name;
}
public void OutputData() {
try {
FileOutputStream out = new FileOutputStream(file);
byte buf[] = textArea_
out
out
out
} catch (Exception e) {
e
}
}
public void InputData() {
try {
FileInputStream in = new FileInputStream(file);
int a = (int)file
byte buf[] = new byte[a];
int len = in
if (len ==
System
}else{
textArea_
}
} catch (Exception e) {
e
}
}
/**
* @param str 內容
* @param col 顏色
* @param bold 是否粗體
* @param fontSize 字體大小
*/
public void setDocs(String str
SimpleAttributeSet attrSet = new SimpleAttributeSet();
StyleConstants
// 顏色
if (bold == true) {
StyleConstants
}// 字體類型
StyleConstants
// 字體大小
Document doc = textArea_
try {
doc
} catch (BadLocationException e) {
System
}
}
}
//未寫完的
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26653.html