📄 mainmenu.java~79~
字号:
package Statistics;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class MainMenu extends JFrame {
//String s;
JMenuBar jMenuBar1 = new JMenuBar();
JMenu jMenu1 = new JMenu();
JMenu jMenu2 = new JMenu();
JMenuItem jMenuItem1 = new JMenuItem();
JMenuItem jMenuItem2 = new JMenuItem();
JMenuItem jMenuItem3 = new JMenuItem();
JMenuItem jMenuItem4 = new JMenuItem();
JMenuItem jMenuItem5 = new JMenuItem();
JMenuItem jMenuItem6 = new JMenuItem();
JMenuItem jMenuItem7 = new JMenuItem();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JButton jButton4 = new JButton();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JLabel jLabel5 = new JLabel();
JLabel jLabel6 = new JLabel();
JLabel jLabel7 = new JLabel();
public MainMenu() {
try {
settext1();
settext2();
settext3();
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
MainMenu mainMenu1 = new MainMenu();
}
private void jbInit() throws Exception {
this.getContentPane().setLayout(null);
jMenu1.setPreferredSize(new Dimension(115,15));
jMenu1.setMargin(new Insets(2, 2, 2, 2));
jMenu1.setText("Application");
jMenu2.setPreferredSize(new Dimension(85,15));
jMenu2.setText("Help");
jMenuItem1.setText("Help");
jMenuItem2.setText("Open Log File...");
//jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
//public void actionPerformed(ActionEvent e) {
// jMenuItem2_actionPerformed(e);
//}
//});
jMenuItem3.setText("Open...");
jMenuItem4.setText("Save As...");
jMenuItem5.setText("Close File");
jMenuItem6.setText("Exit");
jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jMenuItem6_actionPerformed(e);
}
});
jMenuItem7.setText("About");
jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jMenuItem7_actionPerformed(e);
}
});
jButton1.setBounds(new Rectangle(172, 123, 243, 32));
jButton1.setText("Daily Transmission Statistics");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton1_actionPerformed(e);
}
});
jButton2.setBounds(new Rectangle(171, 169, 248, 32));
jButton2.setText("Hourly Transmission Statistics");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton2_actionPerformed(e);
}
});
jButton3.setBounds(new Rectangle(171, 218, 248, 33));
jButton3.setText("Total Transfers by Client Domain");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton3_actionPerformed(e);
}
});
jButton4.setBounds(new Rectangle(160, 269, 275, 30));
jButton4.setText("Total Transfers by Reseverd Subdomain");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton4_actionPerformed(e);
}
});
jLabel1.setFont(new java.awt.Font("Dialog", 1, 16));
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setText("Access Statistics for Web Page");
jLabel1.setBounds(new Rectangle(145, 36, 290, 33));
jLabel2.setBounds(new Rectangle(97, 74, 385, 18));
jLabel2.setHorizontalAlignment(SwingConstants.CENTER);
jLabel3.setBounds(new Rectangle(141, 330, 321, 23));
jLabel3.setHorizontalAlignment(SwingConstants.CENTER);
jLabel4.setFont(new java.awt.Font("Dialog", 0, 10));
jLabel4.setBounds(new Rectangle(163, 370, 350, 24));
jLabel5.setFont(new java.awt.Font("Dialog", 0, 10));
jLabel5.setBounds(new Rectangle(163, 422, 350, 24));
jLabel6.setFont(new java.awt.Font("Dialog", 0, 10));
jLabel6.setBounds(new Rectangle(163, 442, 350, 24));
jLabel7.setFont(new java.awt.Font("Dialog", 0, 10));
jLabel7.setBounds(new Rectangle(163, 462, 350, 24));
jMenuBar1.add(jMenu1);
jMenuBar1.add(jMenu2);
jMenuBar1.setBounds(0,0,130,20);
jMenu2.add(jMenuItem1);
jMenu2.add(jMenuItem7);
jMenu1.add(jMenuItem2);
jMenu1.add(jMenuItem3);
jMenu1.add(jMenuItem4);
jMenu1.add(jMenuItem5);
jMenu1.addSeparator();
jMenu1.addSeparator();
jMenu1.add(jMenuItem6);
this.getContentPane().add(jMenuBar1);
this.getContentPane().add(jLabel1, null);
this.getContentPane().add(jLabel2, null);
this.getContentPane().add(jButton1, null);
this.getContentPane().add(jButton2, null);
this.getContentPane().add(jButton3, null);
this.getContentPane().add(jButton4, null);
this.getContentPane().add(jLabel3, null);
this.getContentPane().add(jLabel5, null);
this.getContentPane().add(jLabel6, null);
this.getContentPane().add(jLabel7, null);
this.getContentPane().add(jLabel4, null);
this.setBounds(0,0,600,600);
this.setVisible(true);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
void jMenuItem6_actionPerformed(ActionEvent e) {
System.exit(0);
}
//void jMenuItem2_actionPerformed(ActionEvent e) {
// conLog c;
//c = new conLog();
// c.conLog();
// }
void jButton1_actionPerformed(ActionEvent e) {
Daily d;
d = new Daily();
d.Daily();
}
void jButton2_actionPerformed(ActionEvent e) {
Hourly h;
h = new Hourly();
h.Hourly();
}
void jButton3_actionPerformed(ActionEvent e) {
Domain domain;
domain = new Domain();
try {
domain.jbInit();
}
catch(Exception ex) {
ex.printStackTrace();}
}
void jMenuItem7_actionPerformed(ActionEvent e) {
About about;
about = new About();
try {
about.jbInit();
}
catch(Exception ex) {
ex.printStackTrace();}
}
void jButton4_actionPerformed(ActionEvent e) {
SubDomain sub;
sub = new SubDomain();
try {
sub.jbInit();
}
catch(Exception ex) {
ex.printStackTrace();}
}
public void settext1(){
BufferedReader br =null;
try{
br = new BufferedReader(new FileReader("Z:\\accessstatistics.htm"));
String line="";
while ( (line = br.readLine()) != null) {
if (line.equals("<H1>Access Statistics for Web Pages</H1><EM>")) {
jLabel2.setText(br.readLine());
}
}
}
catch(IOException e1){System.out.println("file not found");}
}
public void settext2(){
BufferedReader br =null;
try{
br = new BufferedReader(new FileReader("Z:\\accessstatistics.htm"));
String line="";
while ( (line = br.readLine()) != null) {
if (line.equals(" Transfers from each Archive Section</A> </LI></UL>")) {
br.readLine();
jLabel3.setText(br.readLine());
}
}
}
catch(IOException e1){System.out.println("file not found");}
}
public void settext3(){
BufferedReader br =null;
try{
br = new BufferedReader(new FileReader("Z:\\accessstatistics.htm"));
String line = "";
while ( (line = br.readLine()) != null) {
if (line.equals("</H2><PRE>")) {
jLabel4.setText(br.readLine());
jLabel5.setText(br.readLine());
jLabel6.setText(br.readLine());
jLabel7.setText(br.readLine());
}
}
}
catch(IOException e1){System.out.println("file not found");}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -