小编Har*_*and的帖子

Java JOptionPane默认文本

当我要求用户输入我使用下面代码制作的程序的数量时,默认文本为3.

String input = JOptionPane.showInputDialog(null, "Please enter new quantity",
                                           JOptionPane.QUESTION_MESSAGE);
Run Code Online (Sandbox Code Playgroud)

我该如何改变?

java default joptionpane

11
推荐指数
2
解决办法
2万
查看次数

java阻止人们关闭

嗨,我有一个全屏程序,我不希望人们关闭,除非他们有密码,我现在有这个代码

public void windowClosing(WindowEvent arg0)
{
    System.out.println("HERE");
    String inputValue = JOptionPane.showInputDialog("Please input the closeword");

    if (inputValue != "closeplz")
    {

    }
} 
Run Code Online (Sandbox Code Playgroud)

在if语句中我希望它停止方法,以便程序能够关闭.任何帮助将是非常好的感谢谢谢

java swing

2
推荐指数
1
解决办法
740
查看次数

Java打印屏幕程序

我试图Robot在Java中使用来制作打印屏幕的图像文件.到目前为止,我有:

 Robot robot = new Robot();
 Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
 BufferedImage capture = new Robot().createScreenCapture(screenRect);
 ImageIO.write(capture, "bmp", new File("printscreen.bmp"));
Run Code Online (Sandbox Code Playgroud)

但我似乎无法创建该文件.

java printscreen awtrobot

1
推荐指数
1
解决办法
5775
查看次数

用","分隔字符串,而不是空格

每次我尝试分割一个字符串,例如foo,bar,foo bar,bar它会在空格后跳过字符串.

如何阻止Java执行此操作?

String[] transactionItem = transactionItems[i].split(",");
Run Code Online (Sandbox Code Playgroud)

如果 transactioItems[0] = Y685,Blue Tie,2,34.79,2

它会输出

transactionItem[0] = Y685
transactionItem[1] = Blue
transactionItem[3] = out of bounds
Run Code Online (Sandbox Code Playgroud)

java string split

-1
推荐指数
1
解决办法
200
查看次数

标签 统计

java ×4

awtrobot ×1

default ×1

joptionpane ×1

printscreen ×1

split ×1

string ×1

swing ×1