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

📄 java2demo.java~2~

📁 风机在线监测系统,采用sqlserver数据库,有问题联系我
💻 JAVA~2~
字号:
package java2d;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.font.FontRenderContext;import java.awt.font.TextLayout;import java.sql.Connection;import java.util.MissingResourceException;import java.util.ResourceBundle;import javax.swing.*;import javax.swing.border.EtchedBorder;public class Java2Demo extends JPanel {    static plotArray pArray;    static plotArrayLY pArrayLY;    static plotArrayRX pArrayRX;    static plotArrayRY pArrayRY;    static float al1 = (float) 7.0;    static float al2 = (float) 9.5;    static Connection connection;    static dataPool datapool;    static Java2Demo demo;    static GlobalControls controls;    static MemoryMonitor memorymonitor;    static PerformanceMonitor performancemonitor;    static JTabbedPane tabbedPane;    static JLabel progressLabel, welcome, title;    static JProgressBar progressBar;    static DemoGroup group[];    static Color backgroundColor;    static Intro intro;    private ResourceBundle bundle;    int textLocation;    String text;    javax.swing.Timer timer;    static String[][] demos0 = { {"振动", "风机左X", "风机左Y", "风机右X", "风机右Y"}, {"位移",                               "风机左Z", "风机右Z", }, {"温度", "风机左", "风机右", "电机左",                               "电机右"}, {"电流", "电流1",                               "电流2", "电流3"}, {"电压", "电压"}    };    static String[][] demos = { {"振动", "LX", "LY", "RX", "RY"}, {"位移", "LZ",                              "RZ", }, {"温度", "FL", "FR", "DL", "DR"}, {"电流",                              "C1", "C2", "C3"}, {"电压", "dianya"}    };    private GlobalPanel gp;    /**     * Construct the Java2D Demo.     */    public Java2Demo() {        pArray = new plotArray();        pArrayLY = new plotArrayLY();        pArrayRX = new plotArrayRX();        pArrayRY = new plotArrayRY();        textLocation = 0;        datapool = new dataPool();        connection = datapool.con;        System.out.println("Java2Demo's connection has been initated!");        setLayout(new BorderLayout());        setBorder(new EtchedBorder());        bundle = null;        text = getString("welcome.text");        welcome.setFont(new Font("serif", Font.BOLD + Font.ITALIC, 40));        title.setFont(new Font("serif", Font.BOLD + Font.ITALIC, 50));        title.setText("武钢炼铁厂 在线监测系统");        progressBar.setMaximum(text.length() + 5);        timer = new javax.swing.Timer(100, createTextLoadAction());        timer.start();        intro = new Intro();        progressBar.setValue(progressBar.getValue() + 1);        UIManager.put("Button.margin", new Insets(0, 0, 0, 0));        controls = new GlobalControls();        memorymonitor = new MemoryMonitor();        performancemonitor = new PerformanceMonitor();        GlobalPanel gp = new GlobalPanel();        tabbedPane = new JTabbedPane();        tabbedPane.setFont(new Font("serif", Font.PLAIN, 12));        tabbedPane.addTab("", new J2DIcon(), gp);        tabbedPane.addChangeListener(gp);        group = new DemoGroup[demos.length];        for (int i = 0; i < demos.length; i++) {            // progressLabel.setText("Loading demos." + demos[i][0]);            group[i] = new DemoGroup(demos[i][0]);            tabbedPane.addTab(demos0[i][0], null);            progressBar.setValue(progressBar.getValue() + 1);        } while (textLocation != 28) {}        timer.stop();        timer = null;        add(tabbedPane, BorderLayout.CENTER);    }    public String getString(String key) {        String value = "nada";        if (bundle == null) {            bundle = ResourceBundle.getBundle("welcome");        }        try {            value = bundle.getString(key);        } catch (MissingResourceException e) {            System.out.println(                    "java.util.MissingResourceException: Couldn't find value for: " +                    key);        }        return value;    }    public Action createTextLoadAction() {        return new AbstractAction("text load action") {            public void actionPerformed(ActionEvent e) {                if (textLocation < text.length()) {                    welcome.setText(welcome.getText() +                                    text.substring(textLocation,                            textLocation + 1));                    progressBar.setValue(progressBar.getValue() + 1);                    textLocation++;                    System.out.println("" + textLocation);                }            }        };    }    public void start() {        pArray.start();        pArrayLY.start();        pArrayRX.start();        pArrayRY.start();        if (tabbedPane.getSelectedIndex() == 0) {            intro.start();        } else {            group[tabbedPane.getSelectedIndex() - 1].setup(false);            if (memorymonitor.surf.thread == null) {                memorymonitor.surf.start();            }            if (performancemonitor.surf.thread == null) {                performancemonitor.surf.start();            }        }    }    public void stop() {        if (tabbedPane.getSelectedIndex() == 0) {            intro.stop();        } else {            memorymonitor.surf.stop();            //  performancemonitor.surf.stop();            int i = tabbedPane.getSelectedIndex() - 1;            group[i].shutDown(group[i].getPanel());        }        datapool.closeConnection();        pArray.stop();        pArrayLY.stop();        pArrayRX.stop();        pArrayRY.stop();    }    static void addToGridBag(JPanel panel, Component comp,                             int x, int y, int w, int h, double weightx,                             double weighty) {        GridBagLayout gbl = (GridBagLayout) panel.getLayout();        GridBagConstraints c = new GridBagConstraints();        c.fill = GridBagConstraints.BOTH;        c.gridx = x;        c.gridy = y;        c.gridwidth = w;        c.gridheight = h;        c.weightx = weightx;        c.weighty = weighty;        panel.add(comp);        gbl.setConstraints(comp, c);    }    /**     * The Icon for the Intro tab.     */    static class J2DIcon implements Icon {        private static Color blue = new Color(94, 105, 176);        private static Color black = new Color(20, 20, 20);        private static Font font = new Font("serif", Font.BOLD, 12);        private FontRenderContext frc = new FontRenderContext(null, true, true);        private TextLayout tl = new TextLayout("主界面", font, frc);        public void paintIcon(Component c, Graphics g, int x, int y) {            Graphics2D g2 = (Graphics2D) g;            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,                                RenderingHints.VALUE_ANTIALIAS_ON);            g2.setFont(font);            if (tabbedPane.getSelectedIndex() == 0) {                g2.setColor(blue);            } else {                g2.setColor(black);            }            tl.draw(g2, x, y + 15);        }        public int getIconWidth() {            return 40;        }        public int getIconHeight() {            return 22;        }    }}

⌨️ 快捷键说明

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