真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

大一java代碼題 java代碼題目和答案

Java大一的題目求大神幫忙看看怎么寫TAT求源代碼

哈哈~網(wǎng)上很多哈,GUI我也不會(huì),現(xiàn)學(xué)現(xiàn)賣一個(gè)

目前創(chuàng)新互聯(lián)已為1000多家的企業(yè)提供了網(wǎng)站建設(shè)、域名、雅安服務(wù)器托管、網(wǎng)站托管運(yùn)營、企業(yè)網(wǎng)站設(shè)計(jì)、扎賚諾爾網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

package swing;

import javafx.embed.swing.JFXPanel;

import javax.swing.*;

import java.awt.*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.text.DateFormat;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Date;

/**

* @author wenxy

* @create 2020-05-01

*/

public class JavaFxDate {

public static void main(String[] args) {

// 創(chuàng)建 JFrame 實(shí)例

JFrame frame = new JFrame();

// Setting the width and height of frame

frame.setSize(310, 180);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

/* 創(chuàng)建面板,這個(gè)類似于 HTML 的 div 標(biāo)簽

* 我們可以創(chuàng)建多個(gè)面板并在 JFrame 中指定位置

* 面板中我們可以添加文本字段,按鈕及其他組件。

*/

JPanel panel = new JPanel();

// 添加面板

frame.add(panel);

/*

* 調(diào)用用戶定義的方法并添加組件到面板

*/

placeComponents(panel);

// 設(shè)置界面可見

frame.setVisible(true);

}

private static void placeComponents(JPanel panel) {

/* 布局部分我們這邊不多做介紹

* 這邊設(shè)置布局為 null

*/

panel.setLayout(null);

// 創(chuàng)建 JLabel

JLabel userLabel = new JLabel("請(qǐng)輸入日期字符串");

userLabel.setBounds(5, 5, 300, 25);

panel.add(userLabel);

/*

* 創(chuàng)建文本域用于用戶輸入

*/

JTextField userText = new JTextField(20);

userText.setBounds(5, 40, 200, 25);

panel.add(userText);

// 創(chuàng)建 JLabel

JLabel showLable = new JLabel();

showLable.setBounds(5, 70, 300, 25);

panel.add(showLable);

// 創(chuàng)建登錄按鈕

JButton loginButton = new JButton("轉(zhuǎn)換");

loginButton.setBounds(180, 40, 100, 25);

loginButton.addActionListener(new ActionListener() {

DateFormat input = new SimpleDateFormat("yyyy-MM-dd");

DateFormat output = new SimpleDateFormat("yyyy年MM月dd日");

{

input.setLenient(false); ? ?// 設(shè)置嚴(yán)格按格式匹配

output.setLenient(false);

}

@Override

public void actionPerformed(ActionEvent actionEvent) {

try {

Date date = convert(userText.getText());

showLable.setText("成功:" + output.format(date));

showLable.setForeground(Color.GREEN);

} catch (WrongDateException e) {

showLable.setText(e.getMessage());

showLable.setForeground(Color.RED);

}

}

private Date convert(String text) throws WrongDateException {

try {

return input.parse(text);

} catch (ParseException e) {

throw new WrongDateException(text);

}

}

});

panel.add(loginButton);

}

static class WrongDateException extends Exception {

WrongDateException(String s) {

super(s + "不是合法的日期字符串");

}

}

}

大一編程入門java,這道題怎么做呢?

Employee .java

public class Employee {

private int empId;

private String empName;

private String empsex;

public int getEmpId() {

return empId;

}

public void setEmpId(int empId) {

this.empId = empId;

}

public String getEmpName() {

return empName;

}

public void setEmpName(String empName) {

this.empName = empName;

}

public String getEmpsex() {

return empsex;

}

public void setEmpsex(String empsex) {

this.empsex = empsex;

}

}

PartTimeEmployee.java

public class PartTimeEmployee extends Employee{

private double hourlyPay;

public double getHourlyPay() {

return hourlyPay;

}

public void setHourlyPay(double hourlyPay) {

this.hourlyPay = hourlyPay;

}

}

