Java java java SQL import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JMenuBar; import javax.swing.JMenu;

kitewormsSoftware and s/w Development

Nov 3, 2013 (3 years and 10 months ago)

99 views




进入二月天,我们的项目也已经进行了四个月了,这期间,我们完成了资料收集,以及
Java
语言
的学习,本阶段我们主要在
java
语言的基础上学习了
java
界面的制作以及
SQL
数据库的学习工作,

下面这段代码是我们自己编写的一个数字评价系统的初步界面的主程序部分。

import java.awt.EventQueue;


import javax.swing.JFrame;

import javax.swing.JMenuBar;

import javax.swing.JMenu;

import javax.sw
ing.JMenuItem;

import javax.swing.JRadioButtonMenuItem;

import javax.swing.JPopupMenu;

import java.awt.Component;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

import javax.swing.JSeparator;

import javax.swing.JCheckBoxMenuItem;

imp
ort java.awt.List;

import java.awt.BorderLayout;

import javax.swing.JCheckBox;

import javax.swing.JRadioButton;

import javax.swing.JTextField;

import javax.swing.JTextPane;

import javax.swing.JPanel;

import java.awt.Color;

import java.awt.Font;

import java
x.swing.SwingConstants;

import javax.swing.JPasswordField;

import javax.swing.JDesktopPane;

import javax.swing.JEditorPane;



