javafx-8

How to make the first 2 rows in a JavaFX listview non-selectable

牧云@^-^@ 提交于 2019-12-12 02:05:57
问题 If I use playList.getSelectionModel().select(1) - the highlighted selection will be the second row of the playlist. If I use playList.getSelectionModel().select(-1) to have no rows selected (as suggested elsewhere on StackOverflow) the first row will be selected. Does anyone have any idea of why this is not working? I would like for the first two rows of the listview to never be eligible for selection. I am using JavaFX-8. public class AudioPlayerFXMLController implements Initializable {

JAVA FX - Service.start() wont run in a separate thread

蓝咒 提交于 2019-12-12 01:52:00
问题 I have and application and i start my scene in the primaryStage. When the user click OK button, I create a Service and after that, I start it. This service make a call to WebService and get me the response. I've seen that after the start() is called, the main flow do not continue and createTask() is called immediately and all my UI is blocked. This is my code: Code when I press the button @FXML private void handleRegisterButton() { User newUser = new User(); newUser.setUsername

How to set the letter spacing (aka tracking) of a Font in JavaFX?

别来无恙 提交于 2019-12-12 01:48:02
问题 The internet teaches me it was available in JavaFX 1.x (most examples I found, were in the .fx format, which is now obsolete). But it now (JavaFX 2.*) seems impossible to do. I can think of one way for accomplishing the effect I want: stuff every letter in a Text and add all of them to a FlowPane with the HGap set to the wanted spacing. But I'd rather use this as a last resort. Oh, I've also tried putting -fx-letter-spacing in my stylesheet, didn't work either. 回答1: I made a custom class that

JavaFX 3D: Transforming Cylinder to defined start and end points

此生再无相见时 提交于 2019-12-12 01:45:35
问题 Suppose that I want a Cylinder to start in some 3D point and to end in some other 3D point. As far as I know, the way to do that, is to compute the Euclidian distance between the 2 points and to create a Cylinder with the same length. Then, the cylinder should be translated and rotated, such that it really starts at the start point and ends at the end point. I get messed up with these transformation and do not succeed to place the Cylinder in its correct place. Could you please share some

How to change the start and end point of Line using Arrow Keys in JavaFx?

倾然丶 夕夏残阳落幕 提交于 2019-12-12 01:44:08
问题 I am trying to make a simple program in Java using JavaFx to set the start and end point of the line object with Arrow Keys. Basically, the idea is to make line like snack with pressing the Arrow Keys. I used the setOnPressedKey event but it doesn't work, but when I remove the event and run the program the setStartX and setStartY and so on works. Line line = new Line(); line.setStroke(Color.BLACK); line.setOnKeyPressed(e -> { if (e.getCode() == KeyCode.UP) { line.setStartX(line.getEndX() + 0)

JavaFX editable ComboBox in a table view

蓝咒 提交于 2019-12-12 01:43:41
问题 I am using a editable ComboBox cell in a table view. Here is my ComboBox cell class public class ComboBoxCell extends TableCell<ClassesProperty, String> { private ComboBox<String> comboBox; public ComboBoxCell() { } @Override public void startEdit() { super.startEdit(); if (comboBox == null) { createComboBox(); } setGraphic(comboBox); setContentDisplay(ContentDisplay.GRAPHIC_ONLY); Platform.runLater(new Runnable() { @Override public void run() { comboBox.requestFocus(); comboBox.getEditor()

Minimize panel button

笑着哭i 提交于 2019-12-12 01:10:09
问题 I'm working on this example of simple panel. public class MainApp extends Application { private static BorderPane bp; @Override public void start(Stage stage) throws Exception { FlowPane flow = new FlowPane(); flow.setPadding(new Insets(50, 5, 5, 5)); flow.setVgap(15); flow.setHgap(15); flow.setAlignment(Pos.CENTER); HBox thb = new HBox(); thb.setPadding(new Insets(13, 13, 13, 13)); thb.setStyle("-fx-background-color: gray"); DropShadow ds = new DropShadow(); ds.setOffsetY(3.0); ds.setOffsetX

Manage wait cursor for task

大憨熊 提交于 2019-12-12 00:41:47
问题 I'm outside the UI and wish to display a wait cursor while stuff is happening and using this basic pattern: on UI - primaryStage.scene.cursor = Cursor.WAIT try { do stuff off UI... } finally { on UI - primaryStage.scene.cursor = Cursor.DEFAULT } While running I can start another process which completes quickly and the Cursor is restored before the first task completes. I don't mind "waiting" while the first task completes, but I don't think this means doing the work on the UI thread? Is there

Resizeable Gridpane or other container

大憨熊 提交于 2019-12-11 23:18:32
问题 Hi I'm trying to create a simple layout that looks like this using JavaFX. I would like the user to be able to drag/resize the middle bar. I've tried to make this using a GridPane. But I can't figure out how to get the middle resized. Perhaps GridPane is not the way to go. Both panes will contain a lot of other program code later on. Thanks! Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds(); stageRef.setMaxWidth(primaryScreenBounds.getWidth()); stageRef.setMaxHeight

@FXML Objects are null in initialize Method

放肆的年华 提交于 2019-12-11 20:01:08
问题 i have a (shortened) java FX Class: public class MyReportController extends javafx.application.Application implements Initializable { @FXML private CustomTextField autoTextField; @Override public void initialize(URL url, ResourceBundle resourceBundle) { TextFields.bindAutoCompletion(autoTextField, ServiceLocator .getInstance().getMeasurementService() .getAllMeasurementNumbers()); }...... the initialzie method is called, but the autoTextField(and all other FXML components) is null. The