It seems there might have been some misunderstanding or typo regarding the usage of ToggleGroup in the FXML. JavaFX FXML does not allow direct Fx:id assignments to attribute values such as toggleGroup. Instead, you should define the ToggleGroup in your controller and set it through code.
this is my EditView.fxml please add a search bar on the top centered of it and an icon inside of it from the most left i'm gonna add it's correct path , also add a Search by: with 4 radio buttons All File No Name ID Phone under the search bar <3 you are the goat and gonna make it also give me the css for the new added components
To add a search bar with an icon and radio buttons for search filters to your EditView.fxml, you will need to update the layout in the file. Here’s an example of how you might modify the structure to include these elements:
You can include this in your existing EditFile.css to style the new elements:
css
/* Style for the search bar */
.search-bar {
-fx-pref-width: 300.0;
-fx-font-size: 14px;
-fx-padding: 6px;
-fx-border-radius: 4px;
-fx-background-radius: 4px;
-fx-border-color: #cccccc;
-fx-background-color: #ffffff;
}
/* Style for radio buttons */
.radio-button {
-fx-font-size: 12px;
-fx-padding: 5px;
}
/* Layout styling */
.vbox > .hbox {
-fx-alignment: center;
}
Make sure to replace the placeholder image path @../../../Icons/searchIcon.png with the actual path of your search icon. The new layout will add a search bar to the top of the interface, with a row of radio buttons beneath the search bar to allow users to filter their searches by different fields.
Here's how you can correct this:
Remove the ToggleGroup assignment in FXML:
Modify your FXML for radio buttons as outlined below:
In your controller class (AddFileController as referenced in fx:controller), you need to initialize the ToggleGroup and associate the radio buttons with it. Here's a sample of how this can be done:
java
import javafx.fxml.FXML;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
public class AddFileController {
@FXML
private RadioButton allRadioButton;
@FXML
private RadioButton fileNoRadioButton;
@FXML
private RadioButton nameRadioButton;
@FXML
private RadioButton idRadioButton;
@FXML
private RadioButton phoneRadioButton;
public void initialize() {
// Create a ToggleGroup
ToggleGroup searchGroup = new ToggleGroup();
// Assign radio buttons to the group
allRadioButton.setToggleGroup(searchGroup);
fileNoRadioButton.setToggleGroup(searchGroup);
nameRadioButton.setToggleGroup(searchGroup);
idRadioButton.setToggleGroup(searchGroup);
phoneRadioButton.setToggleGroup(searchGroup);
// Additional initialization code if needed
}
}
With these changes, you ensure all radio buttons are part of the same ToggleGroup, which allows only one of them to be selected at any time. This setup helps control the selection state and handling within the JavaFX application.