導航:首頁 > 源碼編譯 > 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小程序源碼相關的資料

熱點內容
程序員真的累嗎 瀏覽:323
學信網app為什麼刷臉不了 瀏覽:871
天蠍vs程序員 瀏覽:991
單片機下載口叫什麼 瀏覽:186
程序員的道 瀏覽:924
雲伺服器不實名違法嗎 瀏覽:556
怎樣查看文件夾圖片是否重復 瀏覽:993
文件怎麼導成pdf文件 瀏覽:805
打開sql表的命令 瀏覽:101
安卓手機如何面部支付 瀏覽:37
天元數學app為什麼登錄不上去 瀏覽:822
明日之後為什麼有些伺服器是四個字 瀏覽:102
安卓系統l1是什麼意思 瀏覽:24
伺服器一直崩應該用什麼指令 瀏覽:923
cm202貼片機編程 瀏覽:729
php構造函數帶參數 瀏覽:178
解壓電波歌曲大全 瀏覽:345
為啥文件夾移到桌面成word了 瀏覽:859
命令符的安全模式是哪個鍵 瀏覽:760
編程中學 瀏覽:957