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

📄 application.java

📁 JAVA写的一个机器人程序
💻 JAVA
字号:
package rebot;

import java.awt.*;
import javax.swing.*;
import java.sql.*;
import java.util.*;
import javax.swing.plaf.metal.*;
import java.net.URL;
import rebot.SplashScreen;

public class Application {


    boolean packFrame = false;
    public static String name = new String();
    public static String image = new String();
    public static Calendar calendar = Calendar.getInstance();
    public static String fulltime = calendar.get(Calendar.YEAR) + "-" +
                                    (calendar.get(Calendar.MONTH) + 1) + "-" +
                                    calendar.get(Calendar.DATE) + " " +
                                    calendar.get(Calendar.HOUR_OF_DAY) + ":" +
                                    calendar.get(Calendar.MINUTE) + ":" +
                                    calendar.get(Calendar.SECOND);

    public static String filetime = "" + calendar.get(Calendar.YEAR) + "-" +
                                    (calendar.get(Calendar.MONTH) + 1) + "-" +
                                    calendar.get(Calendar.DATE);


    /**
     * Construct and show the application.
     */
    public Application() {

        Mainframe frame = new Mainframe();
        URL url = getClass().getResource("/image/logo.png");
        frame.setIconImage(new ImageIcon(url).getImage());
        // Validate frames that have preset sizes
        // Pack frames that have useful preferred size info, e.g. from their layout
        if (packFrame) {
            frame.pack();
        } else {
            frame.validate();
        }

        // Center the window
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = frame.getSize();
        if (frameSize.height > screenSize.height) {
            frameSize.height = screenSize.height;
        }
        if (frameSize.width > screenSize.width) {
            frameSize.width = screenSize.width;
        }
        frame.setLocation((screenSize.width - frameSize.width) / 2,
                          (screenSize.height - frameSize.height) / 2);
        frame.setVisible(true);
        frame.jTextArea2.grabFocus();

    }

    /**
     * Application entry point.
     *
     * @param args String[]
     */
    public static void main(String[] args) throws Exception {
        SplashScreen splash = new SplashScreen(4400);
        splash.showSplashAndExit();
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String dburl =
                    "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=data/user.mdb"; //此为NO-DSN方式
            Connection conn = DriverManager.getConnection(dburl);
            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery(
                    "select selected,username,image,language from userdb order by num DESC");
            if (rs.next()) {
                String select = rs.getString(1).trim();
                String uname = rs.getString(2).trim();
                if (select.equals("1")) {
                    Application.name = uname;
                    Application.image = rs.getString(3).trim();
                    language.lang=rs.getBoolean(4);
                } else {
                    language.lang=rs.getBoolean(4);
                    if(language.lang){
                        Application.name = "用户";
                    }
                    else{
                        Application.name = "User";
                    }
                    Application.image = System.getProperty("user.dir") +
                                        "/image/doraemon.gif";

                }
            } else {
                Application.name = "用户";
                Application.image = System.getProperty("user.dir") +
                                    "/image/doraemon.gif";
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                try {
                    UIManager.setLookAndFeel(new MetalLookAndFeel()); //Metal风格
                    //UIManager.setLookAndFeel(new MotifLookAndFeel());//MotifLookAndFeel风格
                    //UIManager.setLookAndFeel(new WindowsLookAndFeel());//Windows风格
                    //UIManager.setLookAndFeel(new WindowsClassicLookAndFeel());//WindowsClassic风格

                } catch (Exception exception) {
                    exception.printStackTrace();
                }

                new Application();
            }
        });
    }
}

⌨️ 快捷键说明

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