设置emacs在shell中显示

emacs安装之后在终端里面打开的是图形版,要想在shell里面直接打开就在~/.bashrc里面添加alias emacs=’emacs -nw’
注意等号两边没有空格

在eclipse中使用vim

参考链接: https://blog.csdn.net/wr132/article/details/70232043

  1. 在help中找到Install New SoftWare,点击add,输入name和网址
  2. 选择viPlugin,之后点击next和accept

3.在eclipse根目录建立文件 viPlugin2.lic ,在其中输入 q1MHdGlxh7nCyn_FpHaVazxTdn1tajjeIABlcgJBc20

  1. 这里注意在安装插件过程中eclipse是没有什么反应的,这个时候不要重启,我之前按照教程里面说的选择了accept, next之后几秒种没反应就直接手动restart了,这个时候其实是在下载,最后eclipse会出现警告,点击install anyway,最后eclipse会弹出restart,点击这个就没问题了

5.vim模式的切换快捷键为Ctrl-Alt-v

How to operate xsel in Linux?

  1. first download xsel in Linux by using this command: sudo apt-get install xsel
    or
    download the xsel(the link is in my other blog–Link Collection)
    modify the ~/.bashrc by vim or emacs
    For example:

    1
    2
    3
    vim ~/.bashrc
    in the last line add: export PATH='~/XselDirectory/'
    source ~/.bashrc //make the operation effective
  2. Some operation
    xsel < file //read file content to xsel
    xsel > file //write xsel content to xsel
    xsel // show xsel content
    cat file | xsel -b -i //file to xsel
    cat file | xsel -b -a //add file content to xsel last line

more content can read README in XselDirectory

c++ 和 java添加环境变量

1
2
3
4
//MinGW(以下根据自己的目录来)
Path: E:\BaiduNetdiskDownload\MinGW\mingw64\bin
INCLUDE: E:\BaiduNetdiskDownload\MinGW\mingw64\include
Lib: E:\BaiduNetdiskDownload\MinGW\mingw64\libx
1
2
3
4
JAVA_HOME:           F:\Java\jdk-10.0.2(根据自己的安装目录来)
CLASSPATH: .;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar
Path:第一个: %JAVA_HOME%\bin
第二个: %JAVA_HOME%\jre\bin

java题库导出

题库链接: https://pan.baidu.com/s/1QRMfkJWUWN6F-dP5GaQ8jQ   提取码:eus0
jd-gui反编译工具链接: https://pan.baidu.com/s/1v0a6asCluIgqeswpR515ww   提取码:308t

该题库软件支持jdk1.8版本

  1. 下载完成之后,将jd-gui-1.4.0.jar放置在该软件目录下的jar/bin/中,打开cmd命令行窗口,再执行:
    java.exe -jar jd-gui-1.4.0.jar,即可打开反编译的软件

通过反编译可以查看Tiku.jar中的内容,发现对象流指向的输出流对象是Problem类,这样我们可以先将题库中的内容提取出来,然后转型为ArrayList,之后就可以通过循环将文件内容输入到文本中。这里为了保持目录的一致性,可以先用数组存储每一个章节题目的位置信息,按照章节来将题库导出,File类中有mkdir()方法,可以创建目录,使用write()方法可以写入内容,由于将题目写入txt文本中之后,格式并不太友好,我这里使用缓冲流,因为里面有newline()方法,可以添加空行。我将ArrayList中的内容遍历,如果是’\n’则使用newline()添加空行,这样使得文本内容更易于查看.

  1. 将Tiku.jar文件导入eclipse中,将如下代码添加到eclipse文本窗口中
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
import java.io.BufferedWriter;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.util.ArrayList;

import quesion.data.Problem;

/**
* @author Administrator
*
*/
public class GetData implements Serializable{
String readPath; //题库目录
String writePath; //导出目录
String chapter[]; //存储章节信息
String type[]; //存储题目类型
ArrayList<Problem> problems; //problems存储题库内容
File readFile;
File writeFile;
FileInputStream fis;
ObjectInputStream ois;
FileWriter fw;
BufferedWriter bw;

public GetData() {
readPath = "C:\\Users\\Administrator\\Desktop\\java\\题库\\";
writePath = "C:\\Users\\Administrator\\Desktop\\data\\";
chapter = new String[15];
for(int i = 0; i < 15; i++)
chapter[i] = "第" + (i + 1) + "章\\";
type = new String[4];
type[0] = "读程题";
type[1] = "判断题";
type[2] = "挑错题";
type[3] = "选择题";
}

public void importFile() {
File directory;
for(int i = 0; i < 15; i++) {
for(int j = 0; j < 4; j++) {
readFile = new File(readPath + chapter[i] + type[j] + ".data"); //将每一个文件的地址提取出来
directory = new File(writePath + chapter[i]);
if(!directory.exists()) //判断目录是否存在,不存在就创建
directory.mkdir();
writeFile = new File(writePath + chapter[i] + type[j] + ".txt"); //文件输出地址
if(readFile.exists()) { //如果读取的文件存在
try {
fis = new FileInputStream(readFile); //文件输入流
ois = new ObjectInputStream(fis); //对象输入流
fw = new FileWriter(writeFile);
bw = new BufferedWriter(fw); //缓冲流
problems = new ArrayList<Problem>();
problems = (ArrayList<Problem>)(ois.readObject()); //对象输入流使用readObject()方法读取一个对象到程序中
for(Problem p : problems) { //循环遍历problems
String s = p.content; //content是题库代码中的题目属性
int flag = 0; //这里实际题库中会出现第一个字符就是'\n',我这里使用flag标记,不在第一排输出空行
if(p.content != null) {
for(int m = 0; m < s.length(); m++)
if(s.charAt(m) == '\n' && flag != 0) {
bw.newLine(); //添加新的行数
}
else {
bw.write(s.charAt(m));
flag = 1;
}
}
bw.newLine();
s = p.correctAnswer; //correctAnswer是题库代码中的答案属性
flag = 0;
if(p.correctAnswer != null) {
for(int m = 0; m < s.length(); m++)
if(s.charAt(m) == '\n' && flag != 0) {
bw.newLine();
}
else {
bw.write(s.charAt(m));
flag = 1;
}
}
bw.newLine();
}
ois.close(); //关闭各个流
fis.close();
bw.close();
} catch (FileNotFoundException e) {
} catch (IOException e) {
} catch (ClassNotFoundException e) {
}
}

}
}
}

public static void main(String[] args) {
GetData data = new GetData();
data.importFile();
}
}

java中的消息对话框

1
2
JOptionPane.showMessageDialog(this, "当前位置有棋子");   //弹出对话框,this表示当前对象
int result = JOptionPane.showConfirmDialog(this, "是否退出游戏"); //弹出对话选择框,是返回0, 否返回1,取消返回2,可以使用int型变量保存,方便判断选择的是哪一个


关于JFrame使用setBackground()设置背景色没反应的问题

参考链接: https://zhidao.baidu.com/question/263731760.html
参考链接: https://blog.csdn.net/qq_34970891/article/details/69665986

原因:JFrame当中会默认使用流式布局管理器(FlowLayout)将整个窗体进行覆盖操作,也就是说设置的颜色确实是存在的,只是被布局管理器给覆盖住了,所以无法看见。

1. 如果直接使用Frame,则修改背景色使用setBackColor(Color.black);

2. 使用JFrame修改背景色

方法一: 调用getContentPane()方法得到一个contentPane容器,然后将其设置为不可见

1
2
setBackground(Color.black);
getContentPane().setVisible(true);

方法二: 在JFrame当中添加一个面板容器,使得面板容器对窗体形成一个覆盖后,直接设置面板的背景颜色就可以达到相当于对窗体背景颜色进行设置的效果

1
2
Container con = getContentPane();
con.setBackground(Color.black);

|