「showjava吧」showjava下载
本篇文章给大家谈谈showjava吧,以及showjava下载对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
- 1、Java中show() 方法被那个方法代替了?
- 2、String str = JOptionPane.showInputDialog("请输入数字:"); int size = Integer.parseInt(str);的含义
- 3、(java)show方法调用show的时候显示所输入参数
- 4、谁能帮我做两道JAVA的题,我谢谢你们了,关系到这个学期的成绩。
- 5、在Java中,如何用showOpenDialog默认打开某路径的,而不是打开C盘的Documents文件夹?
Java中show() 方法被那个方法代替了?
你说的show是swing里的吧,在老版本中Component这个超类确实有show这个方法,而且这个方法也相当有用,使一个窗口可见,并放到最前面。在jdk5.0中阻止了这个方法,普遍用setVisible()显示窗体。
String str = JOptionPane.showInputDialog("请输入数字:"); int size = Integer.parseInt(str);的含义
java吧showInputDialog会使得程序弹出一个对话框,要求用户在对话框中输入一个数字,然后这个数字以String的形式存在str中,之后通过Integer.parseInt将这个String转化成为一个int。整个程序相当于读取用户在对话框中输入的数字。
(java)show方法调用show的时候显示所输入参数
1.在你的Test类里这么写:
int num, phonenum;
String name,address, work;
public Test(int num, String name,int phonenum,String address,String work) {
this.num=num;
this.name=name;
this.phonenum=phonenum;
this.address=address;
this.work=work;
}
public int getNum() {
return num;
}
public int getPhonenum() {
return phonenum;
}
public String getName() {
return name;
}
public String getAddress() {
return address;
}
public String getWork() {
return work;
}
2、你的show()方法里这么写
for(int i=0;imax;i++){
System.out.print("工号"+arr[i].getNum()+" "+"姓名"+arr[i].getName()+" "+"电话"+arr[i].getPhonenum()+" "+"地址"+arr[i].getAddress()+" "+"工作"+arr[i].getWork());
}
3、在你的add类中测试代码:
//测试代码
public static void main(String[] args) {
add a = new add();
a.addwork();
a.show();
}
谁能帮我做两道JAVA的题,我谢谢你们了,关系到这个学期的成绩。
1、
//员工类
public class Employee {
private String name;
private String sex;
private double wage;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public double getWage() {
return wage;
}
public void setWage(double wage) {
this.wage = wage;
}
public Employee(){}
public Employee(String name, String sex, double wage) {
this.name = name;
this.sex = sex;
this.wage = wage;
}
public void showInfo(){
System.out.println("员工姓名:"+name);
System.out.println("性别:"+sex);
System.out.println("薪水:"+wage);
}
}
2、
//商品类
public class Goods {
private double unitPrice;
private int account;
public double getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(double unitPrice) {
this.unitPrice = unitPrice;
}
public int getAccount() {
return account;
}
public void setAccount(int account) {
this.account = account;
}
public Goods() {}
public Goods(double unitPrice, int account) {
this.unitPrice = unitPrice;
this.account = account;
}
public double totalPrice(){
return unitPrice*account;
}
}
//VIP价格接口
public interface VipPrice {
double DISCOUNT=0.8;
double reducedPrice();
}
//服装类
public class Clothing extends Goods implements VipPrice {
private String style;
public String getStyle() {
return style;
}
public void setStyle(String style) {
this.style = style;
}
@Override
public double reducedPrice() {
return VipPrice.DISCOUNT*totalPrice();
}
public Clothing(){}
public Clothing(double unitPrice, int account,String style) {
super(unitPrice, account);
this.style=style;
}
public void showInfo(){
System.out.println("服装单价:"+getUnitPrice());
System.out.println("数量:"+getAccount());
System.out.println("样式:"+style);
System.out.println("原价:"+totalPrice());
System.out.println("VIP价格:"+reducedPrice());
}
}
//测试类
public class Test {
public static void main(String[] args) {
Clothing c=new Clothing(200,1,"男装");
c.showInfo();
}
}
在Java中,如何用showOpenDialog默认打开某路径的,而不是打开C盘的Documents文件夹?
我猜你应该是用了一个JFileChooser对象吧,其中有一个方法叫changeToParentDirectory()方法,该方法会将目录调整到当前目录的父目录,比如说C盘或者D盘,另外还有一个方法叫setCurrentDirectory(File
file)方法,这个方法可以直接指定当前目录应该从哪开始。
JFileChooser
choose
=
new
JFileChooser();
//
使用父目录
choose.changeToParentDirectory();
choose.showOpenDialog(null);
//使用指定目录
choose.setCurrentDirectory(new
File("D:/Java"));
choose.showOpenDialog(null);
希望能帮到您。
关于showjava吧和showjava下载的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。