Created
June 5, 2017 07:22
-
-
Save AhianZhang/e9e8b80a3001c5149be94bf93cf0150e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<component name="ArtifactManager"> | |
<artifact type="jar" name="Editor:jar"> | |
<output-path>$PROJECT_DIR$/out/artifacts/Editor_jar</output-path> | |
<root id="archive" name="Editor.jar"> | |
<element id="module-output" name="Editor" /> | |
<element id="module-output" name="editor_design" /> | |
</root> | |
</artifact> | |
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<component name="ArtifactManager"> | |
<artifact type="jar" name="Editor:jar2"> | |
<output-path>$USER_HOME$/Desktop</output-path> | |
<root id="archive" name="Editor.jar"> | |
<element id="directory" name="META-INF"> | |
<element id="file-copy" path="$USER_HOME$/Desktop/META-INF/MANIFEST.MF" /> | |
</element> | |
<element id="module-output" name="Editor" /> | |
<element id="module-output" name="editor_design" /> | |
</root> | |
</artifact> | |
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<component name="ArtifactManager"> | |
<artifact type="jar" name="Editor:jar3"> | |
<output-path>$PROJECT_DIR$/out/artifacts/Editor_jar3</output-path> | |
<root id="archive" name="Editor.jar"> | |
<element id="directory" name="META-INF"> | |
<element id="file-copy" path="$PROJECT_DIR$/../META-INF/MANIFEST.MF" /> | |
</element> | |
<element id="module-output" name="Editor" /> | |
<element id="module-output" name="editor_design" /> | |
</root> | |
</artifact> | |
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> | |
<output url="file://$PROJECT_DIR$/out" /> | |
</component> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectModuleManager"> | |
<modules> | |
<module fileurl="file://$PROJECT_DIR$/Editor.iml" filepath="$PROJECT_DIR$/Editor.iml" /> | |
<module fileurl="file://$PROJECT_DIR$/editor_design/editor_design.iml" filepath="$PROJECT_DIR$/editor_design/editor_design.iml" /> | |
</modules> | |
</component> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<module type="JAVA_MODULE" version="4"> | |
<component name="NewModuleRootManager" inherit-compiler-output="true"> | |
<exclude-output /> | |
<content url="file://$MODULE_DIR$"> | |
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | |
</content> | |
<orderEntry type="inheritedJdk" /> | |
<orderEntry type="sourceFolder" forTests="false" /> | |
</component> | |
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<module type="JAVA_MODULE" version="4"> | |
<component name="NewModuleRootManager" inherit-compiler-output="true"> | |
<exclude-output /> | |
<content url="file://$MODULE_DIR$"> | |
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | |
</content> | |
<orderEntry type="inheritedJdk" /> | |
<orderEntry type="sourceFolder" forTests="false" /> | |
</component> | |
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Manifest-Version: 1.0 | |
Main-Class: editor | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by 张巍瀚 on 2017/4/10. | |
*/ | |
import javax.swing.*; | |
import javax.swing.event.CaretEvent; | |
import javax.swing.event.CaretListener; | |
import javax.swing.filechooser.FileFilter; | |
import javax.swing.filechooser.FileNameExtensionFilter; | |
import javax.swing.plaf.ColorUIResource; | |
import javax.xml.stream.events.StartDocument; | |
import java.awt.*; | |
import java.awt.event.*; | |
import java.io.*; | |
import java.net.URI; | |
import java.net.URISyntaxException; | |
import java.net.URL; | |
public class editor | |
{ | |
JFrame jFrame; | |
JTextField jTextField; | |
JButton jButton; | |
JButton jButton1; | |
JScrollPane jScrollPane; | |
JPanel jPanel; | |
JTextArea jTextArea; | |
JPanel jPanel1; | |
JLabel count ,info1; | |
JMenuBar jMenuBar; | |
JFileChooser chooser; | |
JRadioButtonMenuItem jRadioButtonMenuItem,jRadioButtonMenuItem1, | |
jRadioButtonMenuItem2,jRadioButtonMenuItem3,jRadioButtonMenuItem4,jRadioButtonMenuItem5,jRadioButtonMenuItem0 | |
,jbifontsmall,jbifontmiddle,jbifontbig; | |
public editor() | |
{ | |
jFrame=new JFrame("Editor"); | |
jFrame.setLayout(null); | |
jFrame.setBounds(1000,200,600,810); | |
//菜单栏 | |
jMenuBar=new JMenuBar(); | |
JMenu jMenuFile=new JMenu("file"); | |
JMenu jMenuSetting=new JMenu("setting"); | |
JMenu jMenuHelp=new JMenu("help"); | |
JMenu jMenuDonate=new JMenu("donate"); | |
JMenuItem jMenuOpen=new JMenuItem("open file"); | |
final JMenuItem jMenuSave=new JMenuItem("save file"); | |
JMenu jMenuFotsize=new JMenu("font size"); | |
JMenu jMenuFontstyle=new JMenu("font style"); | |
JMenu jMenuTheme=new JMenu("backgroundcolor"); | |
JMenu jMenuQRCode=new JMenu("QR Code Scanning"); | |
JMenuItem jMenuPaypal=new JMenuItem("PayPal On Line"); | |
//编码 | |
jRadioButtonMenuItem0=new JRadioButtonMenuItem("楷体",true); | |
jRadioButtonMenuItem=new JRadioButtonMenuItem("宋体",false); | |
jRadioButtonMenuItem1=new JRadioButtonMenuItem("隶书",false); | |
jRadioButtonMenuItem2=new JRadioButtonMenuItem("行楷",false); | |
//主题 | |
jRadioButtonMenuItem3=new JRadioButtonMenuItem("Classic",true); | |
jRadioButtonMenuItem4=new JRadioButtonMenuItem("Blue",false); | |
jRadioButtonMenuItem5=new JRadioButtonMenuItem("EP",false); | |
jbifontsmall=new JRadioButtonMenuItem("small",true); | |
jbifontmiddle=new JRadioButtonMenuItem("middle",false); | |
jbifontbig=new JRadioButtonMenuItem("big",false); | |
ButtonGroup bg=new ButtonGroup(); | |
bg.add(jRadioButtonMenuItem0); | |
bg.add(jRadioButtonMenuItem); | |
bg.add(jRadioButtonMenuItem1); | |
bg.add(jRadioButtonMenuItem2); | |
ButtonGroup bg0=new ButtonGroup(); | |
bg0.add(jbifontsmall); | |
bg0.add(jbifontmiddle); | |
bg0.add(jbifontbig); | |
ButtonGroup bg1=new ButtonGroup(); | |
bg1.add(jRadioButtonMenuItem3); | |
bg1.add(jRadioButtonMenuItem4); | |
bg1.add(jRadioButtonMenuItem5); | |
JMenuItem jMenuContact=new JMenuItem("contact me"); | |
JMenuItem jMenuInfo=new JMenuItem("about editor"); | |
JMenuItem jMenuAlipay=new JMenuItem("Ali pay"); | |
JMenuItem jMenuQqpay=new JMenuItem("QQ pay"); | |
JMenuItem jMenuWechatpay=new JMenuItem("WeChat pay"); | |
jMenuQRCode.add(jMenuAlipay); | |
jMenuQRCode.add(jMenuQqpay); | |
jMenuQRCode.add(jMenuWechatpay); | |
jMenuFile.add(jMenuOpen); | |
jMenuFile.add(jMenuSave); | |
jMenuFotsize.add(jbifontsmall); | |
jMenuFotsize.add(jbifontmiddle); | |
jMenuFotsize.add(jbifontbig); | |
jMenuFontstyle.add(jRadioButtonMenuItem0); | |
jMenuFontstyle.add(jRadioButtonMenuItem); | |
jMenuFontstyle.add(jRadioButtonMenuItem1); | |
jMenuFontstyle.add(jRadioButtonMenuItem2); | |
jMenuTheme.add(jRadioButtonMenuItem3); | |
jMenuTheme.add(jRadioButtonMenuItem4); | |
jMenuTheme.add(jRadioButtonMenuItem5); | |
jMenuDonate.add(jMenuQRCode); | |
jMenuSetting.add(jMenuFotsize); | |
jMenuSetting.add(jMenuFontstyle); | |
jMenuSetting.add(jMenuTheme); | |
jMenuHelp.add(jMenuContact); | |
jMenuHelp.add(jMenuInfo); | |
jMenuDonate.add(jMenuPaypal); | |
jMenuBar.add(jMenuFile); | |
jMenuBar.add(jMenuSetting); | |
jMenuBar.add(jMenuHelp); | |
jMenuBar.add(jMenuDonate); | |
jFrame.setJMenuBar(jMenuBar); | |
//头面板 | |
jPanel=new JPanel(); | |
jPanel.setLayout(null); | |
jPanel.setBounds(0,0,600,100); | |
jPanel.setBackground(Color.cyan); | |
jFrame.getContentPane().add(jPanel); | |
jTextField=new JTextField(1); | |
jTextField.setBounds(100,0,350,50); | |
jTextField.setBackground(Color.white); | |
jTextField.setFont(new Font("楷体",0,40)); | |
jButton=new JButton("Search in the web"); | |
jButton.setBounds(100,55,160,45); | |
jButton1=new JButton("Search in the text"); | |
jButton1.setBounds(290,55,160,45); | |
jPanel.add(jTextField); | |
jPanel.add(jButton); | |
jPanel.add(jButton1); | |
//String textset=jTextField.getText(); | |
//textset.getBytes(); | |
//System.out.println(textset.length()); | |
//中间滚动面板添加文本域 | |
jScrollPane=new JScrollPane(); | |
jScrollPane.setBounds(5,100,585,630); | |
jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); | |
jScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); | |
jTextArea=new JTextArea(); | |
jScrollPane.setViewportView(jTextArea); | |
jTextArea.setFont(new Font("楷体",0,20)); | |
jTextArea.setLineWrap(true); | |
jFrame.getContentPane().add(jScrollPane); | |
//脚面板 | |
jPanel1=new JPanel(); | |
jPanel1.setLayout(new FlowLayout(FlowLayout.LEFT)); | |
jPanel1.setBounds(0,730,600,80); | |
jPanel1.setBackground(new Color(236,213,182)); | |
jFrame.add(jPanel1); | |
count=new JLabel(); | |
info1=new JLabel(); | |
jPanel1.add(count); | |
jPanel1.add(info1); | |
jFrame.setVisible(true); | |
//弹出对话框 | |
//固定界面大小 | |
jFrame.setResizable(false); | |
//单击事件在网页中查找 | |
jButton.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ | |
String a=jTextField.getText(); | |
//System.out.println(a.toString()); | |
// System.out.println(a.length()); | |
//System.out.println(a.getBytes()); | |
if(a.length()!=0){ | |
String b="http://www.baidu.com/s?wd="+a+""; | |
try | |
{ | |
Desktop.getDesktop().browse(new URL(b).toURI()); | |
} catch (IOException e1) | |
{ | |
e1.printStackTrace(); | |
} catch (Exception e2 ) | |
{ | |
e2.printStackTrace(); | |
} | |
//System.out.println(jTextField.getText()); | |
//System.out.println("hello"); | |
} | |
else | |
{JOptionPane.showMessageDialog(null,"请输入查询内容");} | |
} | |
}); | |
//在文本中查找 | |
jButton1.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{int start_s,end_s; | |
String a= jTextField.getText(); | |
String b= jTextArea.getText(); | |
start_s=b.indexOf(a); | |
end_s=start_s+a.length(); | |
int ss=b.indexOf(a); | |
if (a.length()!=0) | |
{ | |
if(start_s!=-1) | |
{ | |
// ss=b.indexOf(a,ss+1); | |
//System.out.println(ss); | |
jTextArea.select(start_s,end_s); | |
//jTextArea.select(start_s,ss); | |
//int last= a.toUpperCase().indexOf(b.toUpperCase()); | |
//jTextArea.select(last,b.indexOf(a)); | |
// String str=jTextArea.getSelectedText(); | |
//b.substring(start_s,end_s); | |
//int sub_1=str.length(); | |
//int sub= str.indexOf(str,sub_1+str.indexOf(sub_1)); | |
//jTextArea.select(sub,sub_1); | |
//int sss=str. | |
//jTextArea.setCaretPosition(); | |
jTextArea.requestFocus(); | |
jTextArea.setSelectedTextColor(Color.RED); | |
jTextArea.setSelectionColor(Color.yellow); | |
// | |
// int sub_1=str.length(); | |
//int sub= str.indexOf(str,sub_1+str.indexOf(sub_1)); | |
//str.lastIndexOf() | |
// jTextArea.select(sub,sub_1); | |
//jTextArea.requestFocus(); | |
//jTextArea.setSelectionStart(b.indexOf(a)); | |
// jTextArea.setSelectionEnd(b.indexOf(a) + a.length() - 1); | |
//jTextArea.setFont(new Font("",1,20)); | |
// int start1=b.indexOf(a,end_s); | |
// int end1=start1+a.length(); | |
// jTextArea.select(start1,end1); | |
// jTextArea.requestFocus(); | |
// jTextArea.setSelectedTextColor(Color.RED); | |
// jTextArea.setSelectionColor(Color.yellow); | |
} | |
else JOptionPane.showMessageDialog(null,"未在文中找到"+a); | |
} | |
else JOptionPane.showMessageDialog(null,"请输入查询内容"); | |
}}); | |
jTextArea.addCaretListener(new CaretListener(){ | |
@Override | |
public void caretUpdate(CaretEvent e) | |
{ | |
try{ | |
//获取光标位置,距离起始位置的偏移量 | |
int posi = jTextArea.getCaretPosition(); | |
//计算行数,比较奇芭,能用,有待搞懂 | |
Rectangle rec = jTextArea.modelToView(posi); | |
int rows = rec.y / rec.height + 1; | |
//计算列数用上面的方法就不行了,先获取所在行r,但是如果设置了自动换行的话,这个r目测不好用, | |
int r = jTextArea.getLineOfOffset(posi); | |
//用光标偏移量减去行首偏移量就是列数了, | |
int columns = posi - jTextArea.getLineStartOffset(r) + 1; | |
info1.setText("【rows:" + rows + " columns:" + columns+"】"); | |
int count1=columns*rows-1; | |
count.setText("Current word counter:"+count1+" "); | |
} catch(Exception badlocation){ | |
System.out.println("bad location"); | |
} | |
} | |
} ); | |
//定义鼠标事件 | |
jMenuOpen.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ /* JDialog jDialog=new JDialog(); | |
jDialog.setBounds(400,300,600,600); | |
jDialog.setVisible(true); | |
jFileChooser.setAcceptAllFileFilterUsed(false); | |
jFileChooser.addChoosableFileFilter(new javax.swing.filechooser.FileFilter(){ | |
@Override | |
public boolean accept(File txt) | |
{ | |
return false; | |
} | |
@Override | |
public String getDescription() | |
{ | |
return null; | |
} | |
}); | |
jFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY ); | |
jFileChooser.showDialog(new JLabel(), "选择(此版本仅限于TXT文件)"); | |
jFileChooser.setAcceptAllFileFilterUsed(false); | |
jFileChooser.setFileHidingEnabled(true); | |
jFileChooser.setMultiSelectionEnabled(false); | |
File file=jFileChooser.getSelectedFile(); | |
if(file.isDirectory()){ | |
System.out.println("文件夹:"+file.getAbsolutePath()); | |
}else if(file.isFile()){ | |
//String a=file.getAbsoluteFile().toString(); | |
jTextArea.append(file.get.toString()); | |
//jFileChooser.getSelectedFile(new SelectedFile(){}); | |
System.out.println("文件:"+file.getAbsolutePath()); | |
} | |
System.out.println(jFileChooser.getSelectedFile().getName()); | |
jFileChooser.setVisible(true);*/ | |
JFileChooser chooser1=new JFileChooser(""); | |
chooser1.setBounds(400,500,600,600); | |
try | |
{ FileNameExtensionFilter filter = new FileNameExtensionFilter("Text Files", "txt"); | |
chooser1.setFileFilter(filter); | |
int returnVal = chooser1.showOpenDialog(null); | |
if(returnVal != JFileChooser.APPROVE_OPTION) { | |
return; | |
} | |
BufferedReader reader=new BufferedReader(new FileReader(chooser1.getSelectedFile())); | |
String line; | |
// StringBuilder sb = new StringBuilder(); | |
while((line=reader.readLine())!=null){ | |
// sb.append(line); | |
jTextArea.append(line); | |
} | |
reader.close(); | |
//System.out.println(sb.toString()); | |
return; | |
} | |
catch (Exception ex) | |
{ | |
ex.printStackTrace(); | |
} | |
} | |
}); | |
jMenuSave.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ | |
chooser=new JFileChooser(""); | |
chooser.setBounds(400,500,600,600); | |
try | |
{ FileNameExtensionFilter filter = new FileNameExtensionFilter("Text Files", "txt"); | |
chooser.setFileFilter(filter); | |
int returnVal = chooser.showSaveDialog(null); | |
if(returnVal != JFileChooser.APPROVE_OPTION) { | |
return; | |
} | |
String save= jTextArea.getText(); | |
byte[]bytes=save.getBytes(); | |
File file=chooser.getSelectedFile(); | |
OutputStream outputStream=new FileOutputStream(file); | |
outputStream.write(bytes); | |
outputStream.close(); | |
return; | |
} | |
catch (Exception ex) | |
{ | |
ex.printStackTrace(); | |
} | |
} | |
}); | |
//Charset | |
// | |
// jRadioButtonMenuItem0.addActionListener(new ActionListener(){ | |
// @Override | |
// public void actionPerformed(ActionEvent e) | |
// { | |
// jTextArea.setFont(new Font("楷体",0,20)); | |
// } | |
// }); | |
// jRadioButtonMenuItem0.addActionListener(new ActionListener(){ | |
// @Override | |
// public void actionPerformed(ActionEvent e) | |
// { | |
// jTextArea.setFont(new Font("楷体",0,20)); | |
// } | |
// }); | |
jRadioButtonMenuItem0.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ | |
if(jbifontsmall.isSelected()){ | |
jTextArea.setFont(new Font("楷体",0,20));} | |
else { | |
if (jbifontmiddle.isSelected()){jTextArea.setFont(new Font("楷体",0,30));} | |
else jTextArea.setFont(new Font("楷体",0,40)); | |
} | |
return ; | |
} | |
}); | |
jRadioButtonMenuItem.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ | |
if(jbifontsmall.isSelected()){ | |
jTextArea.setFont(new Font("宋体",0,20));} | |
else { | |
if (jbifontmiddle.isSelected()){jTextArea.setFont(new Font("宋体",0,30));} | |
else jTextArea.setFont(new Font("宋体",0,40)); | |
} | |
return; | |
}}); | |
jRadioButtonMenuItem1.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ | |
if(jbifontsmall.isSelected()){ | |
jTextArea.setFont(new Font("隶书",0,20));} | |
else { | |
if (jbifontmiddle.isSelected()){jTextArea.setFont(new Font("隶书",0,30));} | |
else jTextArea.setFont(new Font("隶书",0,40)); | |
} | |
return; | |
}}); | |
jRadioButtonMenuItem2.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ | |
if(jbifontsmall.isSelected()){ | |
jTextArea.setFont(new Font("华文行楷",0,20));} | |
else { | |
if (jbifontmiddle.isSelected()){jTextArea.setFont(new Font("华文行楷",0,30));} | |
else jTextArea.setFont(new Font("华文行楷",0,40)); | |
} | |
return; | |
}}); | |
jbifontsmall.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ | |
if (jRadioButtonMenuItem0.isSelected()) | |
{ | |
jTextArea.setFont(new Font("楷体", 0, 20)); | |
} else | |
{ | |
if (jRadioButtonMenuItem.isSelected()) | |
{ | |
jTextArea.setFont(new Font("宋体", 0, 20)); | |
} | |
else { | |
if (jRadioButtonMenuItem1.isSelected()){jTextArea.setFont(new Font("隶书",0,20));} | |
else jTextArea.setFont(new Font("华文行楷",0,20)); | |
}} | |
} | |
}); | |
jbifontmiddle.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ | |
if (jRadioButtonMenuItem0.isSelected()) | |
{ | |
jTextArea.setFont(new Font("楷体", 0, 30)); | |
} else | |
{ | |
if (jRadioButtonMenuItem.isSelected()) | |
{ | |
jTextArea.setFont(new Font("宋体", 0, 30)); | |
} | |
else { | |
if (jRadioButtonMenuItem1.isSelected()){jTextArea.setFont(new Font("隶书",0,30));} | |
else jTextArea.setFont(new Font("华文行楷",0,30)); | |
}} | |
} | |
}); | |
jbifontbig.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ | |
if (jRadioButtonMenuItem0.isSelected()) | |
{ | |
jTextArea.setFont(new Font("楷体", 0, 40)); | |
} else | |
{ | |
if (jRadioButtonMenuItem.isSelected()) | |
{ | |
jTextArea.setFont(new Font("宋体", 0, 40)); | |
} | |
else { | |
if (jRadioButtonMenuItem1.isSelected()){jTextArea.setFont(new Font("隶书",0,40));} | |
else jTextArea.setFont(new Font("华文行楷",0,40)); | |
}} | |
} | |
}); | |
//theme | |
jRadioButtonMenuItem3.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ | |
jTextArea.setBackground(Color.white); | |
} | |
}); | |
jRadioButtonMenuItem4.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{jTextArea.setBackground(new Color(21,113,250)); | |
jTextArea.setSelectionColor(Color.white); | |
//jTextArea.setDisabledTextColor(Color.magenta); | |
// jTextArea.setCaretColor(Color.yellow); | |
jTextArea.setSelectedTextColor(Color.green); | |
} | |
}); | |
jRadioButtonMenuItem5.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ | |
jTextArea.setBackground(new Color(112,167,57)); | |
jTextArea.setSelectionColor(Color.white); | |
//jTextArea.setDisabledTextColor(Color.magenta); | |
// jTextArea.setCaretColor(Color.yellow); | |
jTextArea.setSelectedTextColor(Color.green); | |
} | |
}); | |
jMenuContact.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ | |
JDialog jDialog=new JDialog(); | |
//"QQ:2057844199(@qq.com)"+"Gmail:augerta1995@gmail.com"+"Wechat:L-U-V-" | |
JLabel j=new JLabel(); | |
//j.setBounds(400,500,600,600); | |
//JTextField jf=new JTextField("QQ:2057844199(@qq.com)"+"/r/n"+"Gmail:augerta1995@gmail.com"+"/r/n"+"Wechat:L-U-V-"); | |
//j.add(jf); | |
j.setFont(new Font("楷体",0,30)); | |
j.setText("<HTML><br><br><li>QQ:2057844199(@qq.com)</li><br><br><li>Gmail:augerta1995@gmail.com</li><br><br><li>Wechat:L-U-V-</li><br><hr>爱生活爱技术欢迎和我探讨问题</HTML>"); | |
jDialog.add(j); | |
jDialog.setLayout(new FlowLayout()); | |
jDialog.setBounds(400,500,600,600); | |
jDialog.setVisible(true); | |
} | |
}); | |
jMenuInfo.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ | |
JDialog jDialog=new JDialog(); | |
JLabel j1=new JLabel(); | |
JLabel j=new JLabel(); | |
int backw = jDialog.getWidth(); | |
int backh = jDialog.getHeight(); | |
j1.setSize(backw, backh); | |
j1.setText("<html><body><image width='" + backw | |
+ "' height=400 src=" | |
+ this.getClass().getResource("image/4.jpg") | |
+ "'></img></body></html>"); | |
j.setFont(new Font("楷体",0,20)); | |
j.setText("<HTML><body><br><div align='center'><li>开发工具:Intellij IDEA企业版</li><br><li>为了结束苦逼的图形界面编程,我才做了这个丑的不行编辑器巩固一下知识<br><h1>注:文件编码未解决!!</h1><br>Copyright@潇湘夜雨 保留所有权力<hr>爱生活爱技术欢迎和我探讨问题</div></body></HTML>"); | |
jDialog.add(j1); | |
jDialog.add(j); | |
jDialog.setLayout(new FlowLayout()); | |
jDialog.setBounds(400,200,800,800); | |
jDialog.setVisible(true); | |
} | |
}); | |
jMenuQqpay.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ | |
JDialog jDialog=new JDialog(); | |
jDialog.setBounds(400,0,800,1000); | |
jDialog.setTitle("QQ Pay"); | |
JLabel j=new JLabel(); | |
int backw = jDialog.getWidth(); | |
int backh = jDialog.getHeight(); | |
j.setSize(backw, backh); | |
j.setText("<html><body><image width='" + backw | |
+ "' height='" + backh + "' src=" | |
+ this.getClass().getResource("image/2.jpg") | |
+ "'></img></body></html>"); | |
jDialog.add(j); | |
jDialog.setVisible(true); | |
} | |
}); | |
jMenuAlipay.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ | |
JDialog jDialog=new JDialog(); | |
jDialog.setTitle("Ali Pay"); | |
jDialog.setBounds(400,0,800,1000); | |
JLabel j=new JLabel(); | |
int backw = jDialog.getWidth(); | |
int backh = jDialog.getHeight(); | |
j.setSize(backw, backh); | |
j.setText("<html><body><image width='" + backw | |
+ "' height='" + backh + "' src=" | |
+ this.getClass().getResource("image/1.jpg") | |
+ "'></img></body></html>"); | |
jDialog.add(j); | |
jDialog.setVisible(true); | |
} | |
}); | |
jMenuWechatpay.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ | |
JDialog jDialog=new JDialog(); | |
jDialog.setTitle("WeChat Pay"); | |
jDialog.setBounds(400,0,800,1000); | |
JLabel j=new JLabel(); | |
int backw = jDialog.getWidth(); | |
int backh = jDialog.getHeight(); | |
j.setSize(backw, backh); | |
j.setText("<html><body><image width='" + backw | |
+ "' height='" + backh + "' src=" | |
+ this.getClass().getResource("image/WeChat.jpg") | |
+ "'></img></body></html>"); | |
jDialog.add(j); | |
jDialog.setVisible(true); | |
} | |
}); | |
jMenuPaypal.addActionListener(new ActionListener(){ | |
@Override | |
public void actionPerformed(ActionEvent e) | |
{ | |
try | |
{ | |
Desktop.getDesktop().browse(new URL("https://www.Paypal.me/TDonate/2").toURI()); | |
} catch (IOException e1) | |
{ | |
e1.printStackTrace(); | |
} catch (URISyntaxException e1) | |
{ | |
e1.printStackTrace(); | |
} | |
} | |
}); | |
jTextArea.addKeyListener(new KeyListener(){ | |
@Override | |
public void keyTyped(KeyEvent e) | |
{ | |
} | |
@Override | |
public void keyPressed(KeyEvent e) | |
{ | |
if (jMenuSave.isArmed()){ | |
if(e.isControlDown()&&e.getKeyCode() ==83){ | |
jMenuSave.doClick(); | |
} | |
else { | |
if(e.isControlDown()&&e.getKeyCode() ==83){ | |
String save1= jTextArea.getText(); | |
byte[]bytes=save1.getBytes(); | |
File file=chooser.getSelectedFile(); | |
OutputStream outputStream= null; | |
try | |
{ | |
outputStream = new FileOutputStream(file); | |
outputStream.write(bytes); | |
outputStream.close(); | |
} catch (Exception e1) | |
{ | |
e1.printStackTrace(); | |
} | |
} | |
} } | |
} | |
@Override | |
public void keyReleased(KeyEvent e) | |
{ | |
} | |
}); | |
} | |
public static void main(String[] args) | |
{ | |
new editor(); | |
}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Manifest-Version: 1.0 | |
Main-Class: editor | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment