📄 supportlist1.java
字号:
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
/**
* SupportList1 the component {@link JTextArea}. This class extends
* class {@link @JPanel}.
*
* @author handazhi
* @version 1.3
*/
public class SupportList1 extends JPanel {
private JTextArea textAreaOne;
private JButton b1,b2;
// Container c = getContentPane() ;
/**
* Create a window.
*
* @param aa is a reference of <strong>SupportList1</strong>.
*/
static void resetList(){
try{
PrintWriter fileOut =
new PrintWriter(new FileWriter(List1.getFileName()));
fileOut.println("函大制 999 999_函大制 999 999_函大制 999 999_函大制 999 999_函大制 999 999");
fileOut.close();
/* String paraString ="\t"+"名次" +"\t"+"名字 \t 步数 \t 用时(秒)\n\t";
String littleTemp = " ";
for(int i=0;i<5;i++){//这句话很不好!! 耦
StringTokenizer tokenizer = new StringTokenizer("函大制 999 999"," ");
paraString += (i+1)+"\t"+tokenizer.nextToken()+"\t"+littleTemp+tokenizer.nextToken()+"\t"+littleTemp+tokenizer.nextToken()+"\n"+"\t";
}
textAreaOne.setText(paraString);*/
List1 d1 = new List1();
//d1.readFromFile();
d1.initializationarrays();
d1.printList();
}catch(IOException ioe){
System.err.println("Error");
ioe.printStackTrace();
}
catch(Exception e){
System.exit(0);
}
}
static void woailuo(SupportList1 aa){
// public static void main(String[] args) {
JFrame frame = new JFrame("汉诺英雄排行榜:");
frame.setContentPane(aa);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack(); // Adjust the size of the window
frame.setVisible(true);
}
/**
* Creates two {@link JTextArea} components.
*/
public SupportList1(String s) {//通过这里设置标题
setLayout(new BorderLayout(2, 1));
setBackground(Color.white);
b1 = new JButton("关闭");
//bbutton.setBackground(Color.blue);
b2 = new JButton("重置");
class Listener1 implements ActionListener{
public void actionPerformed(ActionEvent e){
if(b1.getText()=="关闭"){
System.exit(0);
}
}
}
b1.addActionListener(new Listener1());
class Listener2 implements ActionListener{
public void actionPerformed(ActionEvent Event){
if(b2.getText()=="重置"){
resetList();
/*try{
PrintWriter fileOut =
new PrintWriter(new FileWriter(List1.getFileName()));
fileOut.println("匿名 999 999—匿名 999 999—匿名 999 999");
fileOut.close();
}catch(IOException ioe){
System.err.println("Error");
ioe.printStackTrace();
}
catch(Exception e){
System.exit(0);
}*/
// List1 d1 = new List1();
// d1.readFromFile();
// d1.printList();
}
}
}
b2.addActionListener(new Listener2());
JPanel p = new JPanel();
p.setBackground(new Color(0, 0, 150));
// p.setLayout(new GridLayout(2, 2));
p.add(b1);
p.add(b2);
//
// Create the components
textAreaOne = new JTextArea(s, 20,40);//调整大小
// Change the colors of the components
textAreaOne.setBackground(new Color(0, 0, 150));//调整颜色
textAreaOne.setForeground(Color.white);
// Make the text area un-editable
textAreaOne.setEditable(false);
// Add text area components to the scrollbar container.
this. add(new JScrollPane(textAreaOne,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED),BorderLayout.CENTER);
this.add(p,BorderLayout.PAGE_END);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -