导航:首页 > 源码编译 > java小程序直播系统源码

java小程序直播系统源码

发布时间:2022-07-25 19:45:36

Ⅰ 求一java编写的小程序源码,能够运行会追加!

package org.nightrunner..;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class QuestionOne {
/**
* 一组序列由AGCT四个字符组成,例如:AGAAGGAAAAAAGAGGAAGAGGAGAT
* ,要求编一小程序
* 例如:输入一个字符串AAAG,从头开始如果这个字符串在上面的序列,输出:查找成功,并记录位置,没有上面字符串则输出:无法找到,退出
*
* @param args
*/
public static void main(String[] args) {
String data = "AGAAGGAAAAAAGAGGAAGAGGAGAT";
System.out.println("请输入一个字符串,回车结束");
BufferedReader reader = new BufferedReader(new InputStreamReader(
System.in));
String line = null;
try {
line = reader.readLine();
} catch (IOException e) {
e.printStackTrace();
}
int pos = data.indexOf(line);
if (pos == -1) {
System.out.println("无法找到 退出");
} else {
System.out.println("找到了,在第" + (pos + 1) + "个字符");
}
}
}

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

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

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

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

Ⅳ 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);
}
}

Ⅳ 求java小程序源代码 在线等 急急急!!!

下面是俄罗斯方块游戏源代码
还没完,这代码太长了,我用我另一个号再粘上
import javax.swing.*;
import javax.swing.JOptionPane;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
import java.awt.*;
import java.awt.event.*;
/**
* 游戏主类,继承自JFrame类,负责游戏的全局控制。
* 内含
* 1, 一个GameCanvas画布类的实例引用,
* 2, 一个保存当前活动块(ErsBlock)实例的引用,
* 3, 一个保存当前控制面板(ControlPanel)实例的引用;*/
public class ErsBlocksGame extends JFrame {
/**
* 每填满一行计多少分*/
public final static int PER_LINE_SCORE = 100;
/**
* 积多少分以后能升级*/
public final static int PER_LEVEL_SCORE = PER_LINE_SCORE * 20;
/**
* 最大级数是10级*/
public final static int MAX_LEVEL = 10;
/**
* 默认级数是5*/
public final static int DEFAULT_LEVEL = 5;

private GameCanvas canvas;
private ErsBlock block;
private boolean playing = false;
private ControlPanel ctrlPanel;

private JMenuBar bar = new JMenuBar();
private JMenu
mGame = new JMenu("游戏设置"),
mControl = new JMenu("游戏控制"),
mWindowStyle = new JMenu("窗口风格");
private JMenuItem
miNewGame = new JMenuItem("新游戏"),
miSetBlockColor = new JMenuItem("设置颜色 ..."),
miSetBackColor = new JMenuItem("设置底色 ..."),
miTurnHarder = new JMenuItem("提升等级"),
miTurnEasier = new JMenuItem("调底等级"),
miExit = new JMenuItem("退出"),

miPlay = new JMenuItem("开始游戏"),
miPause = new JMenuItem("暂停"),
miResume = new JMenuItem("继续");

private JCheckBoxMenuItem
miAsWindows = new JCheckBoxMenuItem("风格1"),
miAsMotif = new JCheckBoxMenuItem("风格2"),
miAsMetal = new JCheckBoxMenuItem("风格3", true);

/**
* 主游戏类的构造函数
* @param title String,窗口标题*/
public ErsBlocksGame(String title) {
super(title);
//this.setTitle("lskdf");
setSize(315, 392);
Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
//获得屏幕的大小

setLocation((scrSize.width - getSize().width) / 2,
(scrSize.height - getSize().height) / 2);

createMenu();

Container container = getContentPane();
container.setLayout(new BorderLayout(6, 0));

canvas = new GameCanvas(20, 12);
ctrlPanel = new ControlPanel(this);

container.add(canvas, BorderLayout.CENTER);
container.add(ctrlPanel, BorderLayout.EAST);

addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
JOptionPane about=new JOptionPane();
stopGame();
System.exit(0);
}
});
addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent ce) {
canvas.fanning();
}
});
show();
canvas.fanning();
}
// 游戏“复位”
public void reset() {
ctrlPanel.reset();
canvas.reset();
}
/**
* 判断游戏是否还在进行
* @return boolean, true-还在运行,false-已经停止*/
public boolean isPlaying() {
return playing;
}
/**
* 得到当前活动的块
* @return ErsBlock, 当前活动块的引用*/
public ErsBlock getCurBlock() {
return block;
}
/**
* 得到当前画布
* @return GameCanvas, 当前画布的引用 */
public GameCanvas getCanvas() {
return canvas;
}