測試類Test.java

public class Test{

public static void main(String[] args) {

PartTimeEmployee pe=new PartTimeEmployee();

pe.setEmpId(1);

pe.setEmpName("莉莉");

pe.setEmpsex("女");

pe.setHourlyPay(50.0);

System.out.println("雇員編號(hào):"+pe.getEmpId());

System.out.println("雇員姓名:"+pe.getEmpName());

System.out.println("雇員性別:"+pe.getEmpsex());

System.out.println("每小時(shí)工資:"+pe.getHourlyPay());

}

}

(大一java題目) 多線程

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

import java.util.*;

import java.text.*;

public class Win extends JFrame implements Runnable

{

public static void main(String[] args)

{

new Win();

}

Win()

{

setLayout(new GridLayout(2,2));

add(new JLabel("當(dāng)前時(shí)間:"));

add(timetxt=new JTextField(25));

add(new JLabel("當(dāng)前數(shù)字:"));

add(numtxt=new JTextField(25));

// setSize(400,300);

// setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

pack();

setResizable(false);

setLocationRelativeTo(null);

addWindowListener(new WindowAdapter()

{

public void windowClosing(WindowEvent e)

{

exit=true;

dispose();

System.exit(0);

}

});

new Thread(this).start();

new Thread(new Runnable()

{

public void run()

{

while(!exit)

{

try

{

Thread.sleep(2000);

n++;

numtxt.setText(String.valueOf(n));

n%=10;

}

catch(Exception ex)

{

}

}

}

private int n=0;

}).start();

setVisible(true);

}

public void run()

{

while(!exit)

{

try

{

timetxt.setText(sdf.format(new Date()));

Thread.sleep(1000);

}

catch(Exception ex)

{

}

}

}

private boolean exit=false;

private JTextField timetxt,numtxt;

private final SimpleDateFormat sdf=new SimpleDateFormat("H:m:s");

}

大一編程入門java語言,這道題代碼怎么打呢?

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.event.*;

public class PainterPanel extends JPanel implements MouseListener{

int shape=-1; //圖案類型

Point[] point=new Point[2]; //記錄鼠標(biāo)拖動(dòng)的起始點(diǎn)和終點(diǎn)

public PainterPanel(){

super(); //調(diào)用父類構(gòu)造函數(shù)

this.setBackground(Color.white); //設(shè)置背景顏色

point[0]=new Point(-1,-1); //初始化變量

point[1]=new Point(-1,-1);

addMouseListener(this); //增加鼠標(biāo)事件

}

public void mouseReleased(MouseEvent e){ //鼠標(biāo)釋放事件

point[1]=new Point(e.getX(),e.getY()); //設(shè)置終點(diǎn)位置

repaint(); //重繪屏幕

}

public void mouseEntered(MouseEvent e){}

public void mouseExited(MouseEvent e){}

public void mouseClicked(MouseEvent e){}

public void mousePressed(MouseEvent e){ //鼠標(biāo)按下時(shí)事件

point[0]=new Point(e.getX(),e.getY()); //設(shè)置起始位置

}

public void paint(Graphics g){

super.paint(g);

switch (shape){ //根據(jù)shape繪制圖形

case 0:

g.drawLine(point[0].x,point[0].y,point[1].x,point[1].y); //繪線

break;

case 1:

int width=point[1].x-point[0].x;

int height=point[1].y-point[0].y;

g.drawOval(point[0].x,point[0].y,width,height); //繪橢圓

break;

case 2:

width=point[1].x-point[0].x;

height=point[1].y-point[0].y;

g.drawRect(point[0].x,point[0].y,width,height); //繪矩形

break;

}

}

public void drawShape(int shape){

this.shape=shape;

}

}


網(wǎng)頁題目:大一java代碼題 java代碼題目和答案
網(wǎng)頁路徑:http://weahome.cn/article/dospdgd.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部