📄 systemm.java
字号:
package MyLibraryok.MyMain;
import java.awt.*;
import javax.swing.*;
import java.util.Properties;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class SystemM extends JDialog {
Dimension screen = getToolkit().getScreenSize(); //得到屏幕尺寸
int myWidth = screen.width;
int myHeight = screen.height;
int x =420,y=210;
JTextArea jTextArea1 = new JTextArea();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JButton jButton1 = new JButton();
MainFrame2 ss;
public SystemM(MainFrame2 ss) {
super(ss, "", true);
this.ss = ss;
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
Process p = null;
Properties envVars = new Properties();
Runtime r = Runtime.getRuntime();
try {
p = r.exec("cmd.exe /c set user");
BufferedReader br = new BufferedReader(new InputStreamReader(p.
getInputStream()));
String line;
//第一行是机器名;第二行是当前登陆的用户名,第三个是当前登陆用户的主文件夹
while ((line = br.readLine()) != null) {
int idx = line.indexOf('=');
String key = line.substring(0, idx);
String value = line.substring(idx + 1);
envVars.setProperty(key, value);
String lls = value;
//System.out.println(lls);
// kk.setText("<html>"+kk.getText()+"<br>"+lls+"</html>");
jTextArea1.append(lls + '\n' + '\n');
//System.out.println(key + " = " + value);
// System.out.println();
}
} catch (Exception e) {
e.printStackTrace();
}
getContentPane().setLayout(null);
jTextArea1.setBounds(new Rectangle(106, 11, 370, 117));
jTextArea1.setFont(new java.awt.Font("Dialog", Font.BOLD, 14));
jTextArea1.setOpaque(false);
jTextArea1.setEditable(false);
jLabel1.setBounds(new Rectangle(5, 11, 99, 20));
jLabel1.setFont(new java.awt.Font("Dialog", Font.BOLD, 13));
jLabel2.setFont(new java.awt.Font("Dialog", Font.BOLD, 13));
jLabel2.setText("主机登录用户:");
jLabel2.setBounds(new Rectangle(3, 49, 99, 20));
jLabel3.setFont(new java.awt.Font("Dialog", Font.BOLD, 13));
jLabel3.setText("用户工作目录:");
jLabel3.setBounds(new Rectangle(2, 92, 99, 20));
jButton1.setBounds(new Rectangle(330, 155, 76, 26));
jButton1.setFont(new java.awt.Font("Dialog", Font.BOLD, 13));
jButton1.setText("确 定");
jButton1.addActionListener(new SystemM_jButton1_actionAdapter(this));
this.getContentPane().add(jTextArea1);
this.getContentPane().add(jLabel1);
this.getContentPane().add(jLabel3);
this.getContentPane().add(jLabel2);
this.getContentPane().add(jButton1);
jLabel1.setText("主 机 名:");
// Center the frame
if (x >= myWidth || y >= myHeight) {
x = myWidth;
y = myHeight;
this.setSize(x, y);
this.setLocation(0, 0);
} else {
this.setSize(x, y);
this.setLocation((myWidth - this.getSize().width) / 2,
(myHeight - this.getSize().height) / 2);
}
////////////////// Center the frame
// this.setSize(420, 210);
// this.setVisible(true);
}
public static void main(String[] args) {
SystemM system = new SystemM(null);
}
public void jButton1_actionPerformed(ActionEvent e) {
this.setVisible(false);
}
}
class SystemM_jButton1_actionAdapter implements ActionListener {
private SystemM adaptee;
SystemM_jButton1_actionAdapter(SystemM adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -