首页 > 教程 >

小程序源码网java 微信小程序java开发

2022-03-12教程围观

简介求可以下载JAVA小程序+源代码的网站http://www.codefans.net/sort/list_5_1.shtmljava小程序源代码求一个JAVA小程序的源代码,要求如下大概是这个样子。------------------------------------------------------------------------------------------import java.awt.Graphics;import java.awt.Point;import java.awt.eve

  

求可以下载JAVA小程序+源代码的网站

求可以下载JAVA小程序+源代码的网站

http://www.codefans.net/sort/list_5_1.shtml

java小程序源代码

求一个JAVA小程序的源代码,要求如下

大概是这个样子。 ------------------------------------------------------------------------------------------import java.awt.Graphics;import java.awt.Point;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.MouseEvent;import java.awt.event.MouseListener;import java.util.Date;import java.util.Timer;import java.util.TimerTask;import javax.swing.JButton;import javax.swing.J ;import javax.swing.JPanel;public class DateCheck extends J implements ActionListener { private boolean isOval = true; public DateCheck() { setSize(567, 419); setResizable(false); setDefaultCloseOperation(EXIT_ON_CLOSE); setLocationRelativeTo(null); getContentPane().setLayout(null); JButton btnNewButton = new JButton("Oval"); btnNewButton.addActionListener(this); btnNewButton.setBounds(80, 10, 93, 23); getContentPane().add(btnNewButton); JButton btnNewButton_1 = new JButton("Rect"); btnNewButton_1.setBounds(203, 10, 93, 23); btnNewButton_1.addActionListener(this); getContentPane().add(btnNewButton_1); JPanel panel = new MyPanel(); panel.setBounds(12, 47, 537, 337); getContentPane().add(panel); new Timer().schele(new MyTimesk(), new Date(), 100); setVisible(true); } public static void main(String[] args) { new DateCheck(); } public void actionPerformed(ActionEvent event) { isOval = "Oval".equals(event.getActionCommand()); System.out.println(isOval); } class MyPanel extends JPanel implements MouseListener { Point point1 = null; Point point2 = null; // protected void paintComponent(Graphics g) { // super.paintComponent(g); // // } int click = 0; public MyPanel() { addMouseListener(this); } public void paint(Graphics g) { super.paint(g); Point p = this.getMousePosition(); if (p == null && click % 2 == 1) { return; } if (click % 2 == 0 && (point1 == null || point2 == null)) { return; } if (click % 2 == 0) { if (isOval) { int w = point2.x - point1.x; int h = point2.y - point1.y; int r = (int) Math.sqrt(w * w + h * h); g.drawOval(point1.x - r / 2, point1.y - r / 2, r + r / 2, r + r / 2); } else { g.drawRect(point1.x, point1.y, point2.x - point1.x, point2.y - point1.y); } return; } if (isOval) { if (click % 2 == 1) { int w = p.x - point1.x; int h = p.y - point1.y; int r = (int) Math.sqrt(w * w + h * h); g.drawOval(point1.x - r / 2, point1.y - r / 2, r + r / 2, r + r / 2); } } else { g.drawRect(point1.x, point1.y, p.x - point1.x, p.y - point1.y); } } public void mouseClicked(MouseEvent mouseevent) { click++; if (click % 2 == 1) { point1 = mouseevent.getPoint(); } else { point2 = mouseevent.getPoint(); } } public void mouseEntered(MouseEvent mouseevent) { } public void mouseExited(MouseEvent mouseevent) { } public void mousePressed(MouseEvent mouseevent) { } public void mouseReleased(MouseEvent mouseevent) { } } class MyTimesk extends TimerTask { public void run() { repaint(); } }}

下载链接:网站源码/小程序源码/网站模板下载

Tags: 程序源码 微信 程序 开发 java