public class MyFrame {



private JFrame frmIntelligentEvaluationSystem;


private JTextField txtsubject;


private JTextField textFi
eld;


private JTextField textField_1;


private JTextField textField_2;


private JTextField textField_3;



/**



* Launch the application.



*/


public static void main(String[] args) {





EventQueue.invokeLater(new Runnable() {




public void run() {





tr
y {






MyFrame window = new MyFrame();






window.getFrmIntelligentEvaluationSystem().setVisible(true);





} catch (Exception e) {






e.printStackTrace();





}




}



});


}



/**



* Create the application.



*/


public MyFrame() {



initialize();


}



/**



* Initialize the contents of the frame.



*/


private void initialize() {



setFrmIntelligentEvaluationSystem(new JFrame());



getFrmIntelligentEvaluationSystem().setTitle("Intelligent evaluation system");



getFrmIntelligentEvaluationSystem().s
etBounds(100, 100, 794, 487);



getFrmIntelligentEvaluationSystem().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);



getFrmIntelligentEvaluationSystem().getContentPane().setLayout(null);






JPanel panel = new JPanel();



panel.setBackground(new Color(30
, 144, 255));



panel.setForeground(new Color(30, 144, 255));



panel.setBounds(0, 0, 778, 449);



getFrmIntelligentEvaluationSystem().getContentPane().add(panel);



panel.setLayout(null);






txtsubject = new JTextField();



txtsubject.setHorizontalAlign
ment(SwingConstants.CENTER);



txtsubject.setBackground(new Color(255, 255, 255));



txtsubject.setFont(new Font("
宋体
", Font.BOLD, 12));



txtsubject.setText("
\
u9009
\
u62E9
\
u5B66
\
u79D1");



txtsubject.setBounds(10, 69, 94, 30);



panel.add(txtsubject);



txt
subject.setColumns(10);








JRadioButton rdbtnNewRadioButton = new
JRadioButton("
\
u7406
\
u8BBA
\
u7269
\
u7406
\
u5B66");



rdbtnNewRadioButton.setBackground(new Color(30, 144, 255));



rdbtnNewRadioButton.setBounds(10, 180, 121, 23);



panel.add(rdbtnNewRadioBu
tton);






JRadioButton radioButton = new JRadioButton("
\
u9AD8
\
u7B49
\
u6570
\
u5B66");



radioButton.setBackground(new Color(30, 144, 255));



radioButton.setBounds(10, 130, 121, 23);



panel.add(radioButton);






JRadioButton radioButton_1 = new JRadioButt
on("
\
u6A21
\
u62DF
\
u7535
\
u8DEF");



radioButton_1.setBackground(new Color(30, 144, 255));



radioButton_1.setBounds(10, 155, 121, 23);



panel.add(radioButton_1);






JRadioButton radioButton_2 = new JRadioButton("
\
u5FAE
\
u673A
\
u539F
\
u7406");



radioButton_2
.setBackground(new Color(30, 144, 255));



radioButton_2.setBounds(10, 205, 121, 23);



panel.add(radioButton_2);






JRadioButton radioButton_3 = new JRadioButton("
\
u4F53
\
u80B2");



radioButton_3.setBackground(new Color(30, 144, 255));



radioButton_3.se
tBounds(10, 230, 121, 23);



panel.add(radioButton_3);






textField = new JTextField();



textField.setHorizontalAlignment(SwingConstants.CENTER);



textField.setFont(new Font("
宋体
", Font.BOLD, 12));



textField.setBackground(new Color(255, 255, 255));



textField.setText("
\
u5F00
\
u59CB
\
u8BC4
\
u4EF7");



textField.setBounds(439, 69, 76, 30);



panel.add(textField);



textField.setColumns(10);






textField_1 = new JTextField();



textField_1.setBackground(new Color(30, 144, 255));



textField_1.setText("1.
\
u8001
\
u5E08
\
u8BB2
\
u8BFE
\
u7684
\
u65B9
\
u6CD5");



textField_1.setBounds(317, 142, 127, 22);



panel.add(textField_1);



textField_1.setColumns(10);






JCheckBox checkBox = new JCheckBox("
\
u4F18");





checkBox.setBackground(new Color(30, 144, 255));



checkBo
x.setBounds(478, 141, 37, 23);



panel.add(checkBox);






JCheckBox checkBox_1 = new JCheckBox("
\
u4E00
\
u822C");



checkBox_1.setBackground(new Color(30, 144, 255));



checkBox_1.setBounds(622, 141, 49, 23);



panel.add(checkBox_1);






JCheckBox checkBox
_2 = new JCheckBox("
\
u826F");



checkBox_2.setBackground(new Color(30, 144, 255));



checkBox_2.setBounds(548, 141, 37, 23);



panel.add(checkBox_2);






textField_2 = new JTextField();



textField_2.setToolTipText("hkyu");



textField_2.setFont(new Font(
"
楷体
", Font.BOLD, 18));



textField_2.setHorizontalAlignment(SwingConstants.CENTER);



textField_2.setText("
\
u667A
\
u80FD
\
u8BC4
\
u4EF7
\
u7CFB
\
u7EDF");



textField_2.setBounds(237, 22, 236, 30);



panel.add(textField_2);



textField_2.setColumns(10);






JEdit
orPane dtrpnHjhv = new JEditorPane();



dtrpnHjhv.setBounds(109, 349, 447, 90);



panel.add(dtrpnHjhv);






textField_3 = new JTextField();



textField_3.setBackground(new Color(30, 144, 255));



textField_3.setFont(new Font("
宋体
", Font.BOLD, 14));



textF
ield_3.setHorizontalAlignment(SwingConstants.CENTER);



textField_3.setText("
\
u5B66
\
u751F
\
u5EFA
\
u8BAE
\
uFF1A");



textField_3.setBounds(10, 348, 89, 30);



panel.add(textField_3);



textField_3.setColumns(10);


}



private static void addPopup(Component com
ponent, final JPopupMenu popup) {



component.addMouseListener(new MouseAdapter() {




public void mousePressed(MouseEvent e) {





if (e.isPopupTrigger()) {






showMenu(e);





}




}






public void mouseReleased(MouseEvent e) {





if (e.isPopupTrigger
()) {






showMenu(e);





}




}




private void showMenu(MouseEvent e) {





popup.show(e.getComponent(), e.getX(), e.getY());




}



});


}



public void setFrmIntelligentEvaluationSystem(




JFrame frmIntelligentEvaluationSystem) {



this.frmIntellige
ntEvaluationSystem = frmIntelligentEvaluationSystem;


}



public JFrame getFrmIntelligentEvaluationSystem() {



return frmIntelligentEvaluationSystem;


}

}