小编Fra*_*sco的帖子

JFileChooser OK按下后如何退出?

方案是,当选择单选按钮时,我打开一个JFileChooser来选择一个DIRECTORY,其中应该是一些文件.我正在尝试显示错误消息,我想再次显示目录选择器.这是代码(我在radiobutton更改时调用的函数):

private void JFileChooserOpen(java.awt.event.ActionEvent evt) {
    fileChooser.setCurrentDirectory(new java.io.File("."));
    fileChooser = new JFileChooser(); 
    fileChooser.setDialogTitle("Select a directory");
    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    fileChooser.setAcceptAllFileFilterUsed(false);

    int result = fileChooser.showOpenDialog(fileChooser);
    if (result == JFileChooser.APPROVE_OPTION) {
// here I'm calling a function that searches for specific files. 
// true these files are found, false, they are not.
        if (checkTheDir(fileChooser.getSelectedFile()))
        {
// assigning the path to a label
                thePath.setText(fileChooser.getSelectedFile().toString());
        }
        else
        {
// file not found
            JOptionPane.showMessageDialog(null, "File GuiRap not found!", 
                    "Controlla meglio", JOptionPane.WARNING_MESSAGE);
// what should I do, here, to …
Run Code Online (Sandbox Code Playgroud)

java swing jfilechooser

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

当var包含".0"时,如何将String转换为BigInteger

我有一个String变量,可能包含一个这样的数字"2015.0".当我尝试将其转换为int时

int i = Integer.parseInt(myVar) 
Run Code Online (Sandbox Code Playgroud)

或BigInteger

BigInteger bi = new BigInteger(myVar) 
Run Code Online (Sandbox Code Playgroud)

我收到了错误

java.lang.NumberFormatException: For input string: "2015.0"
Run Code Online (Sandbox Code Playgroud)

我怎样才能实现正确的演员表?

谢谢!

java casting biginteger

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

标签 统计

java ×2

biginteger ×1

casting ×1

jfilechooser ×1

swing ×1