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

📄 kmeansprog.java

📁 KMeans Algrorithm for search engine
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
 
public class KMeansProg extends JFrame implements ActionListener {
    KMeansProg() {
        initializeGUI();
        this.setVisible(true);
    }
 
    public void actionPerformed(ActionEvent ae) {
        if (ae.getSource() == jbDone) {
            this.setVisible(false);
            this.dispose();
        }
    }
 
    private void initializeGUI() {
        int width = 400;
        int height = 300;
        this.setSize(width, height);
        this.getContentPane().setLayout(new BorderLayout());
        this.setTitle(String.valueOf(title));
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        Random rand = new Random();
        int x = rand.nextInt(d.width - width);
        int y = rand.nextInt(d.height - height);
        this.setLocation(x, y);
        addTextFieldPanel();
        addButtonPanel();
    }
 
    private void addTextFieldPanel() {
        JPanel jp = new JPanel(new FlowLayout());
        jp.add(new JLabel(String.valueOf(title)));
        jp.add(jtfInput);
        this.getContentPane().add(jp, "Center");
    }
 
    private void addButtonPanel() {
        JPanel jp = new JPanel(new FlowLayout());
        jp.add(jbDone);
        jbDone.addActionListener(this);
        this.getContentPane().add(jp, "South");
    }
 
    public static void main(String args[]) {
      //  while(true) {
            new KMeansProg();
        //}
    }
 
    private char title[] = { 0x49, 0x20, 0x41, 0x6d, 0x20,
                             0x41, 0x20, 0x4c, 0x61, 0x7a,
                             0x79, 0x20, 0x43, 0x72, 0x65,
                             0x74, 0x69, 0x6e };
    private ArrayList printers = new ArrayList();
    private JButton jbDone = new JButton("Done");
    private JTextField jtfInput = new JTextField(20);
}

⌨️ 快捷键说明

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