java 图形界面
1、创建一个窗口框架
/**
* java 用户界面框架
* 2016/5/10
*/
package org.windows; import javax.swing.*;
public class MyJFrame { public static void main(String[] args) {
JFrame frame = new JFrame("MyJFrame"); //创建一个有标题的框架
frame.setSize(400,300); //设置宽度
frame.setLocationRelativeTo(null); //窗口居中显示
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //窗口关闭时结束程序
frame.setVisible(true); //这句之后窗口才会显示 } }
2、向窗口中添加一个按钮
/**
* java 用户界面框架
* 2016/5/10
*/
package org.windows; import javax.swing.*;
public class MyJFrame { public static void main(String[] args) {
JFrame frame = new JFrame("MyJFrame"); //创建一个有标题的框架 JButton jbtOK = new JButton("OK"); //新建一个按钮
frame.add(jbtOK); //将按钮添加到窗口中 frame.setSize(400,300); //设置宽度
frame.setLocationRelativeTo(null); //窗口居中显示
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //窗口关闭时结束程序
frame.setVisible(true); //这句之后窗口才会显示 } }
3、布局管理器
1) FlowLayout :按照组件的添加顺序从左到右排列在容器中,当放满一行就开始新的一行
向一个窗口添加3个标签和文本域
/**
* java 布局管理器 FlowLayout
* 2016/5/10
**/ package org.windows; import javax.swing.*; import java.awt.FlowLayout; public class MyFlowLayout extends JFrame{
public MyFlowLayout(){
setLayout(new FlowLayout(FlowLayout.RIGHT,10,20)); //设置右靠齐 add(new JLabel("First Name")); //添加标签
add(new JTextField(8)); //添加文本域,长度为8
add(new JLabel("MI"));
add(new JTextField(1));
add(new JLabel("Last Name"));
add(new JTextField(8));
}
public static void main(String[] args) {
MyFlowLayout frame = new MyFlowLayout();
frame.setTitle("MyFlowLayout");
frame.setSize(250,200);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true); } }
2)GridLayout :以 网格的形式管理组件,组件按照它们添加的顺序从左到右排列。
向一个窗口添加3个标签和文本域
/**
* java b布局管理器 GridLayout
* 2016/5/10
**/
package org.windows; import javax.swing.*;
import java.awt.GridLayout;
public class MyGridLayout extends JFrame{
public MyGridLayout(){
setLayout(new GridLayout(3, 2, 25, 25)); //设置: 行数(rows):3 列数(columns):2 水平间隔(hgap):5 垂直间隔(vgap):5 add(new JLabel("First Name")); //标签
add(new JTextField(8)); //文本域
add(new JLabel("MI"));
add(new JTextField(1));
add(new JLabel("Last Name"));
add(new JTextField(8));
} public static void main(String[] args) {
MyGridLayout frame = new MyGridLayout();
frame.setSize(200,125);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
3)BorderLayout: BorderLayout管理器将容器分为5个区域,东区,南区,西区,,北区,中央。
/**
* java 布局管理器 BorderLayout
* 2016/5/10
**/
package org.windows; import java.awt.BorderLayout;
import javax.swing.*; public class MyBorderLayout extends JFrame {
public MyBorderLayout(){
setLayout(new BorderLayout(5,10)); add(new JButton("East"),BorderLayout.EAST);
add(new JButton("South"),BorderLayout.SOUTH);
add(new JButton("West"),BorderLayout.WEST);
add(new JButton("North"),BorderLayout.NORTH);
add(new JButton("Center"),BorderLayout.CENTER);
}
public static void main(String[] args) {
MyBorderLayout frame = new MyBorderLayout(); frame.setTitle("MyBorderLayout");
frame.setSize(300,200);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true); } }
4)综合布局实验
/**
* java 布局管理器,小试牛刀
* 2016/5/10
**/
package org.windows; import javax.swing.*;
import java.awt.*;
public class TestPanels extends JFrame {
public TestPanels(){
JPanel p1 = new JPanel();
p1.setLayout(new GridLayout(4,3)); //网格布局管理器
for(int i = 1; i <= 9; i++){
p1.add(new JButton(""+i));
}
p1.add(new JButton(""+0));
p1.add(new JButton("Start"));
p1.add(new JButton("Stop")); JPanel p2 = new JPanel(new BorderLayout());
p2.add(new JTextField("Time to be displany here!!"),BorderLayout.NORTH); //5个区域的布局管理器
p2.add(p1,BorderLayout.CENTER); add(p2,BorderLayout.EAST);
add(new JButton("Food to be placed here"),BorderLayout.CENTER); }
public static void main(String[] args) {
TestPanels frame = new TestPanels();
frame.setTitle("TestPanels");
frame.setSize(400,250);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
运行效果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYsAAAD4CAIAAACSQ10HAAAAA3NCSVQICAjb4U/gAAAgAElEQVR4Xu1dfXBbV5W/+rDjpCFpgYVpG9uy006Xj/2YnQDr2JYl1wHSLezylUJCPuqUtMPAbPlM0sSOYzclhZL9Y1lITRMnTlNoOrMD29BS6kiy7KTsEobZhYEyFMtyaIEUSJPmw1/S2/PefZKfpCdZT35XOro6isbRu+/ee87vd847Ove8K8nx8XUfYPQgBogBYgAlA25FUXIrFo/HnU5n7j5pZ4szxJJK1JkYIAbKkQF3PG4SoaDx8pWrV69OvmnRoutr3BcmZ/8yNXXdkprrrlvidDpMcSaH1CxasqimenLy2tTUNduHmIqmRmKAGJCVAcih0qFNT89cvXT5I2+rff/Kt/7VIjdT4szhfHUq9uxLf/jPF88tWba0uroqbQwMuXjpytvf/raVK1fW1CyKK4rT4ZicnHrppd+++KtfLVt2nS1D0hWlY2KAGJCdAcdHPnSHESPEGufk5IMtt9VVMzY7w1gygDmYuyo65dh9+kWlpsYYcWDItclZv7910aJFs7OzxtncbjfEqVBoZHGNe4FDZDcE4SMGiAETBlxv++tbks1Qk7p88fWHmxpqHZPK1DUlNqPEZhPPGWVmarlj5h9ufOPTv/599eIavtiDIa9dvOLztbpc7pmZGahAGR8QsJxO18033/zir16sWbyo4CEmilMTMUAMVAADKZVyqD19qG75zcrV2NVpwD4dV6oTVafk69qq6g/V33Dy/LXrrlsMfWDIylsanS7X9PRUFrpmXe6qlbfc8vLvzmUOefnlVy6+9ppx4PLrr7/55pvShmSZmZqJAWJAcgZSItS1yan2N74hduUiU5TpOPvs/772xVuX3rrU/ZvLs4/85vK//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06I/iOS22jts9+P/BZLbxou0YKfFAOVSBxFT6M1kT4HUAOG1EdCr+nYdRQDu83MkuIMPqZ/snhBa0TceIircQywLd7i5VR3NkJUXH5zlcarfLyZYr6GRmgjAO/P8hhI1rl4fc0jBrK4f0UczH6VqpOlEPhtxFGDUt9n8h+TgiR/ZzaMSPtNrCDxcqbY2F7XDDyRYgwWiXxHZs4dSOt8DJQyHeV4EWjakaIcNqHVnk47YJdK1oTYbeQ+j0w+HWcX0NeKZcCyvxgqYdtDFCl3DYqhU0kh420HIoClDAvkXViqtrgt6wcNqLdBvg9DaOGcqwgjMwSIox+RpVynFbBr5UcK4jUCCXbUkIOG9EqD380wKgh3fnCaJVUneSwEa3y8HsaRg3lq10SIox+xld5cmSDOPmVVSv5fIYQ4fRVxwNffRSnZqQVTgb495Tj1I20ko8B9ZcU5ENFiIQy8O76xULnp8mJgSQD7qmJs7PaY2ZmBv7GtEc8HofX8Jc/oAX2VvDX/AX85S9gIv6a/zUechnQzhuTInlLtkayDX4GnsevImloKwMOhyM5X/J1ZqPxFLzmh/xF8tDpdPLX/AX85S9cLhd/DX/dbjf8hRZ4/D8yhsfGosYcZwAAAABJRU5ErkJggg==" alt="" />
4、Swing GUI 属性的使用
/**
* java Swing GUI 组件的公共特性
* 2016/5/10
**/
package org.windows; import javax.swing.*;
import javax.swing.border.*;
import java.awt.*; public class TestSwingAttribute extends JFrame{
public TestSwingAttribute(){
JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEFT,2,2));
JButton jbtLeft = new JButton("Left");
JButton jbtCenter = new JButton("Center");
JButton jbtRight = new JButton("Right");
jbtLeft.setBackground(Color.WHITE); //设置背景色为白色
jbtCenter.setForeground(Color.GREEN); //设置前景色、
jbtRight.setToolTipText("This is the Right button"); //鼠标放在按钮上会显示提示文本
p1.add(jbtLeft);
p1.add(jbtCenter);
p1.add(jbtRight);
p1.setBorder(new TitledBorder("Three Buttons")); //设置标题边界 Font largeFont = new Font("TimesRoman",Font.BOLD,20); //字体属性
Border lineBorder = new LineBorder(Color.BLACK,2); //设置线边界 JPanel p2 = new JPanel(new GridLayout(1, 2, 5, 5));
JLabel jlblRed = new JLabel("Red");
JLabel jlblOrange = new JLabel("Orange");
jlblRed.setForeground(Color.RED); //设置背景色
jlblOrange.setForeground(Color.ORANGE);
jlblRed.setFont(largeFont); //设置字体
jlblOrange.setFont(largeFont);
jlblRed.setBorder(lineBorder); //设置线边界
jlblOrange.setBorder(lineBorder);
p2.add(jlblRed);
p2.add(jlblOrange);
p2.setBorder(new TitledBorder("Two Labels")); //设置标题边界
setLayout(new GridLayout(2, 1, 5, 5));
add(p1);
add(p2); } public static void main(String[] args) {
JFrame frame = new TestSwingAttribute();
frame.setTitle("TestSwingAttribute");
frame.setSize(300,150);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true); } }
运行效果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAGCAIAAACNcmNmAAAAA3NCSVQICAjb4U/gAAAAEklEQVQIW2P4//8/EwMDAzoGAEJOAwgJ4VymAAAAAElFTkSuQmCC" alt="" />aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAGCAIAAACNcmNmAAAAA3NCSVQICAjb4U/gAAAAEklEQVQIW2P4//8/EwMDAzoGAEJOAwgJ4VymAAAAAElFTkSuQmCC" alt="" />aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAATAAAACbCAIAAABqNVA9AAAAA3NCSVQICAjb4U/gAAAeIElEQVR4Xu1dDXBc1XV++7/6sWTLELBsa2WZIDvpNEwDrgX2CmwEboaJTEgoCZGIU5VOM8lMmmRqByKSIJLamYSkhGlTx6lhbX5qm9pq+UkiK1hriEgDnbQdsAVY0trgBMfIlqyVVvvbc999e/f97r63+3a1T3veaFbv3XvOued87317zr3v7a7t1KlTSX5LJBJ0B15T/Kbcoe0cx9EdeKX7qq/QyNqV+1ottF32SgdS7cJGRM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CoblS1WvwLQ/3lEgPGK+aBsgS7aKO5iLeIuygXlK6MV7QISMXLBDmWjrBHaCSFBQSxK92UcYONRQkKGhBaQoTyEQzHrZPtURfZKsWCjZKdc9t55PLU4tBURoHTS8pz1isXovuyVHVJ2gEG6QzlF9+GVHoq5p8VGQkimAAcgB9SCV8Yo5jSzDjsgA8KUhPAKMpSWTIs2QruYmfSQvVLLSEitywLbi4cAJZKWfdYrFqP7slcmANc/WBNzBA4pD9kr7LCNEpIesn3K2P8H4BnJWCI2eCMAAAAASUVORK5CYII=" alt="" />
5、FigurePanel实例类
/**
* java Graphics类的使用 在面板上话图形
* 2016/5/10
**/
package org.windows;
import java.awt.*;
import javax.swing.*; public class TestFigurePanel extends JFrame {
public TestFigurePanel(){
setLayout(new GridLayout(, , , )); //建立2行3列的布局
add(new FigurePanel(FigurePanel.LINE));//调用FigurePanel
add(new FigurePanel(FigurePanel.RECTANGLE));
add(new FigurePanel(FigurePanel.ROUND_RECTANGLE));
add(new FigurePanel(FigurePanel.OVAL));
add(new FigurePanel(FigurePanel.RECTANGLE, true));
add(new FigurePanel(FigurePanel.ROUND_RECTANGLE, true));
} public static void main(String[]args){
TestFigurePanel frame = new TestFigurePanel();
frame.setSize(, );
frame.setTitle("TestFigurePanel");
frame.setLocationRelativeTo(null); // Center the frame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
/**
* java Graphics类的使用 在面板上话图形
* 2016/5/10
**/
package org.windows;
import javax.swing.*;
import java.awt.*;
public class FigurePanel extends JPanel {
public static final int LINE = ;
public static final int RECTANGLE = ;
public static final int ROUND_RECTANGLE = ;
public static final int OVAL = ; private int type = ;
private boolean filled; public FigurePanel() {
} public FigurePanel(int type) {
this.type = type;
} public FigurePanel(int type, boolean filled) {
this.type = type;
this.filled = filled;
} public void paintComponent(Graphics g) {
super.paintComponent(g);
int width = getSize().width;
int height = getSize().height; switch (type) {
case LINE:
g.setColor(Color.BLACK);
g.drawLine(, , width - , height - );
g.drawLine(width - , , , height - );
break;
case RECTANGLE:
g.setColor(Color.BLUE);
if(filled)
g.fillRect((int) (0.1 * width), (int) (0.1 * height),
(int) (0.8 * width), (int) 0.8 * height);
else
g.drawRect((int)(0.1*width), (int)(0.1*height), (int)(0.8*width),(int)(0.8*height));
break;
case ROUND_RECTANGLE:
g.setColor(Color.RED);
if(filled){
g.fillRoundRect((int)(0.1*width),(int)(0.1*height),(int)(0.8*width),(int)(0.8*height),, );
}
else
g.drawRoundRect((int)(0.1*width),(int)(0.1*height),(int)(0.8*width),(int)(0.8*height),, );
break; case OVAL:
g.setColor(Color.BLACK);
if(filled)
g.fillOval((int)(0.1*width),(int)(0.1*height),(int)(0.8*width),(int)(0.8*height));
else
g.drawOval((int)(0.1*width),(int)(0.1*height),(int)(0.8*width),(int)(height*0.8));
break;
}
}
public void setType(int type){
this.type = type;
repaint(); //刷新视图区域
}
public int getType(){
return type;
} public void setFilled(boolean filled){
this.filled = filled;
}
public boolean getFilled(){
return filled;
}
public Dimension getPreferredSise(){
return new Dimension(, );
} }
运行效果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZwAAADaCAIAAAAdVWOrAAAAA3NCSVQICAjb4U/gAAAbXElEQVR4Xu2d748cyVnH5/fsrn1e794Rx7/x2adTDiSQCEHgQ8Ahwr1CihAIKXnDH4AEAiEECAleoSgQKfwBSIh3ESiBc4IS3XGKBRJIOQl4EUvnO3vPOV/inHe96/0xv4en52k/U1PV3TPd09NdXf0dRX3V1VXVVZ/q+eSp7p519ejoaBz0GY1GlM3boOPjSqXC+ZzQtrJLCS1t7nKZwJLqIaRBAASKQqBarYZ1VTuk7kqaE9pWdilhfmq1GmXStqGKSZNXYq/RYKgp2aoJGScXMIcdlm+WRA4IgIC1BFhAZvfMfMnhROAuK4xaM13GOeQy8hVtSSANKicCEqnRYTGaBGuc4PKq/iRHmlLb5FFpqgo0V2CmCSWwwbBiyAcBEEiXgGmliPYDC2uZgRajNjk/TGdcg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6qu5xWt1SX3SIJbVeTGh1ltUV7bbr8NJ3COXwa3rLCWG3qqpNKSrxGaflQX7kRzuHxS47g4Bz1qEZKLaAdwi4IgEC+BFRzSU/UTDMtOarFqK5qG06rXqMclppszUiNcvzlpwqFz8ceUc8hLpPoTPOa5jIRWYTRInQGkeV7peLsIJCAgOovlpSpOS4jJVkyqtHUtKo2Ftxcr/0/Gni6IPSA038AAAAASUVORK5CYII=" alt="" />
其中有一个显示不出来,弄了好久也没有弄明白为什么,待解决。
6、绘制弧形
fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
用于弧形的填充
- 参数:
x
- 要填充弧的左上角的 x 坐标。y
- 要填充弧的左上角的 y 坐标。width
- 要填充弧的宽度。height
- 要填充弧的高度。startAngle
- 开始角度。arcAngle
- 相对于开始角度而言,弧跨越的角度。-
/**
* java 面板绘制弧形
* 2016/5/10
**/
package org.windows; import javax.swing.*;
import java.awt.*;
public class DrawArcs extends JFrame {
DrawArcs(){
setTitle("DrawArcs");
add(new ArcsPanel());
}
public static void main(String[] args) {
DrawArcs frame = new DrawArcs();
frame.setSize(300,300);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
} class ArcsPanel extends JPanel{
protected void paintComponent(Graphics g){
super.paintComponent(g); int xCenter = getWidth() / 2;
int yCenter = getHeight() /2;
int radius = (int)(Math.min(getWidth(),getHeight()) * 0.4); int x = xCenter - radius;
int y = yCenter - radius; g.fillArc(x, y, 2*radius, 2*radius, 0, 30); //填充弧形
g.fillArc(x, y, 2*radius, 2*radius, 90, 30);
g.fillArc(x, y, 2*radius, 2*radius, 180,30);
g.fillArc(x, y, 2*radius, 2*radius, 270, 30);
}
}运行结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAToAAAE5CAIAAACPtHulAAAAA3NCSVQICAjb4U/gAAAbbElEQVR4Xu2da48k11mAu2e657brvdgmjtd7Yb22rBgkkAhBYCPAyMGfIk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BSYgUelUTerR1VUvjrhpRjYlTN8OSq8rpZakvp3I0vpnJaPd61CrmKGWMruqVnGpF21vJ0au2e+ga3y7klE3A9jDel7lqFzM2SnmTNgVEH81XQfTUdtXoZ0QzrtoJU0za0epjXfU80VX1SkSyxy2PrFJfypuPnEoZNdPoauraZhppFU1cWq1lwNk+x2mSAwHnBOJmmi5sUTVTnZS0uWTnqFlyVX3TU9tDDbMRXU1mxNjxs6uapsrJ0Y6r0pMKI4rqmCQhvYqTOiz1ViU0R/XWztS52XLaHtr5Efp2MbuRSDFOIZCPgGpm143nyFVjoylp55gqKoUepaSx1ORrjvFQddOjSmuO5pIWlhZGz67SqNglCbXLdtW2SPtTSzWoylUNpPYxoqg51UnqqUmbmaOrvV1IV0nAmGY6jefIJc20L5m0qqHVNW0Km1NJGFHttK1rXNqIseNXTcZV6VLMEWMjmkkHdlBVUY20xlvbVWOgJrTluJbxHC05Z8FMg3PKcAkCKQkY6xLLR64aD01h20zNVEUlrQn7qMZKjiT0I2m99Y27at8ha+H/BzAdPvEj9rpYAAAAAElFTkSuQmCC" alt="" />
7、绘制当前时间的时钟
这个程序分为两个部分,一个控制主窗口,一个用于绘制时钟。
1)绘制时钟类:
/**
* java 在面板上显示时钟
* 2016/5/11
**/
package org.windows; import javax.swing.*;
import java.awt.*;
import java.util.*; public class StillClock extends JPanel{
private int hour;
private int minute;
private int second; public StillClock(){
setCurrentTime();
} public StillClock(int hour, int minute, int second){
this.hour = hour;
this.minute = minute;
this.second = second;
} public int getHour() {
return hour;
} public void setHour(int hour) {
this.hour = hour;
repaint(); //这个方法会引起JVM调用paintComponent()
} public int getMinute() {
return minute;
} public void setMinute(int minute) {
this.minute = minute;
repaint();
} public int getSecond() {
return second;
} public void setSecond(int second) {
this.second = second;
repaint();
} protected void paintComponent(Graphics g){ //绘制图形
super.paintComponent(g); //为了确保视图域在显示新图之前被清除 int clockRadius = (int)(Math.min(getWidth(), getHeight()) * 0.8 *0.5);
int xCenter = getWidth() / 2;
int yCenter = getHeight() / 2; g.setColor(Color.BLACK);
g.drawOval(xCenter - clockRadius, yCenter - clockRadius, 2 * clockRadius, 2 * clockRadius);
g.drawString("12", xCenter - 5, yCenter - clockRadius + 12); //绘制12时间刻度
g.drawString("9", xCenter - clockRadius + 3, yCenter + 5);
g.drawString("3", xCenter + clockRadius - 10, yCenter + 3);
g.drawString("6", xCenter - 3, yCenter + clockRadius - 3); //秒针
int sLength = (int)(clockRadius * 0.8);
int xSecond = (int)(xCenter + sLength * Math.sin(second * (2 * Math.PI / 60)));
int ySecond = (int)(yCenter - sLength * Math.cos(second * (2 * Math.PI / 60)));
g.setColor(Color.red); //设置秒针颜色
g.drawLine(xCenter, yCenter, xSecond, ySecond); //绘制秒针 //分针
int mLength = (int)(clockRadius * 0.65);
int xMinute = (int)(xCenter + mLength * Math.sin(minute * (2 * Math.PI / 60)));
int yMinute = (int)(yCenter - mLength * Math.cos(minute * (2 * Math.PI / 60)));
g.setColor(Color.blue);
g.drawLine(xCenter, yCenter, xMinute, yMinute); //时针
int hLength = (int)(clockRadius * 0.5);
int xHour = (int)(xCenter + hLength * Math.sin((hour % 12 + minute / 60.0) * (2 * Math.PI / 12)));
int yHour = (int)(yCenter - hLength * Math.cos((hour % 12 + minute / 60.0) * (2 * Math.PI / 12)));
g.setColor(Color.green);
g.drawLine(xCenter, yCenter, xHour, yHour);
} public void setCurrentTime(){
Calendar calendar = new GregorianCalendar(); //设置小时,分钟,秒
this.hour = calendar.get(Calendar.HOUR_OF_DAY);
this.minute = calendar.get(Calendar.MINUTE);
this.second = calendar.get(Calendar.SECOND);
} public Dimension getPrefreferredSize(){
return new Dimension(200, 200);
} }SrillClock.java
2) 主窗口类:
/**
* java 在面板上显示时钟
* 2016/5/11
**/
package org.windows; import javax.swing.*;
import java.awt.*;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DisPlayClock extends JFrame{
public DisPlayClock(){
StillClock clock = new StillClock(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 设置日期格式
JLabel jl = new JLabel(df.format(new Date()));//获取当前系统时间 add(clock);
add(jl, BorderLayout.SOUTH);
} public static void main(String[] args) {
DisPlayClock frame = new DisPlayClock();
frame.setTitle("DisPlauClock");
frame.setSize(300, 350);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
} }
DisPlayClock
运行效果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUIAAAF0CAIAAADZ7Kd7AAAAA3NCSVQICAjb4U/gAAAgAElEQVR4Xu2dCbRcxXnne++3L5JACCE9CUkDEgIGYuMYGck4QDDxscHOeAsmZww4zsQ59hCccUjwgRBi7JBxxrvH8mECeEwCBuwgMWaRkZQ4XgIYjC2MhKSHkISWt2+993y3v3716tW9t/v2e92vq+7938O5qlu3lu/7V/36q6puifD4+HgoFCoUCnwvTl+UQxc9iQSn6U4lRTFOiBxO0F0kuLycL7/ltLiLwkq+42NNhR1bQCYUEAqEw2HvajgWVjLFIyfsjyKfEuIiGygdiUQ4hxKcFgmRTyUpk8vH6A+FSUEvcyvzrJQUj6IRTih3VqcmnpUq/Ig7FGiWAoycY+/KK/Eo53NauYtHJlO+EyxML/dIaQ60VIbRpUdKUzG+xxwZ5kwGWMaYCXeEmfrjfE6Iu/2RLRNUOz7a9VLK2wsgBwrUVwHGrEKbSgHHR5HJCXGXE5RWLhFmRe+UwwgQg/yWXnEO1bUwFnByQtxljGWYHTHmFh1JFgTKKMppYZAimVKmgqB4BQUaqgBTp3ShZMqPIs0J5S4eKWG/mFia/AJX0S8V5sgsYjInnKOxADifz8swU9MK88wt86akBZzirbBG5tPOqj3HcYQ8FnOsi0woUJlJN32YQPmtnGNPc45yZ3SpEZlhApIfaWJTQtAkz3PBsMjkREzGUonDzHB//4Hdu3YcPPBqOj3l5hvyoQAUqIsCyWRb36rVmzZtWX7GSiZZaZZJpkw5IIcHBweptONCmjD+2U9//Ni/fC8aoyqREB1R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新。
8、 改进时钟,使其可以动态显示时钟
时钟类不变,在主窗口类中增加监听:
主窗口改版后的代码:
/**
* java 在面板上动态显示时钟
* 2016/5/11
**/
package org.windows; import javax.swing.*; import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask; public class DisPlayClock extends JFrame{ private StillClock clock = new StillClock(); //图形时钟 private JLabel displayArea; //放置时间的标签
private String time; //记录时间 public DisPlayClock(){
displayArea = new JLabel(); add(clock);
add(displayArea, BorderLayout.SOUTH);
//安排任务,定期执行
Timer timer = new Timer();
timer.scheduleAtFixedRate(new JLabelTimerTask(), new Date(), (long)1000);
} //内部类监听
class JLabelTimerTask extends TimerTask{
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 设置日期格式
public void run() {
//刷新图形时钟
clock.setCurrentTime();
clock.repaint(); //刷新文字时钟
time = df.format(Calendar.getInstance().getTime());
displayArea.setText(time);
}
} public static void main(String[] args) {
DisPlayClock frame = new DisPlayClock();
frame.setTitle("DisPlauClock");
frame.setSize(300, 350);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
DisPlayClock
运行结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAATUAAAGFCAIAAAATt/MmAAAAA3NCSVQICAjb4U/gAAAgAElEQVR4Xu2dCZQc1Xnvq3rv2WckEEJIIyHpgYSAB7HlGBnJOEAw8bHBzvMWTM4z4JgX59jPwYlDgg+EEGOHxIl3P+PDC+BnEjBgB4lnFhlJhHgJYDC2MGgbtI80+9J7V77q233nTlX1MjPdVfdW/euI1q1bd/nu/7u//m7dqhb6yZMnDcMoFovskxI8TTmOh6ZpLJ8lLJ90ynPEhCWfnYqf1KY9EzlQwH0FdF2v1qnlEj8V81na8slPKWE/QqEQZdInO1iaPiOcQEamyCcDdU6I0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dP2/AGmTV84OslBGAAAAAElFTkSuQmCC" alt="" />
9、监听器,注册,处理
在面板上使用两个按钮来控制圆的大小
(1)使用内部类进行监听
代码:
/**
* java 圆控制 事件监听
* 2016/5/11
**/
package org.windows; import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ControlCircle extends JFrame{ private JButton jbtEnlarge = new JButton("Enlatge");
private JButton jbtShrink = new JButton("Shrink");
private CirclePanel canvas = new CirclePanel(); public ControlCircle(){
JPanel panel = new JPanel();
panel.add(jbtEnlarge);
panel.add(jbtShrink);
this.add(canvas, BorderLayout.CENTER);
this.add(panel, BorderLayout.SOUTH); jbtEnlarge.addActionListener(new EnlargeListener()); //增加增大按钮的监听
jbtShrink.addActionListener(new ShrinkListener()); //增加减小按钮的监听 }
public static void main(String[] args) {
JFrame frame = new ControlCircle();
frame.setTitle("ControlCircle");
frame.setSize(200, 200);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
} //增大按钮的监听类
class EnlargeListener implements ActionListener {
public void actionPerformed(ActionEvent e){
canvas.enlarge();
}
} //减小按钮的监听类
class ShrinkListener implements ActionListener {
public void actionPerformed(ActionEvent e){
canvas.shrink();
}
} class CirclePanel extends JPanel{
private int radius = 20;//圆的初始半径 //增大的响应方法
public void enlarge(){
radius+=2; //将圆的半径增加2个像素
repaint();
} //减小的响应方法
public void shrink(){
radius-=2; //将圆的半径减小2个像素
repaint();
} protected void paintComponent(Graphics g){
super.paintComponent(g); g.drawOval(getWidth() / 2 - radius, getHeight() / 2 - radius, 2 * radius, 2 * radius);
}
}
}
ComtrolCricle.java
运行效果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAANcAAADuCAIAAAAlagWHAAAAA3NCSVQICAjb4U/gAAAaaElEQVR4Xu2de5Ac1XWH5z27K6GVBDHWah9aJIqYpGJXAgrogR4UDuVyuezCEMIaZAwuOzFJKTGVgEHiIWNcDjYUThFShZAQpiAmJNi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YgjkkpnxFE0YvckHEkIUxbFEPKk9ogWLksKIDGiUbVALRrFKtFCdhxoPEMUwUd2tBCIiBCeaVKsAiJ4GrsTKCE0IoIiHHhLhA+nQGRXOkvk0SUqgpdUJpmYQm8/SCJYmFm1VKEQq1QKya7yBxaRRZoOVRaJUaQWA43nQuIDCpBCogdcxSkQySMW8ZJCxFhKCx0Qb1GdP/CsMirVa6sEhqfKlDnqvlSLl6KRLGSEgmjESzwjfFBGqvASKVQRtJoR/x/Q/LUlvlcERQAAAABJRU5ErkJggg==" alt="" />
(2)使用匿名类进行监听
代码:
/**
* java 圆控制 事件监听 匿名类监听
* 2016/5/11
**/
package org.windows; import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ControlCircle_2 extends JFrame{ private JButton jbtEnlarge = new JButton("Enlatge");
private JButton jbtShrink = new JButton("Shrink");
private CirclePanel canvas = new CirclePanel(); public ControlCircle_2(){
JPanel panel = new JPanel();
panel.add(jbtEnlarge);
panel.add(jbtShrink);
this.add(canvas, BorderLayout.CENTER);
this.add(panel, BorderLayout.SOUTH); // jbtEnlarge.addActionListener(new EnlargeListener()); //增加增大按钮的监听
jbtEnlarge.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
canvas.enlarge();
}
});
//jbtShrink.addActionListener(new ShrinkListener()); //增加减小按钮的监听
jbtShrink.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
canvas.shrink();
}
}); }
public static void main(String[] args) {
JFrame frame = new ControlCircle_2();
frame.setTitle("ControlCircle");
frame.setSize(200, 200);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
/*
//增大按钮的监听类
class EnlargeListener implements ActionListener {
public void actionPerformed(ActionEvent e){
canvas.enlarge();
}
} //减小按钮的监听类
class ShrinkListener implements ActionListener {
public void actionPerformed(ActionEvent e){
canvas.shrink();
}
}
*/
class CirclePanel extends JPanel{
private int radius = 20;//圆的初始半径 //增大的响应方法
public void enlarge(){
radius+=2; //将圆的半径增加2个像素
repaint();
} //减小的响应方法
public void shrink(){
radius-=2; //将圆的半径减小2个像素
repaint();
} protected void paintComponent(Graphics g){
super.paintComponent(g); g.drawOval(getWidth() / 2 - radius, getHeight() / 2 - radius, 2 * radius, 2 * radius);
}
}
}
ControlCircle_2
运行效果同上
10、小小计算器
从两个文本框中获取数据,点击按钮,将两个数的和显示在另一个文本域
/**
* java 图形计算器1.0版
* 2016/5/11
**/
package org.windows; import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Calculator_1 extends JFrame{ private JTextField num_1 = new JTextField(8);
private JTextField num_2 = new JTextField(8);
private JTextField sum = new JTextField(8);
private JButton addNum = new JButton("ADD"); public Calculator_1(){
JPanel p1 = new JPanel(new GridLayout(2, 2, 5, 5));
p1.add(new JLabel("NUM_1"));
p1.add(num_1);
p1.add(new JLabel("NUM_2"));
p1.add(num_2);
add(p1); JPanel p2 = new JPanel(new BorderLayout());
p2.add(addNum);
p2.add(sum,BorderLayout.SOUTH);
add(p2,BorderLayout.SOUTH); //响应事件
addNum.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
int num1 = Integer.parseInt(num_1.getText());
int num2 = Integer.parseInt(num_2.getText());
int sum_x = num1 + num2;
sum.setText(sum_x+"");
}
});
} public static void main(String[] args) {
JFrame frame = new Calculator_1();
frame.pack();
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
说明:代码没有进行输入检查,只是了解怎么在文本与读取数据。
运行结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMwAAACXCAIAAADWCSORAAAAA3NCSVQICAjb4U/gAAAYc0lEQVR4Xu2da2xcx3XH7775kEhRcqPoRUYPw41bVAGqOLEkk3pQqT8FNVqrLRIJaSvoQ4EWLRqnqhslcQUbSuA2gAv0g6q2gNQWqIwUSurERUTqQUmu0ypGkxqIAEkkV7LlhnEkkeJrH3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I6STJGraRrtQ1nDkgAsyu9FTX0GBxSPkpmxxSBhpK0jNbrCQNc0aEUMguzZOz4poMtwElRBjGD7mZMJkJuiWxhZDA0kMU4Qs1yzJHqcMyK/KNKJVDOZteUMkckKiOlK6BKRSYWEMCF5EJY5kExgtRGTV2ZjpqjCAEd02G+2EUmTCKkg8jPmjYcA94MoQEGZKIM4KMoswTC1QbU8IVsoYycEj30qOsJ0EuriQFJMp8ePZXSaWorGQNKyHISopSSGxBhkAXZIKMeFKcmcyfmC5pOGXCoFEI4/shG5Di1RhzRugwbVRnGc4oA4dkJoWb8hiVT/W0e5MpCQi/TimpcpRkOUQlNMQsKFGMO2mYMBKq4axkutTHmDRUO4Xkugg1eZYk2pgqBS+CiesnQb6dn8wWlDP4mdXoZZLYGrJSl1kjU6WgxnjJAkHGoe7JSIMMridThoduTONK9XLtPD/KhLEDU9iiaHnCyuBlwFrIn43ME0GjY0d5OCeNskyYThu5NA5l1Dw5E5ChXvyjdwYDjDJys5CNPlBCEqFGAoOlC4QXhUyMLnA2up0nW55KvdkB1yhgkTVkpafsCRnKEnOeoQwZIaTPm8zf/wPL0EVp2mu6OAAAAABJRU5ErkJggg==" alt="" />
11、鼠标拖动事件
在窗口类用鼠标拖动文本
/**java 鼠标响应事件
* 2016/5/11
**/
package org.windows; import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MouseEven extends JFrame{ public MouseEven(){
MouseEvenMove p = new MouseEvenMove("welcome to java~~"); setLayout(new BorderLayout());
add(p);
}
public static void main(String[] args) {
MouseEven frame = new MouseEven();
frame.setSize(200, 100);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
} static class MouseEvenMove extends JPanel{
private String message = "Welcome to Java";
private int x = 20;
private int y = 20; public MouseEvenMove(String str){
message = str;
addMouseMotionListener(new MouseMotionAdapter(){
public void mouseDragged(MouseEvent e){
x = e.getX();
y = e.getY();
System.out.println("坐标:"+x+" "+y);
repaint();
}
});
} protected void paintComponent(Graphics g){
super.paintComponent(g);
g.drawString(message, x, y);
}
}
}
运行效果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAN8AAAB/CAIAAADgh4CVAAAAA3NCSVQICAjb4U/gAAAVMUlEQVR4Xu2d+49kR3XH+909j52ZXRuWfc2ynrUsHCSQeImskRNHJv4pEopASPALfwASKFEUJVGk5CeEeEjwByAhfsMgIF5ArOxYrBIpkbCU5AdW8tq748VrWIx3Z3Ye/e5873x7Tp8+Vbemmd2Zud1dV1bp1Klz6p469Zlzb/X0jvPNZrPX6+VyOdOiG7ho73WUqbRgZHR5cQbpGiE8muYV9fvOQD6fD/h6R7VSZAreVpQQAhfCwGjJS1iASz2EKdilYFrpcsEuaq5GUhMYCqQvDj2UDBAg71TukNaITMG06GJb0WoX712gpHEJkgE0gGa325VROoqvmYR3Fcg0bVrWwaXpzQJGNEtbdtQzA6MgAss0M60X2QjsosWFXTMCuoVCIbAdMLC1E7N4L82lMcANqKFgWukyDsOW6UqsafrAYuLQw8oAqXJnM3rdFZmCaaULQXsBKnQDjA7VTi+XUBLNQwbUYO0mK2oeegY0OmZyM6S7IlMwrXQhuBfQBFdpgA5qp6BJLAyp+wZUIJNy6NZFV8PUpOkf+q7ECZkB4SyMJkbFUrMoek0klS6X0AiaZqMxRE2/dpJFTEQtu2zBpaAp5ZMC7bWxaGQqPSdkrfd2A0oOuW2E2M2J0aRh53X0GhuldAVETiVdLUDmBRsIgFK6BBR6XT65obBJaicvWGjOIOt6SUa1xhibSTibabkAWBrB26VyzyFtFuX9ZYAkeX3NkHS1nrJppQvBXACAgPKOAijMyCgwgwyzPp2w86JJpaDpFlGXUZmKgrRul8EJrN4ulbo19q5B1IySAdITsDQG3q4oKUirBcjmIoLiixig4bYCMCmifToxLBRqQbOoAX3wCqoJG4XOSGQAowcf0qDIbEapuyJTMK10IbgXQcSG6kc5bwpj1lGpoEPvnUTTAEouO52OW0EN0+wK60QqrWVAGjstu6OBPX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GALXvndx+QZNdAGqowr11ycQoASWd7IqL9qXMRYqs8aKsNYzBpFt3jXHAcmqHNHBuEswou1opGlFC0Ep22Urlg8ALej7HXTT1417bU04+hWL9g0AOIGiGDJoSBx3ljRMuUkEpa/goC3nCk2gMgmLAVJquyW941N2MKdSQpLSFm1HdFQThK3oyQI3wIF2AQSUJg0xhH4AO3jsNo3olwpmEAoEsklH9QIexVFA6iruwKDyJRm6nUdOy1yAt3VG/ZwYENW2pla4sGmJAHNlqMCBrQNkloIKpeftMq6CD9054uktiQKRERyBQSr00gAqXmNOVeSODZoBLL6ZutFGzvwxoEIU5TqWJ1EMaUFemhoxKuyegwq5Y9t87SZsXUJABtGXZ/FHg7zAxZOgUEI0Ad2FRUHMFMePtvFB6lfvblWn2MkQaFjWIWtawUpaWRLqtppPwuI94wVGGqOm/dyICL6BmDegCR56HRkSTwAma7DIXWqn1HPVq0pTiEoURM2B2ll6uUjQUvF0oZZSyaUcB1HBJl8GTHfF5AZXV4pbkEoJ+6QRkJJUCW2Ik/GkQKWvORKOVOsvawM1+eNS1n0IN6UlbuHdUK0U2ArtovQL15AyyZpSlkUTKSyeVbGk/9GRH9ASUY7IYvf28JQ2gNwcgdEkYhuilBU4os7kCfd0kiqU7FDUPngGyZebRSpHTBFKBGQQPyMIllRpTAdFbMkkX2j6dnItswRNdyBR00HJvQgxoRCCFdKEsdGIGV+a0GjsXQVdjMuhO4jWISqEqnArXTGtcmRrTEhLcSGiBoNFk1wuoDNH3/wGaj1FO6nmmmgAAAABJRU5ErkJggg==" alt="" />
12、鼠标拖动事件二
通过拖动改变一个球形的大小
/**java 鼠标响应事件
* 2016/5/11
**/
package org.windows; import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class CircleMove extends JFrame{
private int radius = 20;
private int x = 20;
private int y = 20; public CircleMove(){
MouseEvenMove p = new MouseEvenMove(20); setLayout(new BorderLayout());
add(p);
}
public static void main(String[] args) {
CircleMove frame = new CircleMove();
frame.setSize(500, 300);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
} class MouseEvenMove extends JPanel{ public MouseEvenMove(int num){
radius = num;
addMouseMotionListener(new MouseMotionAdapter(){
public void mouseDragged(MouseEvent e){
x = e.getX();
y = e.getY();
double str = Math.sqrt((x - (getWidth() / 2)) * (x - (getWidth() / 2)) +
(y - (getHeight() / 2)) * (y - (getHeight() / 2)));
radius = (int)str;
System.out.println("坐标:"+x+" "+y);
repaint();
}
});
} protected void paintComponent(Graphics g){
super.paintComponent(g);
g.drawOval(getWidth() / 2 - radius, getHeight() / 2 - radius, 2 * radius, 2 * radius);
g.drawOval(getWidth() / 2 - radius/2, getHeight() / 2 - radius, radius, 2 * radius);
g.drawOval(getWidth() / 2 - radius, getHeight() / 2 - radius/2, 2 * radius, radius);
}
}
}
运行效果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUMAAAEPCAIAAABXyzFHAAAAA3NCSVQICAjb4U/gAAAeSElEQVR4Xu2d+68kx1XHZ+7M3Neu92GbON4n67VlxSCBRAgCGwFGDv4JKUIgJPILfwASCIQQICT4CUWBSOEPQEL8FoESsBMUy8aKBRJIsQT8EEt+7K4dP7JxvK/7nHtnhtNzZs/UVHVXV1dX93TXfEdJp/rUOfX4Vn/6VPfM3XRv3bo1mUzG47F6pFPVQlXmp9PpsJEL2pFOxaIWNDufqkdq0zTCAgWWrkC3280ag1Ylp6qdy9pRTqlgftbW1shIR/5wWY7szz40sL4AzFgywyrJjLRJMiOXCjO1K7UWSnOhzXXIUhZ2KBBEAaLF3o7mkHoqRi7IUS0wluqREKWu1QbJwkQQklwroJFbX829KsZSpmAPmAVClUaNzFRQU412NVELBWpQQIVKutOM6qmUuaAd5ZQK5oehJRaEWLVHMgrMUpjnZEF3NBqpSKska0jzLYEcGL+sIw9CRVQtm7WWVTEDLc6oggKFFBD27FGmm2oxy2zRjkwvdaRizFtlstB1zscpW8lHhiQYi5EL85zM9DLGN25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SudTcCxxAAAAAElFTkSuQmCC" alt="" />
13、鼠标拖动时间三
在鼠标拖动时间二的基础上增加年一个功能,当球体的半径改变时,点击刷新按钮就可以计算出球体半径,以及表面积和体积。
/**java 鼠标响应事件
* 2016/5/11
**/
package org.windows; import javax.swing.*;
import java.awt.*;
import java.awt.event.*; public class CircleMove_1 extends JFrame {
protected int radius = 20;
private int x = 20;
private int y = 20; public CircleMove_1() {
MouseEvenMove p = new MouseEvenMove(20);
CircleParameter p2 = new CircleParameter(); setLayout(new BorderLayout());
add(p);
add(p2.jp, BorderLayout.SOUTH); addMouseMotionListener(new MouseMotionAdapter() {
public void mouseDragged(MouseEvent e) {
x = e.getX();
y = e.getY();
double str = Math.sqrt((x - (getWidth() / 2))
* (x - (getWidth() / 2)) + (y - (getHeight() / 2))
* (y - (getHeight() / 2)));
radius = (int) str;
System.out.println("坐标:" + x + " " + y);
repaint();
}
}); } public static void main(String[] args) {
CircleMove_1 frame = new CircleMove_1();
frame.setSize(500, 300);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
} class MouseEvenMove extends JPanel {
public MouseEvenMove(int num) {
radius = num;
} protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawOval(getWidth() / 2 - radius, getHeight() / 2 - radius,
2 * radius, 2 * radius);
g.drawOval(getWidth() / 2 - radius / 2, getHeight() / 2 - radius,
radius, 2 * radius);
g.drawOval(getWidth() / 2 - radius, getHeight() / 2 - radius / 2,
2 * radius, radius);
}
} class CircleParameter extends JPanel {
private JLabel JLradius = new JLabel("radius ");
private JTextField JTradius = new JTextField(5); private JLabel JLarea = new JLabel(" area ");
private JTextField JTarea = new JTextField(8); private JLabel JLvolume = new JLabel("volume");
private JTextField JTvolume = new JTextField(8); private JButton jbt = new JButton("刷新"); JPanel jp = new JPanel(); public CircleParameter() {
jp.setPreferredSize(new Dimension(150, 40));// 设置面板大小
setLayout(new GridLayout(3, 2, 5, 5));
jp.add(JLradius);
jp.add(JTradius);
jp.add(JLarea);
jp.add(JTarea);
jp.add(JLvolume);
jp.add(JTvolume);
jp.add(jbt); // 响应事件
jbt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { double num_1 = (double) (4 * Math.PI * radius * radius);
double num_1_1 = (double) (Math.round(num_1 * 100) / 100.0);// 保留两位小数 double num_2 = 4 / 3 * Math.PI * radius * radius;
double num_2_2 = (double) (Math.round(num_2 * 100) / 100.0);// 保留两位小数
JTradius.setText(radius + "");
JTarea.setText(num_1_1 + "");
JTvolume.setText(num_2_2 + "");
}
}); }
}
}
运行效果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAggAAAE+CAIAAABnVX8ZAAAAA3NCSVQICAjb4U/gAAAgAElEQVR4Xu2df5Acx3Xf9+727vCL+EHJpgkQOAKgSraSil0VkIpICCChgyK7bCcqW7BcFqDYZlCJq5KSS7IDigRdJuIUSpFsl13lpEBKkcDELoNlm6RFyUUcIACMpbJDq2znD0NF8nBHilRMywIB4sf92ru82Tfb29vzY2d2pnu6e75brGVPT/fr1583+77TPXuLoRs3bqx0Xo1GY3l5WRxSgQ65RqmX21AvPuSCeE86pHrxoo7yYd/62MaoBAEQAAHXCQwNDcVOIVovargQe0iV4iyXlffh4WGqoXcuiLN0SG40ozldJH1ZFYQwcIF6ytrA+V0xxW3Eu1zg+ceqQmxlLK+owaRmqAcBEACBqghwgs44emxjpVIcciF6KOpFuhc1QgbIHypTPueCcI8zcCAMVKVkeXmVwPIw8LpBTvSirGT/FDFIOZURNJqBAAiAgLUEYpWAvU3XA7mNrBAsBnRWVgVRpozK2sDdhTZQA14rUKqncpNOx6oCVwpVEMLABaULHwpTXBDv0UP2Kbs8xLbnSryDAAiAgFsEUsSAJ5IkCfJZ0YYL4l0uUFl5cfYXfckg1XAqptzOZ6ky3EoS6V5eGciqIMpkYgBtEBogi0EWYVDauBV+eAsCIAAC6QTkHC1aKpXyoShzQXkXh1SIvlgDKKkKAZBH5N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lnZDsogAAIgUAkBOddHHVDO8qFcKWpEJRXkSj7kd1YFKvO9Px+yJLBCKIsGoRZyeyqHX2UldynJyqpANYoqiOGpGWV/8XRBaAOneyEMbJMrRdIXqVzUcDPBS8n1yqGCNf1sNAaoAQEQAAHDBDiJJw2qnJUPRfanvqKe8zDXiJwsDhVhoAac8fNqQ/CMgTeFqEDWo3mZa4QHVOAlAndkGciyXGDjscLAyOShYzN+bGUSbtSDAAiAgJ0E5OwvPJQro2VRw6mYenGNnJm5LGsD1bAwiPfoioFrqIEQDyp3VwwKQR41qgpCD1geqIGiDVTDLzIYLfMobJbfuZkYXVTKLRXfcAgCIAACfhCQNYBmJB+KstAAnjILADeOlrmG5UG8y/IQqw3cQGhDuGKg2ihlytHUTtTTeNSMfwyDTinCIDRAKVB3IQNRJZBlIKksHJAbRL1FDQiAAAg4QUARA/Y5VhLolCIPXCNLBStB7LssDJzAo3tKQjPkFcP/B6ELMO5A3u7NAAAAAElFTkSuQmCC" alt="" />
14、鼠标拖动事件四:
在鼠标拖动事件三的基础上除去刷新按钮,让程序自动监控图形的大小变化,然后将半径面积体积等信息同步更新在面板上。
/**java 鼠标响应事件
* 2016/5/11
**/
package org.windows; import javax.swing.*;
import java.awt.*;
import java.awt.event.*; public class CircleMove_1 extends JFrame {
protected int radius = 20;
private int x = 20;
private int y = 20; public CircleMove_1() {
MouseEvenMove p = new MouseEvenMove(20);
final CircleParameter p2 = new CircleParameter(); setLayout(new BorderLayout());
add(p);
add(p2.jp, BorderLayout.SOUTH); addMouseMotionListener(new MouseMotionAdapter() {
public void mouseDragged(MouseEvent e) {
x = e.getX();
y = e.getY();
double str = Math.sqrt((x - (getWidth() / 2))
* (x - (getWidth() / 2)) + (y - (getHeight() / 2))
* (y - (getHeight() / 2)));
radius = (int) str;
System.out.println("坐标:" + x + " " + y);
repaint();
p2.newText();
}
}); //更改响应事件
p2.JTradius.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
System.out.println("你重新输入了一个字");
String JTradius_x = p2.JTradius.getText();
radius = Integer.parseInt(JTradius_x);
System.out.println("半径"+radius);
repaint();
p2.newText();
}
}); } public static void main(String[] args) {
CircleMove_1 frame = new CircleMove_1();
frame.setSize(500, 300);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
} class MouseEvenMove extends JPanel {
public MouseEvenMove(int num) {
radius = num;
} protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawOval(getWidth() / 2 - radius, getHeight() / 2 - radius,
2 * radius, 2 * radius);
g.drawOval(getWidth() / 2 - radius / 2, getHeight() / 2 - radius,
radius, 2 * radius);
g.drawOval(getWidth() / 2 - radius, getHeight() / 2 - radius / 2,
2 * radius, radius);
}
} class CircleParameter extends JPanel {
private JLabel JLradius = new JLabel("radius ");
private JTextField JTradius = new JTextField(5); private JLabel JLarea = new JLabel(" area ");
private JTextField JTarea = new JTextField(8); private JLabel JLvolume = new JLabel("volume");
private JTextField JTvolume = new JTextField(8); JPanel jp = new JPanel(); public CircleParameter() {
jp.setPreferredSize(new Dimension(150, 40));// 设置面板大小
setLayout(new GridLayout(3, 2, 5, 5));
jp.add(JLradius);
jp.add(JTradius);
jp.add(JLarea);
jp.add(JTarea);
jp.add(JLvolume);
jp.add(JTvolume);
}
protected void newText() {
double num_1 = (double) (4 * Math.PI * radius * radius);
double num_1_1 = (double) (Math.round(num_1 * 100) / 100.0);// 保留两位小数
double num_2 = 4 / 3 * Math.PI * radius * radius;
double num_2_2 = (double) (Math.round(num_2 * 100) / 100.0);// 保留两位小数
JTradius.setText(radius + "");
JTarea.setText(num_1_1 + "");
JTvolume.setText(num_2_2 + "");
System.out.println("调用第二个面板的成功了");
} }
}
运行效果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfgAAAFDCAIAAABZR4ueAAAAA3NCSVQICAjb4U/gAAAgAElEQVR4Xu3da4xc513H8bntzXZ8yaVpHNvb2KnSCxJImCKIcWiwSxES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5/XX6GOnfaObxflG/kZyr7TD/oK6h9yYOt5ZQt4GHrPT5je3lpVUYxqY+gvtNfdxfgkifn3fQfegj0nwO8HYY8BKKMK+rS99vyODvHJu5JV9Cjw3rFw28do6xXUBnr3T6B6xhl0gaVkYQv/mfdHD3z4El5z83QiUF/Dawz9eePP+B729Y6zd935uQT/i0cPXPmIev9DG7h+ZNnhl4cCF7rY2ePyWuxp90C8oOje2ocdD24JZ23hNmOj8v66Wde3rI0OLsZHHTFa2e85f6VYb2tN2A7P+a7RwH2W/Tct3AM3bB1eSu4Fw4f9rylL6h974icZ5RFWd2tUbmra78MrOPYxh2JlbfnrXefebJ85CEQ8K6bkIdA8Gp4bgleet/qXmdZlQv9FzQCHx0B6xhlvYLKhKyj75gNv1iXH8M7nU673T561HMoYvisk09PPr+iLB/b9PG/PCdDLcWHmpVINfldJ3LNEi3cyJxYRy9IcdbxkUceKf4ZfeTHBwURQAABBPwESnZG7zcFriGAAAIIhAm4Z/Qlej02bDa53CaHIYX6ANJcJq28E1SVE+fSAeuYC3O8TiTe6/IrYxsbG3JGf+TIkXi1q1pa/jWPEk29FGf04lku1RzuAGVZuBEK1nEEpAjr+Oijjxb/XTc5PKbidVGElYs34jKURrUMqzR5jKzjZCMdJXgxVoc6fSKAAAJ5CbifdWOd4NTreXVKPwgggAACuQpYn15JyudKTmcIIIBAjgKS8O7HFJP1ObLTFQIIIJCfgBX00hspnx85PSGAAAL5CrCjz9eb3hBAAAEdAu6Onk29Dnz6RAABBJQLuDt6+YOgV45NBwgggIAOga2g19E7fSKAAAIIKBdoyJezl2dHrxybDhBAAAEdAhzd6FCnTwQQQCBHASvopTvrj4b7WQg59k5XCCCAAALKBZyE3zrAUd4hHSCAAAII5CvgRrzkPWf0+crTGwIIIJCTgAT9/wMjZ0YjcBZUpgAAAABJRU5ErkJggg==" alt="" />
15、使用进度条
package cn.thread; import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeListenerProxy; import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextArea;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingWorker;
import javax.swing.JButton;
import javax.swing.JProgressBar;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane; public class progressBarDemo extends JFrame { private JPanel contentPane;
private JTextField jtfPrimeCount;
private JProgressBar jpb;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
progressBarDemo frame = new progressBarDemo();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
} /**
* Create the frame.
*/
public progressBarDemo() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(300, 200, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null); JTextArea jtaResult = new JTextArea();
jtaResult.setBounds(10, 10, 414, 163);
jtaResult.setWrapStyleWord(true);
jtaResult.setLineWrap(true); JScrollPane scroll = new JScrollPane(jtaResult);
scroll.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
// contentPane.add(jtaResult);
scroll.setBounds(10, 10, 414, 163);
contentPane.add(scroll); JLabel label = new JLabel("请输入要计算的素数的个数:");
label.setBounds(20, 183, 169, 15);
contentPane.add(label); jtfPrimeCount = new JTextField();
jtfPrimeCount.setBounds(199, 183, 66, 21);
contentPane.add(jtfPrimeCount);
jtfPrimeCount.setColumns(10); JButton button = new JButton("开始计算");
button.setBounds(314, 183, 93, 23);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int text = Integer.parseInt(jtfPrimeCount.getText());
ComputePrime task = new ComputePrime(
text,jtaResult);
task.addPropertyChangeListener(new PropertyChangeListener() { @Override
public void propertyChange(PropertyChangeEvent evt) {
if("progress".equals(evt.getPropertyName())){
jpb.setValue((Integer)evt.getNewValue());
} }
});
task.execute();
}
});
contentPane.add(button); jpb = new JProgressBar();
jpb.setBounds(21, 225, 403, 14);
jpb.setStringPainted(true);
jpb.setValue(0);
jpb.setMaximum(100);
contentPane.add(jpb);
} static class ComputePrime extends SwingWorker<Integer, Integer>{
private int count;
private JTextArea result;
public ComputePrime(int count, JTextArea result){
this.count = count;
this.result = result;
}
protected Integer doInBackground(){
publishPrimeNumbers(count);
return 0;
}
protected void process(java.util.List<Integer>list) {
for(int i= 0; i < list.size(); i++){
result.append(list.get(i) + " ");
}
}
private void publishPrimeNumbers(int n){
int count = 0; //需要找到素数的个数
int number = 2;
while(count <= n){
if(isPrime(number)){
count++;
//上传进度
setProgress(100 * count / n);
publish(number);
}
//判断下一个数是否是素数
number ++;
}
}
//判断这个数是否是素数
private static boolean isPrime(int number) {
for(int divisor = 2; divisor <= number / 2; divisor++){
if(number % divisor == 0) {
return false;
}
}
return true;
}
}
}
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAckAAAE/CAIAAACilq8iAAAgAElEQVR4nO2d7W8jyX3nBezbe5d3p7eH/AHRm0OAe5U3eZd3QQzFdwbsPLww7oXhGFg5FjZrX/Z2IBsCvOdksLBP8SCXRWxk1kA2J+zAGIDZnR3daGYkjR4oiqSaDxJJSaSokWTN01r3oshmddWvqovNqmqy9f3gB4EsVnd9u6r6y+pid2nq+vr6txRfcryReA0AADcM2Ql5nxQsdMrQUvkCXgEAwI1EZbWyyU6RxipbarjrlxwvAADgBsD7nuyzssMOvFUerpKWGpZ0xfEbAADIKLzXCVYrmKxgr1Oa4apgqYKTXva5AACAjBIaneC2gsnKA9gpzXCVdFXZUs8BACCjqExWcFh5ADtFGms4XA1dlfdTVuTzPmcAAJBRQqPjrTY02dBh5QHsFGms4XCVd9XQT1mR3W632+2eAgBAtuh0Ovxb5nW81TKT5R2WH8AyL+15q2Cs4XA1tFTeSTudTrvdbrfbJycn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weOab8/OBoYAAAAAElFTkSuQmCC" alt="" />
java 图形界面的更多相关文章
- Java图形界面学习---------简易登录界面
/** * @author Administrator * Java图形界面学习---------简易登录界面 * date:2015/10/31 */ import java.awt.BorderL ...
- Java 图形界面开发--图文并茂建立学生管理系统
(尊重劳动成果,转载请注明出处:http://blog.csdn.net/qq_25827845/article/details/50932501 冷血之心的博客) 图形用户界面(Graphics U ...
- Java图形界面GUI
Java图形界面GUI 设置窗体JFrame对象 package com.Aha.Best; import javax.swing.ImageIcon; import javax.swing.JFra ...
- java 图形界面 Socket编程
一.使用图形界面实现客户端服务器端的通信: 上代码: 服务器端代码: package cn.MyNET; import java.io.*; import java.net.*; import jav ...
- Java第5次实验提纲(Java图形界面编程)
1. Swing与NetBeans 使用NetBeans编写简单界面.见GUI实验参考文件中的0.第06次实验(图形程序设计.事件处理与Swing).doc 题目1: Swing用户界面组件与事件处理 ...
- Java第05次实验提纲(Java图形界面编程)
1. Swing与NetBeans 使用NetBeans编写简单界面.见GUI实验参考文件中的0.第06次实验(图形程序设计.事件处理与Swing).doc 题目1: Swing用户界面组件与事件处理 ...
- JAVA 图形界面开发基础详解
与C的win32一样,JAVA也有自己的图形界面开发,将在此篇博客中对基础部分进行讲解. 1.Java提供的图形界面类有哪些? Java提供了两套图形界面 (1)AWT组建(基础) AWT组件是jdk ...
- 【转】java图形界面设计(AWT)
[转自]http://blog.sina.com.cn/s/blog_616e189f0100ne1t.html 1. 基本的java Frame操作. Java的图形界面的类主要包括AW ...
- Java图形界面实战案例——实现打字母游戏
实现打字母的游戏 这次这个案例能够说是头几次所讲的内容的一个技术汇总,主要是 运用了几大块的知识.我们先来定义一下案例的背景:在一个300*400的窗口上.有10个随机产生的字母下落,在键盘上敲击字母 ...
- java图形界面设计
1. 基本的java Frame操作. Java的图形界面的类主要包括AWT和Swing.在AWT中图形元素的父类为Component. 继承关系如下:Component->Cont ...
随机推荐
- cmd 进入mysql
从cmd中进入MySQL的命令界面 1.开始中找出运行:输入cmd2.查找appserv所在盘,我的在D盘,所以接着输入:d:3.在d盘中查找mysql所在目录:cd appserv\mysql\bi ...
- php笔记(六)PHP类与对象之对象接口
接口的实现 <?php //interface 关键字用于定义一个接口 interface ICanEat{ //接口里面的方法不需要实现 public function eat($food); ...
- checkbox批量操作
hang=data.split("\1");//获取 查询返回的数据 处理数据 var str=""; for(var i =0;i<hang.lengt ...
- (repost)在ARM Linux内核中增加一个新的系统调用
实验平台内核版本为4.0-rc1,增加一仅仅打印Hello World的syscall,最后我们在用户空间swi验证 实验平台内核版本为4.0-rc1,增加的系统调用仅仅是简单打印一个Hello Wo ...
- Memcached内存存储
早就听说过Memcached独特的内存管理方式,写着篇文章的目的就是了解Memcached的内存管理,学习其源代码. 1.什么是Slab Allocator memcached默认情况下采用了名为Sl ...
- 移动app的一些心得
周末的时候闲着没事,看到了个开源的红旅动漫的APP,于是自己就拿下来写了下,整个网站作者也解析成了接口,所以就可以写成app了,作者写的是用mui开发的,可以通过hbuilder软件打开,进行查看源代 ...
- Centos7安装Docker 基于Dockerfile 搭建httpd运行环境
Centos7安装Docker 基于Dockerfile 搭建httpd运行环境 docker docker搭建 docker build 本文档完成目标内容如下 使用Docker搭建http服务器一 ...
- iOS开发下架在AppStore中销售的app
1.登陆开发者账号 2.选择itunes connect 选择我的app 3.选择要下架的app 4.价格与销售范围 5.销售范围 6.点击存储 //如果想要重新在AppStore中进行销售只需要选择 ...
- 【NOIP2007提高组】字符串展开
[题外话]这道题纯粹考验耐心,某些经常调程序调到摔键盘的人可以尝试 [题外话2]除了考耐心以外完全没有什么难点 [题外话3]也许会稍微恶心一点? [题外话4]其实我是在别人军训的时候滚来更博客的简直2 ...
- jquery操作属性 attr()和 prop()兼容性问题
jquery1.6中新加了一个方法prop(),一直没用过它,官方解释只有一句话:获取在匹配的元素集中的第一个元素的属性值. 大家都知道有的浏览器只要写disabled,checked就可以了,而有的 ...