/**
* 开始游戏*/
public void playGame() {
play();
ctrlPanel.setPlayButtonEnable(false);
miPlay.setEnabled(false);
ctrlPanel.requestFocus();
}
/**
* 游戏暂停*/
public void pauseGame() {
if (block != null) block.pauseMove();
ctrlPanel.setPauseButtonLabel(false);
miPause.setEnabled(false);
miResume.setEnabled(true);
}
/**
* 让暂停中的游戏继续*/
public void resumeGame() {
if (block != null) block.resumeMove();
ctrlPanel.setPauseButtonLabel(true);
miPause.setEnabled(true);
miResume.setEnabled(false);
ctrlPanel.requestFocus();
}
/**
* 用户停止游戏 */
public void stopGame() {
playing = false;
if (block != null) block.stopMove();
miPlay.setEnabled(true);
miPause.setEnabled(true);
miResume.setEnabled(false);
ctrlPanel.setPlayButtonEnable(true);
ctrlPanel.setPauseButtonLabel(true);
}
/**
* 得到当前游戏者设置的游戏难度
* @return int, 游戏难度1-MAX_LEVEL*/
public int getLevel() {
return ctrlPanel.getLevel();
}
/**
* 让用户设置游戏难度
* @param level int, 游戏难度1-MAX_LEVEL*/
public void setLevel(int level) {
if (level < 11 && level > 0) ctrlPanel.setLevel(level);
}
/**
* 得到游戏积分
* @return int, 积分。*/
public int getScore() {
if (canvas != null) return canvas.getScore();
return 0;
}
/**
* 得到自上次升级以来的游戏积分,升级以后,此积分清零
* @return int, 积分。*/
public int getScoreForLevelUpdate() {
if (canvas != null) return canvas.getScoreForLevelUpdate();
return 0;
}
/**
* 当分数累计到一定的数量时,升一次级
* @return boolean, ture-update successufl, false-update fail
*/
public boolean levelUpdate() {
int curLevel = getLevel();
if (curLevel < MAX_LEVEL) {
setLevel(curLevel + 1);
canvas.resetScoreForLevelUpdate();
return true;
}
return false;
}
/**
* 游戏开始*/
private void play() {
reset();
playing = true;
Thread thread = new Thread(new Game());
thread.start();
}

/**
* 报告游戏结束了*/
private void reportGameOver() {
JOptionPane.showMessageDialog(this, "游戏结束!");
}
/**
* 建立并设置窗口菜单 */
private void createMenu() {
bar.add(mGame);
bar.add(mControl);
bar.add(mWindowStyle);

mGame.add(miNewGame);
mGame.addSeparator();
mGame.add(miSetBlockColor);
mGame.add(miSetBackColor);
mGame.addSeparator();
mGame.add(miTurnHarder);
mGame.add(miTurnEasier);
mGame.addSeparator();
mGame.add(miExit);

mControl.add(miPlay);
mControl.add(miPause);
mControl.add(miResume);

mWindowStyle.add(miAsWindows);
mWindowStyle.add(miAsMotif);
mWindowStyle.add(miAsMetal);

setJMenuBar(bar);

miPause.setAccelerator(
KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_MASK));
miResume.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));

miNewGame.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
stopGame();
reset();
setLevel(DEFAULT_LEVEL);
}
});
miSetBlockColor.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
Color newFrontColor =
JColorChooser.showDialog(ErsBlocksGame.this,
"设置积木颜色", canvas.getBlockColor());
if (newFrontColor != null)
canvas.setBlockColor(newFrontColor);
}
});
miSetBackColor.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
Color newBackColor =
JColorChooser.showDialog(ErsBlocksGame.this,
"设置底版颜色", canvas.getBackgroundColor());
if (newBackColor != null)
canvas.setBackgroundColor(newBackColor);
}
});
miTurnHarder.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
int curLevel = getLevel();
if (curLevel < MAX_LEVEL) setLevel(curLevel + 1);
}
});
miTurnEasier.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
int curLevel = getLevel();
if (curLevel > 1) setLevel(curLevel - 1);
}
});
miExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
System.exit(0);
}
});
miPlay.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
playGame();
}
});
miPause.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
pauseGame();
}
});
miResume.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
resumeGame();
}
});

