星期二—GUI的初步了解

1、GUI:GUI(Graphical User Interface)即图形用户界面,它能够使应用程序看上去更加友好;

2、AWT(Abstract Windows Toolkit)是Java语言中最原始的GUI工具包,相关API位于java.awt包中。AWT是一个非常有限的GUI工具包,比如树、表格等都不支持。

3、在Swing编程中,有一些经常要使用到的组件,其中包括:JFrame(窗体,框架) JPanel(面板,容器) JButton(按钮) JLabel(标签) JTextField(文本框) JTextArea(文本域)

用GUI练习计算器:

package com.chinasoft.gui.PM;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.LayoutStyle.ComponentPlacement;

import java.awt.Font;

import javax.swing.JTextField;
import java.awt.Color;

public class Gui extends JFrame {                       //建立一个框体

	private JPanel contentPane;
	private JTextField textField;
	private JButton[] allButtons;
	private JButton clearButton;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		String b = "123456";	                                         //设置一个登录界面,密码为123456
		String a = JOptionPane.showInputDialog("请输出您的密码:");
		if(a.equals(b)){
	//	JOptionPane.showMessageDialog(null, "alert", "alert", JOptionPane.ERROR_MESSAGE);
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Gui frame = new Gui();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
		}else
		{JOptionPane.showMessageDialog(null, "密码输入错误", "alert", JOptionPane.ERROR_MESSAGE);}
	}
	/**
	 * Create the frame.
	 */
	public Gui() {
		setBackground(Color.BLUE);
		Suanfa f = new Suanfa();
		f.suanfa1();
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setTitle("计算器");
		setBounds(100, 100, 350, 500);
		contentPane = new JPanel();
		contentPane.setBackground(Color.red);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		JButton btnNewButton_3 = new JButton("=");
		btnNewButton_3.setBackground(Color.CYAN);
		btnNewButton_3.setFont(new Font("宋体", Font.PLAIN, 30));            //基本上所有的运算过程都在“=”中实现
		btnNewButton_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			String str = textField.getText();
			byte []b1 = new byte[str.length()];
			b1 = str.getBytes();
		    int endIndex = str.length();

			   for(int i =0;i <str.length();i++ ){	             //用for循环来遍历数组长度中的特殊符号
				   if(b1[i] == ‘+‘){	                   //用if条件来判断符号,同下面的“-”,“/”,“*”
					//获取第一个数字
					int index11 = str.indexOf("+");
					String str1 = str.substring(0, index11);
					int a = Integer.parseInt(str1);
					//获取第二个数字
					String str2 = str.substring(index11+1, endIndex);
					int b = Integer.parseInt(str2);
					//加法计算
					int sum = a + b;	

					//输出结果
					textField.setText(Integer.toString(sum));
				   }else
				   if(b1[i] == ‘-‘){
					int index33 = str.indexOf("-");
					String str3 = str.substring(0, index33);
					int c = Integer.parseInt(str3);

					String str4 = str.substring(index33+1, endIndex);
					int d = Integer.parseInt(str4);

					int div = c - d;	

					textField.setText(Integer.toString(div));

				   }else
				   if(b1[i] == ‘*‘){
					int index44 = str.indexOf("*");
					String str11 = str.substring(0, index44);
					int c1 = Integer.parseInt(str11);
					String str12 = str.substring(index44+1, endIndex);
					int d1 = Integer.parseInt(str12);
					int cheng = c1 * d1;
					textField.setText(Integer.toString(cheng));

				   }else
					if(b1[i] == ‘/‘){
					int index5 = str.indexOf("/");
					String str13 = str.substring(0, index5);
					int c2 = Integer.parseInt(str13);
					String str14 = str.substring(index5+1, endIndex);
					int d2 = Integer.parseInt(str14);
					int chu = c2 / d2;
					textField.setText(Integer.toString(chu));
				   }
				}
			}
		});
		JButton btnNewButton = new JButton("0");   //把btnNewButton按钮在文本框中输出  同下其他按钮
		btnNewButton.setBackground(Color.CYAN);
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				textField.setText(textField.getText() + "0");
			}
		});
		JButton btnNewButton_1 = new JButton("+");
		btnNewButton_1.setBackground(Color.CYAN);
		btnNewButton_1.setFont(new Font("宋体", Font.PLAIN, 30));
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			textField.setText(textField.getText() + "+");
			}
		});
		JButton button = new JButton(".");
		button.setBackground(Color.CYAN);
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {

			textField.setText(textField.getText() + ".");
			}
		});
		button.setFont(new Font("宋体", Font.PLAIN, 25));

		JButton button_1 = new JButton("-");
		button_1.setBackground(Color.CYAN);
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				textField.setText(textField.getText() + "-");
			}
		});
		button_1.setFont(new Font("宋体", Font.PLAIN, 25));
		JButton button_2 = new JButton("3");
		button_2.setBackground(Color.CYAN);
		button_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {

		  textField.setText(textField.getText() + "3");
			}
		});
		button_2.setFont(new Font("宋体", Font.PLAIN, 25));

		JButton button_3 = new JButton("2");
		button_3.setBackground(Color.CYAN);
		button_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {

		 textField.setText(textField.getText() + "2");
			}
		});
		button_3.setFont(new Font("宋体", Font.PLAIN, 25));

		JButton button_4 = new JButton("1");
		button_4.setBackground(Color.CYAN);
		button_4.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
		 textField.setText(textField.getText() + "1");
			}
		});
		button_4.setFont(new Font("宋体", Font.PLAIN, 25));

		JButton button_5 = new JButton("4");
		button_5.setBackground(Color.CYAN);
		button_5.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
		textField.setText(textField.getText() + "4");
			}
		});
		button_5.setFont(new Font("宋体", Font.PLAIN, 25));

		JButton button_6 = new JButton("5");
		button_6.setBackground(Color.CYAN);
		button_6.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
		 textField.setText(textField.getText() + "5");
			}
		});
		button_6.setFont(new Font("宋体", Font.PLAIN, 25));

		JButton button_7 = new JButton("6");
		button_7.setBackground(Color.CYAN);
		button_7.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			textField.setText(textField.getText() + "6");
			}
		});
		button_7.setFont(new Font("宋体", Font.PLAIN, 25));

		JButton button_8 = new JButton("*");
		button_8.setBackground(Color.CYAN);
		button_8.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				textField.setText(textField.getText() + "*");
			}
		});
		button_8.setFont(new Font("宋体", Font.PLAIN, 25));

		JButton button_9 = new JButton("1/x");
		button_9.setBackground(Color.CYAN);
		button_9.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		button_9.setFont(new Font("宋体", Font.PLAIN, 7));
		JButton button_10 = new JButton("7");
		button_10.setBackground(Color.CYAN);
		button_10.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			textField.setText(textField.getText() + "7");
			}
		});
		button_10.setFont(new Font("宋体", Font.PLAIN, 25));

		JButton button_11 = new JButton("8");
		button_11.setBackground(Color.CYAN);
		button_11.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			textField.setText(textField.getText() + "8");
			}
		});
		button_11.setFont(new Font("宋体", Font.PLAIN, 25));

		JButton button_12 = new JButton("9");
		button_12.setBackground(Color.CYAN);
		button_12.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			textField.setText(textField.getText() + "9");
			}
		});
		button_12.setFont(new Font("宋体", Font.PLAIN, 25));

		JButton button_14 = new JButton("%");
		button_14.setBackground(Color.CYAN);
		button_14.setFont(new Font("宋体", Font.PLAIN, 25));

		JButton button_13 = new JButton("/");
		button_13.setBackground(Color.CYAN);
		button_13.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			textField.setText(textField.getText() + "/");
			}
		});
		button_13.setFont(new Font("宋体", Font.PLAIN, 25));

		JButton button_15 = new JButton("\u2190");          //清除按钮
		button_15.setBackground(Color.CYAN);
		button_15.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String str = textField.getText();
				int a = str.length();
				if(a == 0){
		JOptionPane.showMessageDialog(null, "没了,别逗了", "alert", JOptionPane.ERROR_MESSAGE);
				}else{
			   String str1 = str.substring(0, a-1);
			 //  String str2 = str.replace(str, str1);
				textField.setText(str1);
				}
			}
		});
		button_15.setFont(new Font("宋体", Font.PLAIN, 12));

		JButton btnCe = new JButton("CE");
		btnCe.setBackground(Color.CYAN);
		btnCe.setFont(new Font("宋体", Font.PLAIN, 12));

		JButton btnC = new JButton("C");    //把文本框中内容清空
		btnC.setBackground(Color.CYAN);
		btnC.addActionListener(new ActionListener() {
	   public void actionPerformed(ActionEvent e) {
		   textField.setText("");
			}
		});
		btnC.setFont(new Font("宋体", Font.PLAIN, 25));

		JButton button_18 = new JButton("\u00B1");
		button_18.setBackground(Color.CYAN);
		button_18.setFont(new Font("宋体", Font.PLAIN, 12));

		JButton button_19 = new JButton("\u221A");
		button_19.setBackground(Color.CYAN);
		button_19.setFont(new Font("宋体", Font.PLAIN, 12));

		JButton btnMc = new JButton("MC");
		btnMc.setBackground(Color.CYAN);
		btnMc.setFont(new Font("宋体", Font.PLAIN, 12));

		JButton btnMr = new JButton("MR");
		btnMr.setBackground(Color.CYAN);
		btnMr.setFont(new Font("宋体", Font.PLAIN, 12));

		JButton btnM = new JButton("MS");
		btnM.setBackground(Color.CYAN);
		btnM.setFont(new Font("宋体", Font.PLAIN, 12));

		JButton btnM_1 = new JButton("M+");
		btnM_1.setBackground(Color.CYAN);
		btnM_1.setFont(new Font("宋体", Font.PLAIN, 12));

		JButton btnM_2 = new JButton("M-");
		btnM_2.setBackground(Color.CYAN);
		btnM_2.setFont(new Font("宋体", Font.PLAIN, 12));

		textField = new JTextField();
		textField.setBackground(Color.BLUE);
		textField.setForeground(Color.MAGENTA);
		textField.setFont(new Font("宋体", Font.PLAIN, 30));
		textField.setColumns(10);

		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane.setHorizontalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addGap(26)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addComponent(textField, GroupLayout.PREFERRED_SIZE, 259, GroupLayout.PREFERRED_SIZE)
						.addGroup(gl_contentPane.createSequentialGroup()
							.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
								.addGroup(gl_contentPane.createSequentialGroup()
									.addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, 104, GroupLayout.PREFERRED_SIZE)
									.addGap(13)
									.addComponent(button, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
									.addPreferredGap(ComponentPlacement.RELATED)
									.addComponent(btnNewButton_1))
								.addGroup(gl_contentPane.createSequentialGroup()
									.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
										.addComponent(button_4, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
										.addComponent(button_5, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
										.addComponent(button_10, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
										.addComponent(button_15, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
										.addComponent(btnMc, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE))
									.addPreferredGap(ComponentPlacement.UNRELATED)
									.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
										.addComponent(btnMr, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
										.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
											.addGroup(gl_contentPane.createSequentialGroup()
												.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
													.addComponent(button_3, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
													.addComponent(button_6, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE))
												.addPreferredGap(ComponentPlacement.UNRELATED)
												.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
													.addGroup(gl_contentPane.createSequentialGroup()
														.addComponent(button_2, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
														.addPreferredGap(ComponentPlacement.RELATED)
														.addComponent(button_1, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE))
													.addGroup(gl_contentPane.createSequentialGroup()
														.addComponent(button_7, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
														.addPreferredGap(ComponentPlacement.RELATED)
														.addComponent(button_8, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE))))
											.addGroup(gl_contentPane.createSequentialGroup()
												.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
													.addComponent(button_11, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
													.addComponent(btnCe, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE))
												.addPreferredGap(ComponentPlacement.UNRELATED)
												.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
													.addGroup(gl_contentPane.createSequentialGroup()
														.addComponent(btnC, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
														.addPreferredGap(ComponentPlacement.RELATED)
														.addComponent(button_18, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE))
													.addGroup(gl_contentPane.createSequentialGroup()
														.addComponent(button_12, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
														.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
														.addComponent(button_13, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE))
													.addGroup(gl_contentPane.createSequentialGroup()
														.addComponent(btnM, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
														.addPreferredGap(ComponentPlacement.RELATED)
														.addComponent(btnM_1, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE))))))))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
								.addComponent(btnNewButton_3, GroupLayout.PREFERRED_SIZE, 52, GroupLayout.PREFERRED_SIZE)
								.addComponent(button_9, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
								.addComponent(button_14, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
								.addComponent(button_19, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
								.addComponent(btnM_2, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE))))
					.addContainerGap(23, Short.MAX_VALUE))
		);
		gl_contentPane.setVerticalGroup(
			gl_contentPane.createParallelGroup(Alignment.TRAILING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addGap(23)
					.addComponent(textField, GroupLayout.PREFERRED_SIZE, 83, GroupLayout.PREFERRED_SIZE)
					.addGap(28)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addComponent(btnMc, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
						.addComponent(btnMr, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
						.addComponent(btnM, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
						.addComponent(btnM_1, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
						.addComponent(btnM_2, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addComponent(button_15, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
						.addComponent(btnCe, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
						.addComponent(btnC, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
						.addComponent(button_18, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
						.addComponent(button_19, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addComponent(button_10, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
						.addComponent(button_11, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
						.addComponent(button_14, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
						.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
							.addComponent(button_13, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
							.addComponent(button_12, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)))
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addComponent(button_5, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
						.addComponent(button_6, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
						.addComponent(button_7, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
						.addComponent(button_8, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
						.addComponent(button_9, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_contentPane.createSequentialGroup()
							.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
								.addComponent(button_1, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
								.addComponent(button_2, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
								.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
									.addComponent(button_3, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
									.addComponent(button_4, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)))
							.addGap(8)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
								.addComponent(btnNewButton_1, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
								.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
									.addComponent(button, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
									.addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, 41, GroupLayout.PREFERRED_SIZE))))
						.addComponent(btnNewButton_3, GroupLayout.PREFERRED_SIZE, 94, GroupLayout.PREFERRED_SIZE))
					.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
		);
		contentPane.setLayout(gl_contentPane);
	}

	private void clearButton() {
		// TODO Auto-generated method stub

	}
}

 

 

时间: 2024-10-14 19:38:40

星期二—GUI的初步了解的相关文章

《Java程序设计》第14周实验作业:GUI编程初步

[目的] 1. 掌握图形化WindowBuilder的使用方式. 2. 理解Java中事件机制. [目标] 1. 掌握Eclipse中安装WindowBuilder的方法. 2. 了解Java中事件机制. 3. 了解GUI中重用控件.  4. 完成一个GUI作业,作业要求如下. (1)功能:有一个按钮(JButton)和一个标签(JLabel),当点击 按钮后,能够显示下一张图片.点击图片下载,获得图片样本. import java.awt.EventQueue; import java.awt

第14周实验作业:GUI编程初步

import java.awt.EventQueue; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; import javax.swing.JButton; import javax.swing.JLabel; import java.aw

GUI初步学习以及自身感受

在初步接触到GUI的时候, 终于接触到了一个可以看见的东西了,心里面还是有比较激动的, 也在做作业的时候有更多的乐趣,更愿意自发的去完成作业, 虽然里面穿插着之前面向对象的是知识, 这个时候也愿意的去思考, 去研究, 和小组的同学之间的讨论也变得多了, 组员之间 的一些交流 要都围绕着作业和当天不懂知道 来惊醒讨论. 虽然刚刚接触的GUI,讲起来也只是初步的让我们来进行排版,  里面还是有很多知识 需要我们去巩固和实用, 里面还有很多事件的东西 需要我们去学习.  目前的感受  在GUI 这章的

GUI初步

import java.awt.*; public class FrameDemo { public static void main(String[] args) { // TODO Auto-generated method stub Frame f=new Frame(); f.setVisible(true); f.setLocation(100,100); f.setSize(500, 400); f.setLayout(new FlowLayout()); Button but=ne

scala界面GUI编程实战初步了解

示例代码: import scala.swing._ //SimpleSwingApplication继承自SwingApplication类(此类中有main方法,因此可以运行显示界面) object Hello_GUI extends SimpleSwingApplication { def top = new MainFrame{ //顶级容器 title = "Hello GUI" contents = new Button{ text = "Scala =>

GUI初步和frame&panel

java的话这个GUI其实不是什么重点,但我们也要学习,重点是学习这种图形编程的思路. java里面对于图形的一些类都封装在了AWT和它的一些子包里.AWT(抽象窗口开发包)            当然AWT是比较旧的开发包,新的叫swing, 所有可以显示出来的元素都叫component,然后下面那些什么Button,lable都是它的子类.,这里有个比较特殊的子类,container,在图形里面,container是用来容纳其他component的元素.然后这个container又分两种,一

python GUI初步

打印目录内容,包括每个文件的大小和修改时间为了简单  下面的版本 只打印条目名称  而不打印它们的完整路径 TypeError:print_dir_info()missing 1 required positional argument重命名 移动 复制   删除文件rename moved copy  delett fileshutil模块 包括操作文件操作 shutil.move重命名一个函数函数shutil.move重命名一个文件 将一个文件移动到另一个目录shutil.move("old

Unity3D游戏开发初探—2.初步了解3D模型基础

一.什么是3D模型? 1.1 3D模型概述 简而言之,3D模型就是三维的.立体的模型,D是英文Dimensions的缩写. 3D模型也可以说是用3Ds MAX建造的立体模型,包括各种建筑.人物.植被.机械等等,比如一个大楼的3D模型图.3D模型也包括玩具和电脑模型领域. 互联网的形态一直以来都是2D模式的,但是随着3D技术的不断进步,在未来的时间里,将会有越来越多的互联网应用以3D的方式呈现给用户,包括网络视讯.电子阅读.网络游戏.虚拟社区.电子商务.远程教育等等.甚至对于旅游业,3D互联网也能

结对作业1----基于GUI的四则运算生成器

代码地址:https://git.oschina.net/cococok2/groupwork1/tree/master 学号:201421123030 201421123005 需求分析: 能按照用户的要求自动生成四则混合运算的程序,并做成GUI界面. 此次开发的新功能:GUI图形界面,记录用户做题的对错数目以及总数.(此次因时间原因还没有做出计时功能,后续会一直更新并改进) 程序设计思维导图: GUI界面如下:(时间原因没有优化界面,仅仅实现了基本功能) 开始界面 点击开始后,出现主界面(此