导航:首页 > 源码编译 > java小程序源码

java小程序源码

发布时间:2022-01-20 16:56:30

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

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

Ⅱ 求一个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.JFrame;
import javax.swing.JPanel;
public class DateCheck extends JFrame 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();
}
}
}

Ⅲ JAVA小程序源码

不好意思,技术上帮不了你,不过可以给你提供域名或空间。
J1型(1000M,送独立IP、支持JSP、PHP,FTP管理,送500M SQL数据库)
国际顶级英文域名:60元(续费65元)
可咨询我们在线客服,享受优惠。我们已为25000多家用户提供了6年多优秀服务,更专业,更稳定。联系方式请点击我的用户名——用户资料。

Ⅳ java 小程序源代码

求素数,比较经典的,下面是代码及注释
================================================
public
class
Sushu
{
/**
*
判断一个数是不是素数
*
@param
a
被判断的数
*
@return
是素数返回真
*/
public
boolean
isSuhu(int
a){
boolean
isSushu=true;
//根据素数的性质判断一个数是否为素数
for(int
i=2;i<a;i++){
if(a%i==0){
isSushu=false;
break;
}
}
return
isSushu;
}
/**
*
判断连续若干个数中那些是素数
*
@param
start
起始数
*
@param
end
终止数
*/
public
void
selectSushu(int
start,int
end){
//判断一串数中那些为素数,并将结果打印出来
for(int
i=start;i<=end;i++){
if(isSuhu(i)){
System.out.println(i);
}
}
}
public
static
void
main(String
[]args){
//定义起始位置和终止位置
int
start=1;
int
end=100;
//声明变量
Sushu
s=new
Sushu();
//调用方法
s.selectSushu(start,
end);
}
}

Ⅳ 810分求一个JAVA 小程序的源码

...这个完全可以逆向汇编到这球来了。。真浪费积分 如果没人回答你呢。等于浪费额、
告诉你以后球问题的时候最好是5分然后对了给人家 加分。你这样浪费况且人家不返还给你 的积分的。。。
去找程序然后反汇编自己去看就好了

Ⅵ 急需一些java小程序代码

既然是新手,那给你两个小程序试试,程序的功能是一样的,实现思路不一样,多多研究
第一种思路,面向过程
import java.util.Scanner;

public class ATM {

public static void main(String[] args) {
int mima = 111111;
int jine;
int cishu;
Scanner input = new Scanner(System.in);
for (int i = 0; i < 3; i++) {
System.out.println("请输入密码。");

int mm = input.nextInt();

if (mm == mima) {
for (;;) {
System.out.println("请输入取款金额:");
int je = input.nextInt();
if (je > 0 && je <= 2000) {
System.out.println("操作成功,取款金额为" + je + "元");
System.out.println("是否继续取款?y/n");
String yn = input.next();
if (yn.equals("y") || yn.equals("Y")) {
continue;
} else if (yn.equals("n") || yn.equals("N")) {
return;
} else {
System.out.println("输入错误,异常终止。");
}

return;
} else if (je <= 0 || je > 2000) {
System.out.println("金额不合法。");
continue;
}
}

} else if (mm != mima) {
System.out.println("输入错误");
}
}
System.out.println("密码3次错误,异常终止。");
}

}
第二种思路,面向对象
import java.util.Scanner;
import java.util.concurrent.ConcurrentHashMap;

public class ATM2 {
Scanner input = new Scanner(System.in);

// 判断密码是否正确。(密码默认为111111)
void mima() {
System.out.println("请输入密码:");
int mm = input.nextInt();
if (mm == 111111) {
qukuai();
}
if (mm != 111111) {
for (int i = 0; i < 2; i++) {
System.out.println("输入错误,请重新输入");

if (mm == 111111) {
qukuai();
return;
}

}
System.out.println("3次错误,程序终止。");

}
}

// 开始取款
void qukuai() {
for (;;) {
System.out.println("请输入取款金额:");
int je = input.nextInt();
if (je > 0 && je <= 2000) {
System.out.println("取款成功,取款金额为" + je);
jixu();
return;
} else {
System.out.println("金额不合法.");
continue;
}
}
}

// 继续取款
void jixu() {
System.out.println("是否继续取款?y/n");
String yn = input.next();
if (yn.equals("y") || yn.equals("Y")) {
qukuai();
} else if (yn.equals("n") || yn.equals("N")) {
System.out.println("谢谢使用!");

} else {
System.out.println("输入错误,异常终止。");
}
}

// 程序入口
public static void main(String[] args) {
ATM2 s = new ATM2();
s.mima();
}
}

Ⅶ java小程序源代码

importjava.io.File;
importjava.io.FileInputStream;
importjava.io.FileOutputStream;
importjava.io.IOException;

publicclassTest3
{
publicstaticvoidmain(String[]args)throwsIOException
{
FileOutputStreamoutput=newFileOutputStream(newFile("set.ini"));
output.write(123);
output.close();
FileInputStreaminput=newFileInputStream(newFile("set.ini"));
System.out.println(input.read());
input.close();
}
}

Ⅷ java的一个小程序,求源码

你要懒得写的话,把数组转成list,我记得list有个现成的sort方法,直接给你排好序了,输出最后一个就行

Ⅸ 谁能提供一个java小程序代码

这就是最简单的了,有窗体,还有事件监听,实现的功能很多的
package Test;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;

public class AppletMouse extends JFrame implements CaretListener
{
JTextArea txt=new JTextArea();
AppletMouse()
{
super("JAVA计算文本字符函数测试");
this.setSize(200,200);
this.setLayout(null);
txt.setBounds(20,25,100,20);
txt.addCaretListener(this);
this.add(txt);
this.setVisible(true);
}
public static void main(String []args)
{
new AppletMouse();
}
public void caretUpdate(CaretEvent arg0)
{
this.setTitle("字节数:"+txt.getText().length());
}
}

Ⅹ 可用的java源代码小程序

package mym3;

import java.util.*;

public class cvb {
public static void main(String[] agse) {
int as1[] = new int[10];// 奇
int as2[] = new int[10];// 偶
int jj= 0,ii=0;
for (int i = 1; i <20; i++) {
int random = (int)(Math.random()*100+1
);// 0<math.random()<1 产生这样的随机 算。因为0不是 奇 偶所以加一了
if (random % 2 == 0) {
as2[ii] = random;
ii++;
} else {
as1[jj] = random;
jj++;
}
}
Arrays.sort(as2);
System.out.println("偶数从小到大的排序是:");
for (int j = 0; j < as2.length; j++) {
System.out.println(as2[j]);
}
Arrays.sort(as1);
System.out.println("奇数从小到大的排序是:");
for (int j = 0; j < as1.length; j++) {
System.out.println(as1[j]);
}
}
}

阅读全文

与java小程序源码相关的资料

热点内容
工作三年的大专程序员 浏览:726
java毕业设计文献 浏览:140
筹码集中度指标源码 浏览:477
listsortjava 浏览:183
plc闪光电路编程实例 浏览:297
socket编程试题 浏览:203
华为的服务器怎么设置从光驱启动 浏览:867
程序员真的累吗 浏览:325
学信网app为什么刷脸不了 浏览:872
天蝎vs程序员 浏览:992
单片机下载口叫什么 浏览:188
程序员的道 浏览:926
云服务器不实名违法吗 浏览:558
怎样查看文件夹图片是否重复 浏览:995
文件怎么导成pdf文件 浏览:808
打开sql表的命令 浏览:103
安卓手机如何面部支付 浏览:38
天元数学app为什么登录不上去 浏览:824
明日之后为什么有些服务器是四个字 浏览:104
安卓系统l1是什么意思 浏览:26