今天搞这个字体程序搞了一下午,因为原本对JAVA的事件模型还不太了解,所以只能自己摸索着.
很容易看懂的程序,所以就不加注解了!!!
java 代码
- import javax.swing.*;
- import java.awt.*;
- import java.awt.Color;
- import java.awt.event.*;
-
- public class MyFrame {
-
-
- public static void main(String[] args) {
- SimpleFrame frame=new SimpleFrame();
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.show();
- }
-
-
- }
- class SimpleFrame extends JFrame{
- public SimpleFrame(){
- setTitle("还在写这个难看的程序");
- setSize(MYWIDTH,MYHEIGHT);
- MyPanel panel=new MyPanel();
- Container contentPane=getContentPane();
- contentPane.add(panel);
-
- }
- public static final int MYWIDTH=600;
- public static final int MYHEIGHT=200;
- }
- class MyPanel extends JPanel{
- public MyPanel(){
- JButton redButton=new JButton("RED");
- JButton greenButton=new JButton("GREEN");
- JButton blueButton=new JButton("BLUE");
- add(redButton);
- add(greenButton);
- add(blueButton);
- ColorAction redAction=new ColorAction(Color.RED);
- ColorAction greenAction=new ColorAction(Color.GREEN);
- ColorAction blueAction=new ColorAction(Color.BLUE);
- redButton.addActionListener(redAction);
- greenButton.addActionListener(greenAction);
- blueButton.addActionListener(blueAction);
- }
-
- public void paintComponent(Graphics g){
- super.paintComponents(g);
- Graphics2D g2=(Graphics2D)g;
- Font f=new Font("黑体",Font.BOLD,36);
- g2.setFont(f);
- g2.drawString("也能往这面板上加点东西啊!!",M_X,M_Y);
- }
-
- private class ColorAction implements ActionListener{
- public ColorAction(Color c){
-
- fontColor=c;
- }
- public void actionPerformed(ActionEvent event){
- setForeground(fontColor);
-
-
- }
- private Color fontColor;
-
- }
-
-
-
-
-
- public static final int M_X=75;
- public static final int M_Y=100;
- }
-
- 描述: 紅色
- 大小: 21.6 KB
- 描述: 綠色
- 大小: 19.4 KB
- 描述: 藍色
- 大小: 21.2 KB
分享到:
相关推荐
public class JVMine extends java.applet.Applet 简单实现!~ 网页表格组件 GWT Advanced Table GWT Advanced Table 是一个基于 GWT 框架的网页表格组件,可实现分页数据显示、数据排序和过滤等功能! Google Tag...
Java 3DMenu 界面源码,有人说用到游戏中不错,其实平时我信编写Java应用程序时候也能用到吧,不一定非要局限于游戏吧,RES、SRC资源都有,都在压缩包内。 Java zip压缩包查看程序源码 1个目标文件 摘要:Java源码...
Java 3DMenu 界面源码,有人说用到游戏中不错,其实平时我信编写Java应用程序时候也能用到吧,不一定非要局限于游戏吧,RES、SRC资源都有,都在压缩包内。 Java zip压缩包查看程序源码 1个目标文件 摘要:Java源码...
public class JVMine extends java.applet.Applet 简单实现!~ 网页表格组件 GWT Advanced Table GWT Advanced Table 是一个基于 GWT 框架的网页表格组件,可实现分页数据显示、数据排序和过滤等功能! Google Tag...
public class JVMine extends java.applet.Applet 简单实现!~ 网页表格组件 GWT Advanced Table GWT Advanced Table 是一个基于 GWT 框架的网页表格组件,可实现分页数据显示、数据排序和过滤等功能! Google Tag...
public class JVMine extends java.applet.Applet 简单实现!~ 网页表格组件 GWT Advanced Table GWT Advanced Table 是一个基于 GWT 框架的网页表格组件,可实现分页数据显示、数据排序和过滤等功能! Google Tag...
public class JVMine extends java.applet.Applet 简单实现!~ 网页表格组件 GWT Advanced Table GWT Advanced Table 是一个基于 GWT 框架的网页表格组件,可实现分页数据显示、数据排序和过滤等功能! Google Tag...
public class JVMine extends java.applet.Applet 简单实现!~ 网页表格组件 GWT Advanced Table GWT Advanced Table 是一个基于 GWT 框架的网页表格组件,可实现分页数据显示、数据排序和过滤等功能! Google Tag...
public class JVMine extends java.applet.Applet 简单实现!~ 网页表格组件 GWT Advanced Table GWT Advanced Table 是一个基于 GWT 框架的网页表格组件,可实现分页数据显示、数据排序和过滤等功能! Google Tag...
public class JVMine extends java.applet.Applet 简单实现!~ 网页表格组件 GWT Advanced Table GWT Advanced Table 是一个基于 GWT 框架的网页表格组件,可实现分页数据显示、数据排序和过滤等功能! Google Tag...
public class JVMine extends java.applet.Applet 简单实现!~ 网页表格组件 GWT Advanced Table GWT Advanced Table 是一个基于 GWT 框架的网页表格组件,可实现分页数据显示、数据排序和过滤等功能! Google Tag...
public class JVMine extends java.applet.Applet 简单实现!~ 网页表格组件 GWT Advanced Table GWT Advanced Table 是一个基于 GWT 框架的网页表格组件,可实现分页数据显示、数据排序和过滤等功能! Google Tag...
public class JVMine extends java.applet.Applet 简单实现!~ 网页表格组件 GWT Advanced Table GWT Advanced Table 是一个基于 GWT 框架的网页表格组件,可实现分页数据显示、数据排序和过滤等功能! Google Tag...
public class JVMine extends java.applet.Applet 简单实现!~ 网页表格组件 GWT Advanced Table GWT Advanced Table 是一个基于 GWT 框架的网页表格组件,可实现分页数据显示、数据排序和过滤等功能! Google Tag...
public class JVMine extends java.applet.Applet 简单实现!~ 网页表格组件 GWT Advanced Table GWT Advanced Table 是一个基于 GWT 框架的网页表格组件,可实现分页数据显示、数据排序和过滤等功能! Google Tag...
它界面友好清新,操作方便,支持多种语法着色,包括 C++, Delphi(Pascal), Java, C#, Basic, Html, XML, Asp, Php等多种语法,以及灵活的分类数据管理功能,强大的数据搜索功能,可让你从复杂冗长的数据代码中解脱出来,...
Freetype支持和自定义序列化程序,可从Json生成字体 九补丁编辑器,具有批处理功能,可处理多个图像 对集成支持,可实现智能大小调整的动画UI。 实现自己的类,以扩展皮肤功能 使用Scene Composer创建基本的Scene...