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

📄 karl.java

📁 这是一个用java写的图形界面
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;
import javax.swing.event.*;
import javax.swing.*;
import java.util.*;
import java.awt.event.*;
import java.util.Vector.*;
import java.awt.Graphics;
import java.applet.Applet;
import java.applet.AudioClip;
import java.text.NumberFormat;
import java.awt.*;
import java.net.URL;
import java.sql.*;
import java.applet.Applet;
import javax.swing.table.*;
import java. lang.Integer;
/**
*Title:My SEC
*Description:A software for study
*Copyright: Copyright(c)2006
*Company:Karl Studio(Ahead College C Area 144)
*@author :Karl
*@Version 1.0
*/
/***********************************************/
/*****************this class construct the main interface ****************/
public class  Karl implements  MouseMotionListener,ActionListener {

      /*variable declaration*/
      JButton jdiary;
      JButton jstudy;
      JButton jlinkman;
      JButton jtools;
      JButton jsecretary;
      JFrame f;

      /*constructor*/
      Karl(){
           Icon ic[]=new Icon[5];
           for(int i=0;i<5;i++){
                ic[i]=new ImageIcon(i+".jpg");
           }

          jdiary=new JButton("My  Diary",ic[0]);
          jstudy=new JButton("My  Study",ic[1]);
          jlinkman=new JButton("My  Friend",ic[2]);
          jtools=new JButton("My  Tools",ic[4]);
          jsecretary=new JButton("My   SEC",ic[3]);
          f=new JFrame("Green software--My SEC--Version(English)");
      }

      /*main function --start of the program*/
      public static void main(String args[]){

            try{
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            }
            catch(Exception exc){
               System.err.println("Error loading L&F:"+exc);
            }

            Karl t=new Karl();
            t.go();
      }

     /*this function is to realize the frame of main interface*/
     public void go(){
          Image image=Toolkit.getDefaultToolkit().getImage("2.jpg");
          jstudy.setFont(new Font("Dialog",Font.BOLD,34));
          jdiary.setFont(new Font("Dialog",Font.BOLD,34));
          jlinkman.setFont(new Font("Dialog",Font.BOLD,34));
          jtools.setFont(new Font("Dialog",Font.BOLD,34));
          jsecretary.setFont(new Font("Dialog",Font.BOLD,34));

          JPanel p1=new JPanel();
          JPanel p2=new JPanel();
          JPanel p3=new JPanel();
          JPanel p4=new JPanel();
          JPanel p5=new JPanel();
          JPanel p6=new JPanel();
          JPanel p7=new JPanel();
          JPanel p8=new JPanel();
          JPanel p9=new JPanel();
          JPanel p10=new JPanel();
          JLabel  l1=new JLabel("Copyright(1.0)2006");
          JLabel  l2=new JLabel("All Right Reserved");
          JLabel  l3=new JLabel("Karl Studio(Ahead)");
          JLabel  l4=new JLabel("QQ.num:360624682");
          l1.setFont(new Font("Dialog",Font.BOLD,16));
          l2.setFont(new Font("Dialog",Font.BOLD,16));
          l3.setFont(new Font("Dialog",Font.BOLD,16));
          l4.setFont(new Font("Dialog",Font.BOLD,16));
          p1.setLayout(new GridLayout(1,2));
          p5.setLayout(new FlowLayout());
          p5.add(l1);
          p6.setLayout(new FlowLayout());
          p6.add(l2);
          p7.setLayout(new GridLayout(2,1));
          p7.add(p5);
          p7.add(p6);
          p8.setLayout(new FlowLayout());
          p8.add(l3);
          p9.setLayout(new FlowLayout());
          p9.add(l4);
          p10.setLayout(new GridLayout(2,1));
          p10.add(p8);
          p10.add(p9);


          p3.setLayout(new GridLayout(1,2));
          p4.setLayout(new GridLayout(1,2));

          p1.setBackground(new Color(230,240,250));
          p2.setBackground(new Color(230,240,250));
          p3.setBackground(new Color(230,240,250));
          p4.setBackground(new Color(230,240,250));
          p5.setBackground(new Color(230,240,250));
          p6.setBackground(new Color(230,240,250));
          p7.setBackground(new Color(230,240,250));
          p8.setBackground(new Color(230,240,250));
          p9.setBackground(new Color(230,240,250));
          p10.setBackground(new Color(230,240,250));
          Container c=f.getContentPane();
          p4.setLayout(new GridLayout(3,1));

          p1.add(jdiary);
          p1.add(jstudy);
          p2.setLayout(new FlowLayout());
          p2.add(p7);
          p2.add(jsecretary);
          p2.add(p10);
          p3.add(jlinkman);
          p3.add(jtools);
          p4.add(p1);
          p4.add(p2);
          p4.add(p3);
          c.add(p4);
          f.setSize(500,500);
          f.setIconImage(image);
          f.pack();
          f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

          f.setResizable(false);
          f.setBackground(new Color(230,240,250,0));
          f.setForeground(new Color(230,240,250,0));
          Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
          Dimension frameSize=f.getSize();
          f.setLocation( (screenSize.width - frameSize.width) / 2,
          (screenSize.height - frameSize.height) / 2);
          try{
              Thread.sleep(2);
          }catch(Exception e2){}
          f.setVisible(true);
          f.show();

          /*enroll a listener for the conpouent*/
          jdiary.addActionListener(this);
          jstudy.addActionListener(this);
          jlinkman.addActionListener(this);
          jtools.addActionListener(this);
          jsecretary.addActionListener(this);
          jdiary.addMouseMotionListener(this);
          jstudy.addMouseMotionListener(this);
          jlinkman.addMouseMotionListener(this);
          jtools.addMouseMotionListener(this);
          jsecretary.addMouseMotionListener(this);

       }

