Cześć
Potrzebuje pomocy w momencie kiedy chce utworzyć projekt nie podpowiada mi class w zapisie JavaFX na InteliJ-u.
Moje drzewko wygląda tak:
kody w plikach tak:
Main.class
package sample;
import Menu.MenuUtilities;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
FXMLLoader loader = new FXMLLoader();
loader.setLocation(this.getClass().getResource("sample.fxml"));
StackPane stackPane = loader.load();
Scene scene = new Scene(stackPane);
stackPane.getChildren().add(MenuUtilities.prepareMenu());
stackPane.setAlignment(Pos.TOP_LEFT);
primaryStage.getIcons().add(new Image("file:src/img/icon.png"));
primaryStage.setOnCloseRequest((e)->{Controller.closeProgram();});
primaryStage.setTitle("Postoje-Bartosz Kosmowski.app");
primaryStage.setMaximized(true);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
MenuUtilities
package Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import sample.Controller;
public class MenuUtilities {
public static MenuBar prepareMenu() {
MenuBar menuBar = new MenuBar();
javafx.scene.control.Menu menuFile = new javafx.scene.control.Menu("Plik");
MenuItem closeFile = new MenuItem("Zamknij");
closeFile.setOnAction(actionEvent -> Controller.closeProgram());
menuFile.getItems().add(closeFile);
menuBar.getMenus().add(menuFile);
return menuBar;
}
}
Controller
public class Controller implements Initializable {
@FXML private TableView<Stop> tableView;
@FXML private TableColumn<Stop, String> dateColumn;
@FXML private TableColumn<Stop, String> orderColumn;
@FXML private TableColumn<Stop, String> personColumn;
@FXML private TableColumn<Stop, String> warrningColumn;
@FXML private TextField textDate, textOrder, textPerson, textInfo;
@FXML private Button addButton, delateButton;
@FXML
Button button1;
@Override
public void initialize(URL location, ResourceBundle resource){
dateColumn.setCellValueFactory(new PropertyValueFactory<Stop, String>("data"));
orderColumn.setCellValueFactory(new PropertyValueFactory<Stop, String>("zlecenie"));
personColumn.setCellValueFactory(new PropertyValueFactory<Stop, String>("lider"));
warrningColumn.setCellValueFactory(new PropertyValueFactory<Stop, String>("uwagi"));
tableView.setItems(addOrder());
}
public void addRawToTable(){
Stop newStop = new Stop(textDate.getText(), textOrder.getText(), textPerson.getText(), textInfo.getText());
tableView.getItems().add(newStop);
textDate.clear();
textOrder.clear();
textPerson.clear();
textInfo.clear();
}
public void delateRow(){
ObservableList<Stop> wybranyWiersz, wszystkieWiersze;
try{
wszystkieWiersze = tableView.getItems();
if(wszystkieWiersze.size() != 0){
wybranyWiersz = tableView.getSelectionModel().getSelectedItems();
wybranyWiersz.forEach(wszystkieWiersze::remove);
}
}catch(Exception e){
//tabela jest pusta
}
}
public ObservableList<Stop> addOrder(){
ObservableList<Stop>personList = FXCollections.observableArrayList();
personList.add(new Stop("dfsdf", " fdsfsdf", "fsdfsdf", "fdsfsd" ));
return personList;
}
public static void closeProgram()
{
Platform.exit();
System.exit(0);
}
}