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

📄 clusterapplet.java

📁 it is Also Kmeans Algorithm in java.
💻 JAVA
字号:
/* * ClusterApplet.java * * Created on 14 February 2008, 14:24 */package clusteranalysis;import javax.swing.JOptionPane;/** * * @author  hako */public class ClusterApplet extends javax.swing.JApplet {        /** Initializes the applet ClusterApplet */    public void init() {        try {            java.awt.EventQueue.invokeAndWait(new Runnable() {                public void run() {                    initComponents();                }            });        } catch (Exception ex) {            ex.printStackTrace();        }    }        /** This method is called from within the init() method to     * initialize the form.     * WARNING: Do NOT modify this code. The content of this method is     * always regenerated by the Form Editor.     */    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents    private void initComponents() {        appletPanel1 = new clusteranalysis.AppletPanel();        jButton1 = new javax.swing.JButton();        jComboBox1 = new javax.swing.JComboBox();        jButton2 = new javax.swing.JButton();        javax.swing.GroupLayout appletPanel1Layout = new javax.swing.GroupLayout(appletPanel1);        appletPanel1.setLayout(appletPanel1Layout);        appletPanel1Layout.setHorizontalGroup(            appletPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGap(0, 526, Short.MAX_VALUE)        );        appletPanel1Layout.setVerticalGroup(            appletPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGap(0, 368, Short.MAX_VALUE)        );        jButton1.setText("Clean");        jButton1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton1ActionPerformed(evt);            }        });        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2 Groups ", "3 Groups ", "4 Groups ", "5 Groups " }));        jComboBox1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jComboBox1ActionPerformed(evt);            }        });        jComboBox1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {            public void propertyChange(java.beans.PropertyChangeEvent evt) {                jComboBox1PropertyChange(evt);            }        });        jButton2.setText("About");        jButton2.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton2ActionPerformed(evt);            }        });        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());        getContentPane().setLayout(layout);        layout.setHorizontalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addComponent(appletPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)            .addGroup(layout.createSequentialGroup()                .addContainerGap()                .addComponent(jButton1)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 192, Short.MAX_VALUE)                .addComponent(jButton2))        );        layout.setVerticalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(layout.createSequentialGroup()                .addGap(12, 12, 12)                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jButton1)                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(jButton2))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)                .addComponent(appletPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))        );    }// </editor-fold>//GEN-END:initComponents    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed        this.appletPanel1.points.clear();        this.appletPanel1.repaint();    }//GEN-LAST:event_jButton1ActionPerformed    private void jComboBox1PropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_jComboBox1PropertyChange            }//GEN-LAST:event_jComboBox1PropertyChange    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed        int groups=this.jComboBox1.getSelectedIndex()+2;        this.appletPanel1.groupCount=groups;        this.appletPanel1.repaint();    }//GEN-LAST:event_jComboBox1ActionPerformed    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed        JOptionPane.showMessageDialog(null, "by mhSatman, mhsatman@yahoo.com");    }//GEN-LAST:event_jButton2ActionPerformed            // Variables declaration - do not modify//GEN-BEGIN:variables    private clusteranalysis.AppletPanel appletPanel1;    private javax.swing.JButton jButton1;    private javax.swing.JButton jButton2;    private javax.swing.JComboBox jComboBox1;    // End of variables declaration//GEN-END:variables    }

⌨️ 快捷键说明

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