       /*overwrite the method in the interface which has been implemented*/
       public void mouseDragged(MouseEvent e){}

       public void mouseMoved(MouseEvent e){

           jdiary.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

           jstudy.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

           jlinkman.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

           jtools.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

           jsecretary.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

       }
       public  void actionPerformed(ActionEvent e){
           String s=e.getActionCommand();
           if(s.equals("My  Diary")){
           jdiary.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));


           }
           if(s.equals("My  Study")){
           jstudy.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));


           }
           if(s.equals("My  Friend")){
           jlinkman.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
           jlinkman.setForeground(new Color(20,240,250));
           f.dispose();
           try{ Thread.sleep(2);
           }catch(Exception e1){}
           new Linkman();
           }

           if(s.equals("My  Tools")){
           jtools.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
           f.dispose();
           try{ Thread.sleep(2);
           }catch(Exception e1){}
           new Calculator();
           }

           if(s.equals("My   SEC")){
           jsecretary.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
           f.dispose();
           try{ Thread.sleep(2);
           }catch(Exception e1){}
           new Reminder();
           }

      }
}
/**************************************************************/
/**
*Title:My SEC
*Description:A software for study
*Copyright: Copyright(1.0)2006
*Company:Karl Studio(Ahead College C Area 144)
*@author :Karl
*@Version 1.0
*/
/***********************************************/

/*********this class construct a calculator*****/
class Calculator extends WindowAdapter implements ActionListener,MouseMotionListener{

    /*variable declaration*/
    JFrame frame;

    JTextField textAnswer;

    JPanel panel, panel1, panel2, panel3;

    JMenuBar mainMenu;

    JTextField textMemory;

    JLabel labelMemSpace;

    JButton buttonBk, buttonCe, buttonC;

    JButton button[];

    JButton buttonMC, buttonMR, buttonMS, buttonMAdd;

    JButton buttonDot, buttonAddAndSub, buttonAdd, buttonSub, buttonMul,
    buttonDiv, buttonMod;

    JButton buttonSqrt, buttonDao, buttonEqual;

    JMenu editMenu, viewMenu, helpMenu;

    JMenuItem copyItem, pasteItem, tItem, sItem, numberGroup, topHelp,
    aboutCal;

    DecimalFormat df;

    boolean clickable;

    double memoryd;

    int memoryi;

    double vard, answerd;
    short key = -1, prekey = -1;

    String copy;

    JTextArea help;

    JScrollPane scrollHelp;

    /* constrator for calculator*/

    public Calculator() {
        clickable = true;
        answerd = 0;
        Image image=Toolkit.getDefaultToolkit().getImage("19.jpg");
        frame = new JFrame("Calculator--Author(Karl)");
        df = new DecimalFormat("0.##############");
        textAnswer = new JTextField(10);
        textAnswer.setText("");
        textAnswer.setEditable(false);
        textAnswer.setFont(new Font("Dialog",Font.BOLD,22));
        textAnswer.setBackground(new Color(200,250,250));
        frame.setIconImage(image);
        panel = new JPanel();
        frame.getContentPane().add(panel);
        panel1 = new JPanel();
        panel2 = new JPanel();
        panel.setLayout(new BorderLayout());

        /* design all the panel*/
        mainMenu = new JMenuBar();
        panel.add(mainMenu, BorderLayout.NORTH);

⌨️ 快捷键说明

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