Populating a JavaFx Fxml Toolbar with Graphics Buttons - javafx

I have been endeavoring to implement a JavaFX application using FXML which includes a toolbar in the bottom region of a BorderPane populated with four buttons displaying graphics only.
However, the buttons are displayed in gray outline only with no graphic content.
A simplified snippet of the FXML file is as follows:
<bottom>
<ToolBar fx:id="tbTextColor" >
<Button fx:id="btnRed" contentDisplay="GRAPHIC_ONLY">
<graphic>
<ImageView>
<image>
<Image url="#red.png"> </Image>
</image>
</ImageView>
</graphic>
</Button>
<!--more buttons-->
</ToolBar>
</bottom>
If anybody can inform me how to achieve the desired result, it will be much appreciated.
Thanks.

Related

JavaFX - Do I need a subscene or is there a better way to do this?

I'm trying to write a javafx application where the UI behaves similar to the phone dialer on a cell phone. There will be a layout with a few buttons at the top that change the contents of the area below them. I've defined the layout of the parts that change in FXML files and they all load and work fine.
My question is how do I define the "area" that changes in the main FXML and how do I swap in the new contents in the button event handler?
My main FXML layout looks like this:
<GridPane xmlns:fx="http://javafx.com/fxml" alignment="CENTER" hgap="20" vgap="10"
fx:controller="application.Main" >
<Button text="Dialer" alignment="CENTER"
GridPane.columnIndex="0" GridPane.rowIndex="0"
onAction="#handleModeAction" />
<Button text="Log" alignment="CENTER"
GridPane.columnIndex="1" GridPane.rowIndex="0"
onAction="#handleModeAction" />
<Button text="Contacts" alignment="CENTER"
GridPane.columnIndex="2" GridPane.rowIndex="0"
onAction="#handleModeAction" />
<!--
What goes here??
-->
</GridPane>
I read through the previous posts that looked similar but none looks quite like I thought it worked.
Thanks for any pointers
dave

How to Include Common Sidebar or Header in All Scenes JavaFX FXML

I'm learning JavaFX and facing problem in sharing the same resources on the all scene.
Example as in PHP we can include common page like include("header.php"); or include("sidebar.php");
But how I can add same sidebar on the all scenes/stages in JavaFX?
Use <fx:include>:
<BorderPane>
<top>
<fx:include source="header.fxml"/>
</top>
<left>
<fx:include source="sidebar.fxml"/>
</left>
<center>
<!-- ... -->
</center>
</BorderPane>

Filter grayscale on xul image turns it square

I'm trying to use the filter:grayscale(1) technique to grayscale an image. It works fine on the web but when I try it on my XUL image it's failing. It's turning it into a blurry square.
This is the before:
This is the after:
And here's a picture of the DOM inspection, my element is anonymous element.
Any ideas? That would be awesome! Thanks!
Edit:
I cant get code to replicate this outside for my addon but this is the code:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="yourwindow" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml">
<box class="profilist-tbb" >
<image class="toolbarbutton-icon" style="list-style-image: url(chrome://browser/skin/places/query.png)"/>
<image class="profilist-badge" style="filter:grayscale(1);transform:translate(-7px,14px) scale(.8);" src="chrome://branding/content/icon16.png"/>
<box flex="1">
<stack class="profilist-display-stack" flex="1">
<html:input class="profilist-input" style="display:none" />
<label class="toolbarbutton-text" crop="right" flex="1" value="rawr"/>
</stack>
</box>
</box>
</window>
I also worked around it by putting the grayscale on the box element above it which makes everything inside grayscale, not just this badge icon, but I'll have to live with it till I can replicate it :(

How add wpf image button?

Hi i am developing WPF application using MVVM and i am try to add image as a button (like windows 8 start page button) Is there a way to have a Button only display as an image? I have an image that i would like to use as a button alone, but I can't seem to get the Button borders to go away and the Button background color to become transparent. or any way to use image as a Button ? Help me
<Button Style="{StaticResource RoundCorner}" Grid.Column="4" Grid.Row="2"
x:Name="New" Cursor="Hand" FontWeight="ExtraBold"
Margin="10,22,102,5" Grid.RowSpan="4" Grid.ColumnSpan="2">
<Image Source="pack://siteoforigin:,,,/Resources/NewIcon.png"
RenderOptions.BitmapScalingMode="HighQuality" Width="145" Height="93" />
</Button>
You can just replace the default Button ControlTemplate with a plain Image control. Try this:
<Button Click="Button_Click" Width="16" Height="16">
<Button.Template>
<ControlTemplate>
<Image Stretch="None"
Source="pack://application:,,,/AppName;component/FolderName/ImageName.png" />
</ControlTemplate>
</Button.Template>
</Button>

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