我已经在JCreator中编写了一个Java程序,一切都已完成,但我想从中创建一个可执行文件,即我不想通过加载java类并编译然后执行来运行程序,而是将其作为一个独立的可执行文件.
最快的方法是什么?
我试图让我的JTextField填充宽度并为其设置高度但仍然失败.我尝试添加代码setPreferredSize(new Dimension(320,200));但仍然失败.有什么方法可以让我的JTextField填充宽度并将高度设置为200或其他什么?
我正在尝试从命令提示符编译并运行我的项目.我正在为我的项目使用JCreator.我找不到任何解决方案.
这是我在命令提示符中得到的错误:
Note: Some input files use or override a deprecated API
Note: Recompile with -Xlint:deprecation for details.
Run Code Online (Sandbox Code Playgroud)
哦,我也尝试在JCreator中运行该项目.但是,它不显示我的GUI程序.我已经将某个Java文件/类设置为主文件/类.
我不确定是不是因为我没有正确设置或者是其他东西.希望有人可以帮助我或建议解决方案.谢谢!:)
请帮忙.我对此很陌生,我非常需要这个.我需要创建一个程序,让你可以选择加法或减法.这是我目前的计划:
import javax.swing.JOptionPane;
public class RationalZ {
public static void main(String args[]) {
JOptionPane.showMessageDialog(null,
"Enter the letter A for Addition and B Subtraction");
String choice = JOptionPane.showInputDialog(
"A=Addition B=Subtraction");
if (choice == "a") {
String strNum1 = JOptionPane.showInputDialog(
"Enter a Number");
String strNum2 = JOptionPane.showInputDialog(
"Enter a second number");
int aNum1 = Integer.parseInt(strNum1);
int aNum2 = Integer.parseInt(strNum2);
JOptionPane.showMessageDialog(null, aNum1 + aNum2);
System.exit(0);
} else {
System.exit(0);
}
}
}
Run Code Online (Sandbox Code Playgroud)
怎么了?即使在第一步我也无法得到它.
编译完程序后,我收到了显示给我的错误信息
Resource: Employee.java
int cannot be dereferenced
Run Code Online (Sandbox Code Playgroud)
这个代码
public Salary(int positionSalary) {
setMonthlySalary(positionSalary);
}
Run Code Online (Sandbox Code Playgroud)
经过一段时间的检查后,我仍然无法修复错误.这是我的班级,
雇员
import java.util.*;
import java.lang.String.*;
public class Employee {
protected int type;
private static int staticID = 0001;
protected int id;
protected String name;
protected String ic;
protected String tel;
protected static int count = 0;
protected int editChoice=0;
private Salary salary = new Salary(0);
public Employee(){
id = -1;
name = "";
ic = "";
tel = "";
}
public Employee(int type, String name, …Run Code Online (Sandbox Code Playgroud) Scanner x = new Scanner(System.in);
byte num, r, c;
System.out.print("Enter a number: ");
num = x.nextByte();
for (r = 1; r <= num; r++) {
for (c = 1; c <= r; c++) {
System.out.print("*");
}
System.out.println();
}
Run Code Online (Sandbox Code Playgroud)
示例输出:
Enter a number: 4
*
**
***
****
Run Code Online (Sandbox Code Playgroud)
如何更改输出:
*
**
***
****
Run Code Online (Sandbox Code Playgroud)
至
****
***
**
*
Run Code Online (Sandbox Code Playgroud) 我目前正在从事一个项目,并且不断收到错误消息。我被困住了并且已经联系了很多人(包括我的教练),现在我已经转向你们。
到目前为止,这是我的代码。
public class Circle
private int radius = getRadius();
private double area = getArea();
public Circle(int r)
{
r = radius;
}
public int getRadius()
{
return radius;
}
public double getArea(int r)
{
return area = Math.PI * r * r;
}
}
Run Code Online (Sandbox Code Playgroud)
/
java.util.Scanner;
public class CircleTest
{
public CircleTest()
{
int radius = getRadius();
double area = getArea(r);
}
public static void main (String[] args)
{
Scanner kboard = new Scanner(System.in);
System.out.print("Give the radius of a …Run Code Online (Sandbox Code Playgroud)