miAsWindows.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
String plaf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
setWindowStyle(plaf);
canvas.fanning();
ctrlPanel.fanning();
miAsWindows.setState(true);
miAsMetal.setState(false);
miAsMotif.setState(false);
}
});
miAsMotif.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
String plaf = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
setWindowStyle(plaf);
canvas.fanning();
ctrlPanel.fanning();
miAsWindows.setState(false);
miAsMetal.setState(false);
miAsMotif.setState(true);
}
});
miAsMetal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
String plaf = "javax.swing.plaf.metal.MetalLookAndFeel";
setWindowStyle(plaf);
canvas.fanning();
ctrlPanel.fanning();
miAsWindows.setState(false);
miAsMetal.setState(true);
miAsMotif.setState(false);
}
});
}
/**
* 根据字串设置窗口外观
* @param plaf String, 窗口外观的描述
*/
private void setWindowStyle(String plaf) {
try {
UIManager.setLookAndFeel(plaf);
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception e) {
}
}
/**
* 一轮游戏过程,实现了Runnable接口
* 一轮游戏是一个大循环,在这个循环中,每隔100毫秒,
* 检查游戏中的当前块是否已经到底了,如果没有,
* 就继续等待。如果到底了,就看有没有全填满的行,
* 如果有就删除它,并为游戏者加分,同时随机产生一个
* 新的当前块,让它自动下落。
* 当新产生一个块时,先检查画布最顶上的一行是否已经
* 被占了,如果是,可以判断Game Over了。*/
private class Game implements Runnable {
public void run() {
//产生新方快
int col = (int) (Math.random() * (canvas.getCols() - 3)),
style = ErsBlock.STYLES[(int) (Math.random() * 7)][(int) (Math.random() * 4)];
while (playing) {
if (block != null) { //第一次循环时,block为空
if (block.isAlive()) {
try {
Thread.currentThread().sleep(100);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
continue;
}
}
checkFullLine(); //检查是否有全填满的行
if (isGameOver()) { //检查游戏是否应该结束了
miPlay.setEnabled(true);
miPause.setEnabled(true);
miResume.setEnabled(false);
ctrlPanel.setPlayButtonEnable(true);
ctrlPanel.setPauseButtonLabel(true);

reportGameOver();
return;
}
block = new ErsBlock(style, -1, col, getLevel(), canvas);
block.start();

col = (int) (Math.random() * (canvas.getCols() - 3));
style = ErsBlock.STYLES[(int) (Math.random() * 7)][(int) (Math.random() * 4)];

ctrlPanel.setTipStyle(style);
}
}
/**
* 检查画布中是否有全填满的行,如果有就删除之*/
public void checkFullLine() {
for (int i = 0; i < canvas.getRows(); i++) {
int row = -1;
boolean fullLineColorBox = true;
for (int j = 0; j < canvas.getCols(); j++) {
if (!canvas.getBox(i, j).isColorBox()) {
fullLineColorBox = false;
break;
}
}
if (fullLineColorBox) {
row = i--;
canvas.removeLine(row);
}
}
}

/**
* 根据最顶行是否被占,判断游戏是否已经结束了。
* @return boolean, true-游戏结束了,false-游戏未结束*/
private boolean isGameOver() {
for (int i = 0; i < canvas.getCols(); i++) {
ErsBox box = canvas.getBox(0, i);
if (box.isColorBox()) return true;
}
return false;
}
}

Ⅵ 【求助】哪位朋友提供个Java小程序的源代码谢谢!

import java.applet.Applet;
import java.awt.*;
import java.io.*;
import java.net.*;

public class TicTacToeclient extends Applet implements Runnable
{//class1
TextField id;
Panel boardpanel, panel2;
Square board[][],currentsquare;
Socket connection;
DataInputStream input;
DataOutputStream output;
Thread outputThread;
char mymark;
TextArea display;
public void init()
{
setLayout(new BorderLayout());
display=new TextArea(4,30);
display.setEditable(false);
add("South",display);
boardpanel=new Panel();
boardpanel.setBackground(Color.cyan);
boardpanel.setLayout(new GridLayout(3,3,0,0));
board=new Square[3][3];
for(int row=0; row<board.length; row++)
for(int col=0; col<board[row].length; col++)
{
board[row][col]=new Square();
repaint();
boardpanel.add(board[row][col]);
}
id=new TextField();
id.setEditable(false);
add("North",id);
panel2=new Panel();
panel2.add(boardpanel);
add("Center",panel2);
}
//////////end
public void start()
{
try{
connection=new Socket(InetAddress.getLocalHost(),5000);
input=new DataInputStream(connection.getInputStream());
output=new DataOutputStream(connection.getOutputStream());
}
catch(IOException e){
//e.printStackTrace();
}
outputThread=new Thread(this);
outputThread.start();
}
//////////end
public boolean mouseUP(Event e, int x, int y)
{
for( int row=0; row<board.length; row++)
{
for(int col=0; col<board[row].length; col++)
try{
if(e.target==board[row][col])
{
currentsquare=board[row][col];
output.writeInt(row*3+col);
}
}
catch(IOException ie){
//ie.printStackTrace();
}
}
return true;
}
//////////end
public void run()
{
try{
mymark=input.readChar();
id.setText("欢迎您玩家\""+mymark+"\"");
}
catch(IOException e){
e.printStackTrace();
}
while(true)
{
try{
String s=input.readUTF();
processMessage(s);
}
catch(IOException e){
//e.printStackTrace();
}
}
}
//////////end
public void processMessage(String s)
{
if(s.equals("Valid move"))
{
display.appendText("Valid move,please wait\n");
currentsquare.setMark(mymark);
currentsquare.repaint();
}
else if(s.equals("Invalid move,tryagain"))
{
display.appendText(s+"\n");
}
else if(s.equals("Opponent moved"))
{
try{
int loc=input.readInt();
done:
for(int row=0; row<board.length; row++)
for(int col=0; col<board[row].length; col++)
if(row*3+col==loc)
{
board[row][col].setMark(mymark=='x' ? 'o':'x');
board[row][col].repaint();
break done;
}
display.appendText("Opponent moved.Yourturn\n");
}
catch(IOException e){
e.printStackTrace();
}
}
else
{
display.appendText(s+"\n");
}
}

}//class1.end
//////////////////////////////////////
class Square extends Canvas
{//class2
char mark;
public Square()
{
resize(30,30);
}
//////////end
public void setMark(char c)
{
mark=c;
}
//////////end
public void paint(Graphics g)
{
g.drawRect(0,0,29,29);
g.drawString(String.valueOf(mark),11,20);
}

}//class2.end
//<applet code="TicTacToeclient.class" width=275 height=300></applet>
服务器端:
import java.awt.*;
import java.net.*;
import java.io.*;
public class TicTacToeServer extends Frame
{//class1
private byte board[];
private boolean xMove;
private TextArea output;
private Player players[];
private ServerSocket server;
private int numberofplayers;
private int currentplayer;
public TicTacToeServer()
{
super("三子棋服务器");
board=new byte[9];
xMove=true;
players=new Player[2];
currentplayer=0;
try{
server=new ServerSocket(5000,2);
}
catch(IOException e){
// e.printStackrace();
System.exit(1);
}

output=new TextArea();
output.setBackground(Color.yellow);
add("Center",output);
resize(300,300);
show();
Toolkit tp=Toolkit.getDefaultToolkit();
Image logo=tp.getImage("1.gif");
setIconImage(logo);
setResizable(false);
}
//////////end
public void execute()
{
for(int i=0; i<players.length; i++)
{
try{
players[i]=new Player(server.accept(), this, i);
players[i].start();
++numberofplayers;
}
catch(IOException e){
//e.printStackrace();
System.exit(1);
}
}
}
//////////end
public int getNumberOfplayers()
{
return numberofplayers;
}
//////////end
public void display(String s)
{
output.appendText(s+"\n");
}
/////////end
public boolean validMove(int loc,int player)
{
boolean moveDone=false;
while(player!=currentplayer)
{
try{
wait();
}
catch(InterruptedException e){//not
}
}
if(isOccupied(loc))
{
board[loc]=(byte)(currentplayer==0 ? 'x' : 'o');
currentplayer=++currentplayer%2;
players[currentplayer].otherplayerMoved(loc);
notify();
return true;
}
else
return false;
}
//////////end
public boolean isOccupied(int loc)
{
if(board[loc]=='x'||board[loc]=='o')
return true;
else
return false;
}
//////////end
public boolean handleEvent(Event event)
{
if(event.id==Event.WINDOW_DESTROY)
{
hide();
dispose();
for(int i=0; i<players.length; i++)
players[i].stop();
System.exit(0);

}
return super.handleEvent(event);
}
//////////end
public boolean gameOver()
{
return false;
}
//////////end
public static void main(String args[])
{
TicTacToeServer game=new TicTacToeServer();
game.execute();
}
}//class1.end
////////////////////////////////////////////////next.class
class Player extends Thread
{//class2
Socket connection;
DataInputStream input;
DataOutputStream output;
TicTacToeServer control;
int number;
char mark;
public Player(Socket s, TicTacToeServer t,int num)
{
mark=(num==0 ? 'x' : 'o');
connection=s;
try{
input=new DataInputStream(connection.getInputStream());
output=new DataOutputStream(connection.getOutputStream());
}
catch(IOException e){
//e.printStackTrale();
System.exit(1);
}
control=t;
number=num;
}
//////////end
public void otherplayerMoved(int loc)
{
try{
output.writeUTF("Opponet moved");
output.writeInt(loc);
}
catch(IOException e){//not
}
}
//////////end
public void run()
{
boolean done=false;
try{
control.display("玩家"+(number==0 ? 'x' : 'o')+"以登陆!");
output.writeChar(mark);
output.writeUTF("玩家"+(number==0 ? "x 以登陆!\n" : "o 以登陆,请等待!\n"));
if(control.getNumberOfplayers()<2)
{
output.writeUTF("请您等待另一个玩家登陆!");
while(control.getNumberOfplayers()<2);
output.writeUTF("另一个玩家已经登陆!现在您可以走棋了!");
}
while(!done)
{
int location=input.readInt();
if(control.validMove(location,number))
{
control.display("loc"+location);
output.writeUTF("Valic move.");
}
else
output.writeUTF("INvalid move,tryagain");
if(control.gameOver())
{
done=true;
}
connection.close();
}

}
catch(IOException e){
e.printStackTrace();
System.exit(1);
}
}
}//class.end

Ⅶ 求一套java开发PC端直播平台网站的源码

https://github.com/daniulive/SmarterStreaming
国内外为数不多不依赖开源框
架、不依赖CDN实现秒开、公网毫秒级延迟、跨平台(windows/android/iOS)rtmp推流、rtmp/rtsp直播播放利
器"SmarterStreaming",系daniulive(大牛直播)出品的跨平台视频采集、直播SDK(支持rtmp推流/rtmp播放
/rtsp播放,如windows推流(windows pusher)/android推流(android pusher)/iOS推流(iOS
pusher)/windows播放器(windows player)/android播放器(android player)/iOS播放器(iOS
player)),也许是最靠谱的视频直播推流、播放SDK之一,助您轻松实现类似于花椒、映客、斗鱼手机直播推送与播放。

Ⅷ java小程序源代码,简单点的,100多行,谁有啊

// My car shop.java

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;
import javax.swing.border.*;

public class carshop extends JFrame
{
// JPanel to hold all pictures
private JPanel windowJPanel;
private String[] cars = { "","阿斯顿马丁", "美洲虎", "凯迪拉克",
"罗孚", "劳斯莱斯","别克"};
private int[] jiage = { 0,150000, 260000, 230000,
140000, 290000, 150000};
// JLabels for first snack shown
private JLabel oneJLabel;
private JLabel oneIconJLabel;

// JLabels for second snack shown
private JLabel twoJLabel;
private JLabel twoIconJLabel;

// JLabels for third snack shown
private JLabel threeJLabel;
private JLabel threeIconJLabel;

// JLabels for fourth snack shown
private JLabel fourJLabel;
private JLabel fourIconJLabel;

// JLabels for fifth snack shown
private JLabel fiveJLabel;
private JLabel fiveIconJLabel;

// JLabels for sixth snack shown
private JLabel sixJLabel;
private JLabel sixIconJLabel;

// JTextField for displaying snack price
private JTextArea displayJTextArea;

// JLabel and JTextField for user input
private JLabel inputJLabel;
private JComboBox selectCountryJComboBox;

private JLabel inputJLabel2;
private JTextField inputJTextField2;

// JButton to enter user input
private JButton enterJButton;

//JButton to clear the components
private JButton clearJButton;

// no-argument constructor
public carshop()
{
createUserInterface();
}

// create and position GUI components; register event handlers
private void createUserInterface()
{
// get content pane for attaching GUI components
Container contentPane = getContentPane();

// enable explicit positioning of GUI components
contentPane.setLayout( null );

// set up windowJPanel
windowJPanel = new JPanel();
windowJPanel.setBounds( 10, 20, 340, 200 );
windowJPanel.setBorder( new LineBorder( Color.BLACK ) );
windowJPanel.setLayout( null );
contentPane.add( windowJPanel );

// set up oneIconJLabel
oneIconJLabel = new JLabel();
oneIconJLabel.setBounds( 10, 20, 100, 65 );
oneIconJLabel.setIcon( new ImageIcon( "images/阿斯顿马丁.jpg" ) );
windowJPanel.add( oneIconJLabel );

// set up oneJLabel
oneJLabel = new JLabel();
oneJLabel.setBounds( 10, 60, 100, 70 );
oneJLabel.setText( "阿斯顿马丁" );
oneJLabel.setHorizontalAlignment( JLabel.CENTER );
windowJPanel.add( oneJLabel );

// set up twoIconJLabel
twoIconJLabel = new JLabel();
twoIconJLabel.setBounds( 120, 20, 100, 65 );
twoIconJLabel.setIcon( new ImageIcon( "images/美洲虎.jpg" ) );
windowJPanel.add( twoIconJLabel );

// set up twoJLabel
twoJLabel = new JLabel();
twoJLabel.setBounds( 110, 60, 100, 70 );
twoJLabel.setText( "美洲虎" );
twoJLabel.setHorizontalAlignment( JLabel.CENTER );
windowJPanel.add( twoJLabel );

// set up threeIconJLabel
threeIconJLabel = new JLabel();
threeIconJLabel.setBounds( 230, 20, 100, 65 );
threeIconJLabel.setIcon( new ImageIcon(
"images/凯迪拉克.jpg" ) );
windowJPanel.add( threeIconJLabel );

// set up threeJLabel
threeJLabel = new JLabel();
threeJLabel.setBounds( 230, 60, 100, 70);
threeJLabel.setText( "凯迪拉克" );
threeJLabel.setHorizontalAlignment( JLabel.CENTER );
windowJPanel.add( threeJLabel );

// set up fourIconJLabel
fourIconJLabel = new JLabel();
fourIconJLabel.setBounds( 10, 100, 100, 65 );
fourIconJLabel.setIcon( new ImageIcon( "images/罗孚.jpg" ) );
windowJPanel.add( fourIconJLabel );

// set up fourJLabel
fourJLabel = new JLabel();
fourJLabel.setBounds( 10, 150, 50, 70 );
fourJLabel.setText( "罗孚" );
fourJLabel.setHorizontalAlignment( JLabel.CENTER );
windowJPanel.add( fourJLabel );

// set up fiveIconJLabel
fiveIconJLabel = new JLabel();
fiveIconJLabel.setBounds( 120, 100, 100, 65 );
fiveIconJLabel.setIcon( new ImageIcon(
"images/劳斯莱斯.jpg" ) );
windowJPanel.add( fiveIconJLabel );

// set up fiveJLabel
fiveJLabel = new JLabel();
fiveJLabel.setBounds( 110, 150, 100, 70 );
fiveJLabel.setText( "劳斯莱斯" );
fiveJLabel.setHorizontalAlignment( JLabel.CENTER );
windowJPanel.add( fiveJLabel );

// set up sixIconJLabel
sixIconJLabel = new JLabel();
sixIconJLabel.setBounds( 230, 100, 100, 65 );
sixIconJLabel.setIcon( new ImageIcon( "images/别克.jpg" ) );
windowJPanel.add( sixIconJLabel );

// set up sixJLabel
sixJLabel = new JLabel();
sixJLabel.setBounds( 230, 150, 100, 70 );
sixJLabel.setText( "别克" );
sixJLabel.setHorizontalAlignment( JLabel.CENTER );
windowJPanel.add( sixJLabel );

// set up enterJButton
enterJButton = new JButton();
enterJButton.setBounds( 390, 160, 135, 30 );
enterJButton.setText( "Enter" );
contentPane.add( enterJButton );
enterJButton.addActionListener(

new ActionListener() // anonymous inner class
{
// event handler called when enterJButton is clicked
public void actionPerformed( ActionEvent event )
{
enterJButtonActionPerformed( event );
}

} // end anonymous inner class

); // end call to addActionListener

// set up clearJButton
clearJButton = new JButton();
clearJButton.setBounds( 390, 200, 135, 30 );
clearJButton.setText( "Clear" );

contentPane.add( clearJButton );

// set up inputJLabel

inputJLabel = new JLabel();
inputJLabel.setBounds( 390, 25, 135, 25 );
inputJLabel.setText( "Please make selection:" );
contentPane.add( inputJLabel );

selectCountryJComboBox = new JComboBox( cars );
selectCountryJComboBox.setBounds( 390, 50, 135, 21 );
selectCountryJComboBox.setMaximumRowCount( 3 );
contentPane.add( selectCountryJComboBox );
// set up inputJTextField

inputJLabel2 = new JLabel();
inputJLabel2.setBounds( 390, 80, 150, 20 );
inputJLabel2.setText( "Input the Numble:" );
contentPane.add( inputJLabel2 );

// set up inputJTextField
inputJTextField2 = new JTextField();
inputJTextField2.setBounds( 390, 100, 135, 25 );
inputJTextField2.setHorizontalAlignment( JTextField.RIGHT );
contentPane.add( inputJTextField2 );

clearJButton.addActionListener(

new ActionListener() // anonymous inner class
{
// event handler called when clearJButton is clicked
public void actionPerformed( ActionEvent event )
{
clearJButtonActionPerformed( event );
}

} // end anonymous inner class
);

// set up displayJTextField
displayJTextArea = new JTextArea();
displayJTextArea.setBounds( 10, 237,515, 70 );
displayJTextArea.setEditable( false );
contentPane.add( displayJTextArea );
// set properties of application's window
setTitle( "My car Shop" ); // set title bar string
setSize( 550, 360 ); // set window size
setVisible( true ); // display window

} // end method createUserInterface

private void clearJButtonActionPerformed( ActionEvent event )
{
// clear the JTextFields
inputJTextField2.setText( "" );
displayJTextArea.setText("");

} // end method clearJButtonActionPerformed

private void enterJButtonActionPerformed( ActionEvent event )
{
double z;
double c;
int x;
int y;
x=selectCountryJComboBox.getSelectedIndex();
y=Integer.parseInt(inputJTextField2.getText());
double discountRate;
int amount = Integer.parseInt( inputJTextField2.getText());
switch (amount/5)
{
case 0:
discountRate = 0;
break;

case 1:
discountRate = 1;
break;

case 2:
discountRate = 2;
break;
case 3:
discountRate = 3;
break;

default:
discountRate = 4;

} // end switch statement
c=1-discountRate/100;
z=jiage[x]*y*c;
displayJTextArea.append("你选择的是:"+cars[x]+";"+
"它的单价是:"+jiage[x]+";" +"你购买该产品的数量是:"+y+"," +"\n"+"该数量的折扣是:"
+discountRate + " %"+";"+"本次消费的总价格是:"+z+"元"+"!"+"\n");

}
public static void main( String args[] )
{
carshop application = new carshop();
application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

} // end method main

} // end class carshop

Ⅸ 求一个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小程序源代码

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小程序直播系统源码相关的资料

热点内容
方舟手机版怎么创建自己的服务器 浏览:426
阿里云服务器在线扩容磁盘 浏览:58
Python中集合中可以是列表吗 浏览:81
阶梯轴数控编程 浏览:692
php数组反向 浏览:999
程序员进化学习方法 浏览:244
医学认可的解压方式 浏览:669
方舟买个服务器怎么用 浏览:701
android中级开发 浏览:727
空调压缩机生产流程 浏览:530
android方向切换 浏览:144
linux恢复环境变量 浏览:820
课堂培训在app上哪里计时 浏览:814
java的键盘录入 浏览:36
反编译支付成功代码 浏览:377
创维冰箱是什么压缩机 浏览:540
北京市计算机软件怎么加密 浏览:743
python函数可变参数语言 浏览:328
柱加密区箍筋间距8d 浏览:502
简单程序员小说 浏览:696