creating custom button in java fxml - css

How to create a custom round button in fxml,I've tried this Code
<Button fx:id="button" layoutX="273.0"
layoutY="103.0" mnemonicParsing="false"
onAction="#next"
style="-fx-base:#b6e7c9;
-fx-font:12 papyrus;
-fx-border-radius:15px 50px 30px 40px ;
-fx-border:2px solid;"
textOverrun="CLIP">
</Button>

Maybe you should take a look of this 4 Using FXML to Create a User Interface
And this one maybe could help you :)
JavaFX - create custom button with image

Related

javafx 8 fxml negation

Using FXML with JavaFx 8.
I have few ToggleButtons in toggleGroup, defined as:
<ToggleGroup fx:id="operater" />
I want to disable OK button, when no operater is selected. Actually, I want to negate the disable expression in ok button:
<Button disable="${operater.selectedToggle.selected}" fx:id="ok" text="OK" mnemonicParsing="false" onAction="#okClick" >
I have tried with ! and with not(), but no success.
Thanks.
You can use an expression binding:
disable="${!operater.selectedToggle.selected}"
operater is spelt operator.

How can I make this Asp.net button have the same CSS as this <button>?

I'm new to Asp.net webforms, and still learning CSS. I am making a website which uses an html template I bought.
My problem is that the template makes use of tags, but I need to use Asp.net button controls. I tried to take the css classes and put them in my button control's CSSClass property, but it's not displaying right.
You can view an example here: [link removed since page is being taken down]
The green "Send Password" button is the and I want the other "Send Password" button (which is the .net control) to be styled the same way.
I've looked around and only find answers relating to overwriting how tags are rendered which I don't want to do right now. Is there an easy way to just make it look the same with CSS?
Thanks for any help!
Change from btn btn-default btn-clean to btn btn-success btn-clean in your asp:Button markup declaration. Either in the CssClass or css attribute.
The green style is applied by the .btn-success class:
.btn.btn-success.btn-clean {
border-color: #59AD2F;
background: transparent;
color: #59AD2F;
}
But your ASP.NET button is using the .btn-default class. Set it to .btn-success (probably in the CssClass="" property)
The easiest way to go about this is to just copy and paste the css from your purchased template into the Site.css file for your WebForms application.
For example, copy (from #LcSalazar's answer)...
.btn.btn-success.btn-clean {
border-color: #59AD2F;
background: transparent;
color: #59AD2F;
}
... into Site.css. btn btn-success btn-clean should appear as an option in the button properties CssClass drop down list.
Not the cleanest way to accomplish what you want, but definitely the fastest while still using the properties view. More information can be found here, starting with the "Creating and Using a Stylesheet" if you're interested in creating a tidier solution.
You can set in other button(white one) the same class as the green button which is .btn btn-success btn-clean:
<input type="submit" name="btnSendPasswordNew" value="Send Password" id="btnSendPasswordNew" class="btn btn-success btn-clean">

JavaFX TextArea setCursor not working

I am having issues getting setCursor() to work properly in TextArea. I am not seeing any other search results at all for issues with this, and might be doing something silly because no one else has addressed this yet. I have tried different options, with no luck. Here are a few attempts below:
Coding this below makes it so only the outer edges are effected by the setCursor.
textArea.setCursor(Cursor.DEFAULT);
In FXML, I get the following if I add it in with Scene Builder.
<TextArea fx:id="textArea" prefHeight="458.0" prefWidth="766.0">
<font>
<Font name="System Bold" size="12.0" />
</font>
<cursor>
<Cursor fx:constant="DEFAULT" />
</cursor>
</TextArea>
It gives me an error, so I add the import...
<?import javafx.scene.Cursor?>
Then it gives me an error, saying "Instances of javafx.scene.Cursor cannot be created by FXML loader." with no hints provided.
I know for ComboBoxes, I have to do the following:
comboBox.getEditor().setCursor(Cursor.DEFAULT);
Is there some way I have to do this for TextArea to work as well?
Thanks!
Your FXML parsed just fine for me, though it didn't have the desired effect. I'm not sure why it gave you errors.
The reason it doesn't generate the desired cursor is that the Text node is placed as the content of a ScrollPane. The cursor is set by default on that Text node, so it isn't inherited if you set the cursor directly on the TextArea.
The easiest way to do this is to use an external CSS file:
.text-area .content {
-fx-cursor: DEFAULT ;
}

javafx & fxml: how do I apply a border to a pane or label in my gui?

I'm just getting into using fxml and it seems like a really cool idea, except for the fact that I'm having a tough time getting it to work. Supposedly I'm able to lay out my GUI using a nice markup language, and I can style the elements via CSS. So I have a label on my GUI, and I would like there to be a solid black border around it, with width=1. Seems like this should be straightforward -- adapting examples I see here and there in tutorials, etc., I do the following:
<Label text="sample text" style="-fx-border-width: 1; -fx-border-style: solid;" />
But it doesn't work. No border appears. In the Scene Builder there is a text box labelled "Style" in the properties inspector, and I can see the style I have applied appear there, but I don't see a border.
What am I overlooking?
You need to specify the Border Color as well. Add this to your Label tab
-fx-border-color:black;
In your case the sample code will be :
<Label text="sample text" style=" -fx-border-color:black; -fx-border-width: 1; -fx-border-style: solid;" />

Implementing splitter with no width inside a box

I have a horizontal box consisting of 4 other boxes separated by splitters. I want to use a splitter that looks like the tree-splitter (with no width), but whenever I try to use it, the splitters disappear and the columns cannot be resized. Any ideas why?
Or have you got any idea how I can implement a splitter that would look like one with id="folderpane_splitter" that has width probably 1px? This solution would be perfect for me.
My code looks like:
<hbox>
<hbox flex="10">
<label value="name1"/>
</hbox>
<splitter/>
<hbox flex="20">
<label value="name2"/>
</hbox>
<splitter/>
<hbox flex="30"">
<label value="name3"/>
</hbox>
<splitter/>
<hbox flex="40">
<label value="name4"/>
</hbox>
</hbox>
If anyone wonders I'm working on an extension for Thunderbird.
I tried using the id="folderpane_splitter" in firefox but it didn't change look. Anyway perhaps you are looking for something like this?
<splitter style="-moz-appearance: separator;"/>
Using:
<splitter style="background-image: none; width: 1px; min-width: 1px;"/>
gave me the apperance I needed. Probably not overriding min-width was blacking it from getting thinner.
Trees have special code to make zero-width splitters work.

Resources