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

📄 mainframe.java

📁 电力系统紧急控制仿真平台 包括DSA控制平台、紧急控制平台、紧急解列控制平台三个模块。
💻 JAVA
字号:
/* * MainFrame.java * @author Dong Shufeng * Created on 2008-11-05 */package com.ht.dsa;import javax.help.CSH;import javax.help.HelpBroker;import javax.help.HelpSet;import javax.swing.*;import java.io.File;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;/** * * @author  IBM */public class MainFrame extends javax.swing.JFrame {    ActionListener helpAction;    /** Creates new form MainFrame */    public MainFrame() {        String contentPath = this.getClass().getResource("/help").getFile();        File dir = new File(contentPath + File.separator + "help.hs");        HelpSet hs;        ClassLoader cl = this.getClass().getClassLoader();        try {            hs = new HelpSet(cl, dir.toURI().toURL());            HelpBroker hb = hs.createHelpBroker();            helpAction = new CSH.DisplayHelpFromFocus(hb);        }catch(Exception ex)  {            ex.printStackTrace();        }        initComponents();        help.addActionListener(helpAction);    }    /** This method is called from within the constructor to     * initialize the form.     * WARNING: Do NOT modify this code. The content of this method is     * always regenerated by the Form Editor.     */    @SuppressWarnings("unchecked")    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents    private void initComponents() {        jButton3 = new javax.swing.JButton();        dsa = new javax.swing.JButton();        urgent = new javax.swing.JButton();        separate = new javax.swing.JButton();        help = new javax.swing.JButton();        close = new javax.swing.JButton();        jButton3.setText("jButton3");        jButton3.setName("jButton3"); // NOI18N        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);        setTitle("电力系统紧急控制仿真平台");        setResizable(false);        dsa.setFont(new java.awt.Font("华文隶书", 0, 24));        dsa.setText("DSA控制平台");        dsa.setName("dsa"); // NOI18N        dsa.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                dsaActionPerformed(evt);            }        });        urgent.setFont(new java.awt.Font("华文隶书", 0, 24));        urgent.setText("紧急控制平台");        urgent.setName("urgent"); // NOI18N        urgent.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                urgentActionPerformed(evt);            }        });        separate.setFont(new java.awt.Font("华文隶书", 0, 24));        separate.setText("紧急解列控制平台");        separate.setName("separate"); // NOI18N        separate.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                separateActionPerformed(evt);            }        });        help.setFont(new java.awt.Font("华文隶书", 0, 24));        help.setText("帮助");        help.setName("help"); // NOI18N        help.addHierarchyBoundsListener(new java.awt.event.HierarchyBoundsListener() {            public void ancestorMoved(java.awt.event.HierarchyEvent evt) {            }            public void ancestorResized(java.awt.event.HierarchyEvent evt) {                helpAncestorResized(evt);            }        });        close.setFont(new java.awt.Font("宋体", 0, 18));        close.setText("关闭");        close.setName("close"); // NOI18N        close.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                closeActionPerformed(evt);            }        });        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());        getContentPane().setLayout(layout);        layout.setHorizontalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(layout.createSequentialGroup()                .addGap(107, 107, 107)                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)                    .addGroup(layout.createSequentialGroup()                        .addComponent(dsa, javax.swing.GroupLayout.PREFERRED_SIZE, 233, javax.swing.GroupLayout.PREFERRED_SIZE)                        .addGap(80, 80, 80))                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()                        .addComponent(separate, javax.swing.GroupLayout.PREFERRED_SIZE, 233, javax.swing.GroupLayout.PREFERRED_SIZE)                        .addGap(80, 80, 80)))                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)                    .addComponent(help, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                    .addComponent(urgent, javax.swing.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE))                .addGap(104, 104, 104))            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()                .addContainerGap(587, Short.MAX_VALUE)                .addComponent(close, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)                .addGap(135, 135, 135))        );        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {dsa, help, separate, urgent});        layout.setVerticalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(layout.createSequentialGroup()                .addGap(110, 110, 110)                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addComponent(dsa, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(urgent, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))                .addGap(45, 45, 45)                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(separate, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(help, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 90, Short.MAX_VALUE)                .addComponent(close, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)                .addGap(35, 35, 35))        );        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {dsa, help, separate, urgent});        pack();    }// </editor-fold>//GEN-END:initComponents    private void closeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeActionPerformed        System.exit(0);    }//GEN-LAST:event_closeActionPerformed    private void dsaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dsaActionPerformed        DSAFrame.main(null);    }//GEN-LAST:event_dsaActionPerformed    private void urgentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_urgentActionPerformed        UrgenceFrame.main(null);    }//GEN-LAST:event_urgentActionPerformed    private void separateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_separateActionPerformed        UndoFrame.main(null);    }//GEN-LAST:event_separateActionPerformedprivate void helpAncestorResized(java.awt.event.HierarchyEvent evt) {//GEN-FIRST:event_helpAncestorResized// TODO add your handling code here:}//GEN-LAST:event_helpAncestorResized    /**     * @param args the command line arguments     */    public static void main(String args[]) throws IllegalAccessException, UnsupportedLookAndFeelException, InstantiationException, ClassNotFoundException {        UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");        java.awt.EventQueue.invokeLater(new Runnable() {            public void run() {                new MainFrame().setVisible(true);            }        });    }    // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JButton close;    private javax.swing.JButton dsa;    private javax.swing.JButton help;    private javax.swing.JButton jButton3;    private javax.swing.JButton separate;    private javax.swing.JButton urgent;    // End of variables declaration//GEN-END:variables    class HelpAction extends AbstractAction {        public void actionPerformed(ActionEvent e) {            String contentPath = this.getClass().getResource("/help").getFile();            File dir = new File(contentPath + File.separator + "help.hs");            HelpSet hs;            ClassLoader cl = this.getClass().getClassLoader();            try {                hs = new HelpSet(cl, dir.toURI().toURL());                HelpBroker hb = hs.createHelpBroker();                new CSH.DisplayHelpFromFocus(hb);            }catch(Exception ex)  {                ex.printStackTrace();            }        }    }}

⌨️ 快捷键说明

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