Results 1 to 2 of 2
  1. #1
    ferfykins is offline Member
    Join Date
    Feb 2017
    Posts
    24
    Rep Power
    0

    Default How to fix this?

    Java Code:
    package sample;
     
    import javafx.fxml.FXML;
    import javafx.scene.control.Button;
    import javafx.scene.control.Label;
    import javafx.scene.effect.DropShadow;
    import javafx.scene.layout.GridPane;
    import javafx.stage.FileChooser;
     
    import java.awt.*;
    import java.io.File;
    import java.io.IOException;
    import java.net.URI;
    import java.net.URISyntaxException;
    import java.util.List;
     
    public class Controller {
     
     
        @FXML
        private Label label;
     
        @FXML
        private Button button4;
     
        @FXML
        private GridPane gridPane;
     
     
        public void initialize() {
            button4.setEffect(new DropShadow());
     
        }
     
     
        @FXML
        public void handleMouseEnter() {
            label.setScaleX(2.0);
            label.setScaleY(2.0);
        }
     
     
        @FXML
        public void handleMouseExit() {
            label.setScaleX(1.0);
            label.setScaleY(1.0);
        }
     
     
        @FXML
        public void handleClick() {
            FileChooser chooser = new FileChooser();
            // chooser.setTitle("Save Application File");
            chooser.getExtensionFilters().addAll(
                    new FileChooser.ExtensionFilter("Zip", "*.zip"),
                    new FileChooser.ExtensionFilter("PDF", "*.pdf"),
                    new FileChooser.ExtensionFilter("Image Files", "*.jpg", "*.png", "*.gif"),
                    new FileChooser.ExtensionFilter("All Files", "*.*")
            );
     
            List<File> file = chooser.showOpenMultipleDialog(gridPane.getScene().getWindow());
            if (file != null) {
                for(int i=0; i<file.size(); i++) {
                    System.out.println(file.get(i));
                }
    //            System.out.println(file.getPath());
            } else {
                System.out.println("Choose was cancelled");
            }
        }
     
     
     
     
     
     
        @FXML
        public void handleLinkClick() {
            try {
                Desktop.getDesktop().browse(new URI("http://www.javafx.com"));
            } catch (IOException e) {
                e.printStackTrace();
            } catch(URISyntaxException e) {
                e.printStackTrace();
            }
        }
     
     
    }








    Java Code:
    Error:(10, 12) java: java.awt is not public in java; cannot be accessed from outside package
    C:\Users\ferfy\Desktop\Java Code\Course\Section 13-JavaFX\JavaFX Application\src\sample\Controller.java
    Information:9/10/2019 4:51 PM - Build completed with 1 error and 0 warnings in 6 s 24 ms
    Information:java: Errors occurred while compiling module 'JavaFX Application'
    Information:javac 11.0.3 was used to compile java sources

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,991
    Rep Power
    8

    Default Re: How to fix this?

    You're importing java.awt.* in your code (line 10, col 12) but it's not declared in your module.

    I also wonder what you need java.awt.* for in the first place when you are using JavaFX.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •