Wymagania:
C → F i F → CWskazowki:
Double.parseDoubleNumberFormatExceptionF = C * 9 / 5 + 32 oraz C = (F - 32) * 5 / 9Rozwiazanie (przykladowe):
btnCtoF.setOnAction(e -> { try { double c = Double.parseDouble(input.getText().trim()); result.setText(String.format("%.2f F", c * 9 / 5 + 32)); } catch (NumberFormatException ex) { result.setText("Blad danych"); } }); btnFtoC.setOnAction(e -> { try { double f = Double.parseDouble(input.getText().trim()); result.setText(String.format("%.2f C", (f - 32) * 5 / 9)); } catch (NumberFormatException ex) { result.setText("Blad danych"); } });
Wymagania:
ComboBox z kierunkiem studiowZapisz wyswietla podsumowanie w TextAreaWskazowki:
GridPane do ukladu formularzaTextArea i wpisz podsumowanieRozwiazanie (przykladowe):
saveBtn.setOnAction(e -> { String first = firstName.getText().trim(); String last = lastName.getText().trim(); String index = indexField.getText().trim(); String major = majorBox.getValue(); if (first.isEmpty() || last.isEmpty() || index.isEmpty() || major == null) { summary.setText("Uzupelnij wszystkie pola"); return; } summary.setText( "Student:\n" + "Imie: " + first + "\n" + "Nazwisko: " + last + "\n" + "Indeks: " + index + "\n" + "Kierunek: " + major ); });
Wymagania:
TableView z kolumnami: nazwa, kategoria, kwotaWskazowki:
Expense z StringProperty i DoublePropertyPropertyValueFactory albo bindingu kolumnRozwiazanie (przykladowe):
private final ObservableList<Expense> expenses = FXCollections.observableArrayList(); private void updateTotal() { double total = expenses.stream().mapToDouble(Expense::getAmount).sum(); totalLabel.setText(String.format("Suma: %.2f PLN", total)); } addBtn.setOnAction(e -> { try { Expense expense = new Expense( nameField.getText().trim(), categoryBox.getValue(), Double.parseDouble(amountField.getText().trim()) ); expenses.add(expense); updateTotal(); } catch (Exception ex) { totalLabel.setText("Blad: sprawdz dane"); } });
Wymagania:
Wskazowki:
fx:id mapuj na pola @FXMLdisableProperty@ i ., haslo minimum 8 znakowRozwiazanie (przykladowe):
loginBtn.disableProperty().bind( Bindings.createBooleanBinding( () -> { String email = emailField.getText().trim(); String pass = passwordField.getText(); return !(email.contains("@") && email.contains(".") && pass.length() >= 8); }, emailField.textProperty(), passwordField.textProperty() ) ); loginBtn.setOnAction(e -> statusLabel.setText("Dane poprawne - logowanie..."));
Wymagania:
ListView lub TableViewWskazowki:
HttpClient i Task (nie blokuj watku UI)Platform.runLater(…)Rozwiazanie (szkic):
Task<String> loadTask = new Task<>() { @Override protected String call() throws Exception { HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("http://localhost:8080/api/students")) .GET() .build(); return HttpClient.newHttpClient() .send(request, HttpResponse.BodyHandlers.ofString()) .body(); } }; loadTask.setOnSucceeded(e -> statusLabel.setText("Pobrano dane")); loadTask.setOnFailed(e -> statusLabel.setText("Blad polaczenia")); new Thread(loadTask).start();