I am trying to make the arrow button disappear entirely from my ComboBox and at the same time i want to make my ComboBox open the dropdown menu when i click on it.
Firstly, with what i have made the arrow is transparent but still works. So what i want is to delete it entirely. How am i suppose to do that?
ComboBox Java Code
searchBar = new ComboBox<>();
searchBar.setEditable(true);
searchBar.setMinWidth(1100);
searchBar.setPromptText("type here");
CSS Code:
.combo-box {
-fx-border-width: 0.2px;
-fx-border-color: #87C6C8;
-fx-border-radius: 45px;
-fx-background-radius: 45px;
-fx-font-size: 15px;
-fx-font-weight: 100;
-fx-font-family: 'arial';
}
.combo-box .arrow,
.combo-box .arrow-button{
-fx-background-color: transparent;
}
.combo-box-base:editable > .text-field{
-fx-border-width: 0.5px;
-fx-border-color: #87C6C8;
-fx-border-radius: 50px;
-fx-background-radius: 50px;
-fx-font-size: 15px;
-fx-font-weight: 100;
-fx-font-family: 'arial';
}
Result:
How can delete that?
Secondly, how can i make an action when i click the ComboBox the menu drops down?
Any help is appreciated.
Thanks in advance!
I have a button with custom CSS. The white background is overflowing and is seen past the black border (as shown in the picture).
I'm not sure how to fix this issue as I have experience only with web version of CSS.
Thanks for any help!
.root {
-fx-font-family: verdana;
-fx-background-color: rgb(16, 118, 252);
}
#head {
-fx-font-size: 30;
-fx-fill: black;
-fx-font-weight: bold;
}
.button {
-fx-background-radius: 50;
-fx-border-radius: 25px;
-fx-text-fill: black;
-fx-background-color: white;
-fx-font-size: 25;
-fx-border-style: solid;
-fx-border-color: black;
-fx-border-width: 5px;
}
#footer {
-fx-font-size: 18;
}
It seems there are some rounding errors for ...-radius styles.
You can hide background under the border by using insets:
-fx-background-insets: 5px;
Having a Node for example VBox I am trying to add a border and there are 2 ways I can think of - using css or using new Border () etc..
How can I remove part of the border ? i.e remove the bottom part of the border
You can specify different styles for the borders on different sides
Using Border
#Override
public void start(Stage primaryStage) {
Region root = new Region();
root.setBorder(new Border(new BorderStroke(Color.RED, Color.RED, Color.RED, Color.RED,
BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.NONE, BorderStrokeStyle.SOLID,
CornerRadii.EMPTY, new BorderWidths(5), Insets.EMPTY)));
Scene scene = new Scene(root, 300, 300);
primaryStage.setScene(scene);
primaryStage.show();
}
Using inline css
root.setStyle("-fx-border-style: solid solid none solid; -fx-border-width: 5; -fx-border-color: red;");
Using a css stylesheet
.root { /* modify the selector according to your needs */
-fx-border-style: solid solid none solid;
-fx-border-width: 5;
-fx-border-color: red;
}
none doesnt work on javafx 13. I tried changing it to hidden and it works.
.root { /* modify the selector according to your needs */
-fx-border-style: solid solid hidden solid;
-fx-border-width: 5;
-fx-border-color: red;
}
Setting border-width to 0 worked (JavaFX 17): Example:
#header
{
-fx-border-width: 0 0 2px 0;
-fx-border-color: black;
-fx-border-style: solid;
}
Here you can get border only at bottom - order: Top, right, bottom, left.
Hello Fellow StackOverflow Users, this is my first post/question and hopefully i'm not violating any rules/ect.
Unfortunately I am unable to post a picture, but I will put this here for a reference.
http://i.imgur.com/M0uckkg.jpg (Before Button Click)
OT: On the picture above, I am attempting to make the button's background completely transparent besides the text.
http://i.imgur.com/bFOEOVC.jpg (After Button Click)
Everything works out until I click the button then shadows appear on the side.
Here is what I have tried...
CSS
.toggle-button {
-fx-text-fill: black;
-fx-base: transparent;
-fx-background: transparent;
-fx-focus-color: transparent;
-fx-border-color: transparent;
-fx-effect: null;
}
.toggle-button:selected {
-fx-text-fill: black;
-fx-base: transparent;
-fx-background: transparent;
-fx-focus-color: transparent;
-fx-border-color: transparent;
-fx-effect: null;
}
The java code is just a plain simple application with a ToggleButton.
Special Thanks in Advance!
- Bart
I wouldn't recommend modifing the main color palette (-fx-base and others) for just one control. This makes sense if you're trying to style all of them.
Looking at how is defined in modena.css:
.toggle-button {
-fx-background-color: -fx-shadow-highlight-color, -fx-outer-border,
-fx-inner-border, -fx-body-color;
-fx-text-fill: -fx-text-base-color;
}
.toggle-button:selected {
-fx-background-color: -fx-shadow-highlight-color,
linear-gradient(to bottom, derive(-fx-outer-border, -20%), ...),
linear-gradient(to bottom, derive(-fx-color, -22%) 0%, ...);
}
.toggle-button:selected:focused {
-fx-background-color: -fx-focus-color,
linear-gradient(to bottom, derive(-fx-color, -22%) 0%, ...),
-fx-faint-focus-color, linear-gradient(to bottom, derive(-fx-color, -22%) 0%, ...);
}
you will need to change all of them: -fx-shadow-highlight-color, -fx-outer-border,...
Instead, I'll just override the style of the toggle button with your requirements:
.toggle-button,
.toggle-button:focused,
.toggle-button:selected,
.toggle-button:selected:focused {
-fx-background-color: transparent;
-fx-text-fill: black;
}
NOTE I've edited my answer since, as #eckig suggests, it's redundant to apply the same color to the different comma separated values.
If you want to remove the button-like optics completely, I would suggest you to remove all existing styles and add your own style class as the only style class:
ToggleButton toggleButton = new ToggleButton("Login");
toggleButton.getStyleClass().setAll("my-custom-button");
Now you can apply only the styles you need:
.my-custom-button {}
Special Thanks to both of you, Jose & Eckig. I managed to edit my code with both your suggestions and it fixed the issue right away!
Here is a reference for anyone in the future.
Button Code
ToggleButton button= new ToggleButton("Login");
button.getStyleClass().add("custom");
CSS
.custom,
custom:selected {
-fx-background-color: transparent;
-fx-text-fill: black;
}
I am trying to hide box-border for tableView. When I hide that border then border for left side of columnHeader is missing.
Here is my css file:
.table-row-cell:empty {
-fx-background-color: lightyellow;
}
.table-row-cell:empty .table-cell {
-fx-border-width: 0px;
}
.table-view{
-fx-focus-color: transparent;
-fx-box-border: transparent
}
Here is image showing what I mean: