⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viewlog.java

📁 一个优秀的干洗店管理系统
💻 JAVA
字号:
package view.dialog.log;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.File;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.border.Border;

import view.control.viewaction.ViewLogAction;




public class ViewLog extends JDialog {

  /**
   * 
   */
  private static final long serialVersionUID = 1L;

  private JTextArea text;

  private JButton btn;

  private Border etched = BorderFactory.createEtchedBorder();

  private ViewLogAction action;

  private JComboBox com;

  public ViewLog() {
    this.setModal(true);
    this.setTitle("查看日志文件");
    this.setSize(600, 600);
    Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
    this.setLocation((int) (size.getWidth() - this.getWidth()) / 2, (int) (size
        .getHeight() - this.getHeight()) / 2);
    initialDialog();
  }

  public void initialDialog() {
    action = new ViewLogAction(this);
    text = new JTextArea();
    text.setEditable(false);
    this.setLayout(new BorderLayout());
    this.add(new JScrollPane(text), BorderLayout.CENTER);
    this.add(getInfoPanel(), BorderLayout.SOUTH);
  }

  public JPanel getInfoPanel() {
    JPanel panel = new JPanel();
    panel.add(new JLabel("请选择要打开的日志文件:"));
    panel.add(com = new JComboBox(getFile()));
    panel.add(getButton("打开日志文件"));
    panel.add(getButton("退出"));
    panel.setBorder(BorderFactory.createTitledBorder(etched, "请选择"));
    com.addItemListener(action);
    ViewLogAction.logfilename=this.getSelectItem();
    return panel;
  }

  public JButton getButton(String name) {
    btn = new JButton(name);
    btn.addActionListener(action);
    return btn;
  }

  public String[] getFile() {
    File f = new File("日志文件");
    return f.list();
  }
  public void setText(String str){
    this.text.setText(str);
  }
  public String getSelectItem() {
    return this.com.getSelectedItem().toString().trim();
  }
  public static void main(String[] args){
    new ViewLog().setVisible(true);
  }
  
 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -