JavaFX - toggle button with separator - javafx-2

The Java FX Scen Builder contains quite a special form of a toggle button. Several Buttons are visually concatenated and separated by a small vertical line:
I wonder how this is done. Does somebody have any idea?

It's an HBox of ToggleButton's all with the same ToggleGroup and custom css.
There is an example with source code of displaying a similar control group in the Ensemble sample application (which Ensemble terms a Pill Button). The Ensemble sample source license is BSD I think, so you should be able to use it in your app. Go to Ensemble, search for Pill in the Ensemble sample app, click on the "Save NetBeans Project..." button on the Pill Button sample and open the resultant project in NetBeans, full code, css and supporting image files will be included in the project.

As an easier alternative to custom CSS, the Controls FX project provides the Segmented Button control, that allow to visually group buttons just like OP asked.
It is BSD licensed so I guess safe to use in most cases. And the library has many other useful and well designed controls.
The segmented button looks like this :
Very straightforward to use :
ToggleButton tb1 = new Button("Red");
ToggleButton tb1 = new Button("Green");
ToggleButton tb1 = new Button("Blue");
SegmentedButton seg = new SegmentedButton();
seg.getButtons().addAll(tb1,tb2,tb3);
hbox.getChildren().add(seg);
It allows to specify if the selection should be mutually exclusive or not. For the second bwhaviour (non mutually exclusive) set the segmented buttons's group to null :
seg.setToggleGroup(null);
Source :
http://controlsfx.bitbucket.org/org/controlsfx/control/SegmentedButton.html

Related

how to remove default graphic assigned to a control (like buttons and checkboxes) before setting new graphic to that control in java fx scene builder?

i am making a java desktop application using javafx. For gui building i am using scene builder 2.0.
Everything is just perfect as expected just 1 thing. I want to customize the buttons. i want to assign a custom graphic to a button.
When i use [button.setgraphic(node)] , this statement set the new graphic to the button but default graphic of button also remains present as well.
I just want to remove the default graphic and then want to assign the new (custom) garaphic to a control like buttons and radio buttons in javafx. 1 thing again i must tell that i am using scene builder for building gui.
How can i achieve this ?
thanks in advance....
Below is the screen-shot of current occuring situation, .....
Here i have made a button using javafx scene builder , and then in the controller of the fxml file (.java file) i am trying to set the image (shown in orange box in snapshot) to that button by using setGraphics property of button ..... i just need that button to be of following shape ...
You'd better customize your button via CSS. Here goes tutorial. What you are trying to do is to modify button picture (which is empty by default). I guess this wasn't your exact purpose.
button.setGraphic(null)
// worked for me.

Can I create a custom DialogPreference based on a pre-existing custom Dialog?

In my Android project I've already created a custom dialog: A class named SelectColorDialog, extending Dialog, that allows the user to view a large matrix of color cells in order to select a particular color. The dialog returns the selected color value (as Integer) to the dialog initiator – typically an Activity – via a callback function.
I've a similar custom dialog, SelectTypefaceDialog, to allow easy font selection. A list of available typefaces are shown, as ListView rows, each identified by name and with an associated short sample text rendered in that typeface. The available typefaces include usual droid fonts, such as NORMAL, MONOSPACE, etc. as well as any externally sourced TTF font files that the user cares to load into a particular subdirectory on the SDCard.
These custom dialogs were not initially designed to be used directly in conjunction with SharedPreferences, preferences definition XML files or with any PreferenceActivity. Instead of, each dialog can be popped up from any activity, via the user pressing a button or via a menu item. The activity classes that create these dialogs also have internal callback classes, selection event listeners, to detect when the user selects a color or font.
These two dialogs do not have OK and Cancel buttons. Instead, the user just clicks on an item - a view of some kind - in the dialog to select the corresponding color or typeface value (implicit OK) or else presses the device’s back button to dismiss the dialog with no action taken (implicit Cancel).
I would now like to go further and incorporate these two custom dialogs into the shared preferences framework via a preferences.XML and an associated PreferenceActivity.
I would prefer to base two DialogPreference subclasses directly on these existing dialogs if possible, but I cannot see how to do so. I suspect that I cannot, and that I'll need to start all over again, and copy or adapt all the java code that is presently in the custom dialog classes – for color or font display and selection – directly into the custom DialogPreference classes instead, perhaps by overriding onCreateDialogView() and/or other methods?
This question may be a bit old, but I hope to help those, looking at the same problem in future: just extend Preference instead of DialogPreference. DialogPreference is designed badly and expected "official" way to use custom Dialog - overriding protected showDialog method does not work, because this single method contains half of class logic.

Design-time support on composite control

I'm creating a specific DataGridView control that includes two scrollbars so that I can control their size and visibility. So, I have created a User control that contains the DataGridView and the two scrollbars inside a 2x2 TableLayoutPanel.
The issue I'm facing is that when I add my control to a Windows Form, I can't set my DataGridView's DataSource or define the column styles from the design view, because the link that I use for that when I use a common DataGridView (that little white arrow appearing on the top right side of the DataGridView) is not appearing.
While doing some testing, I saw that if I inherit my control from DataGridView, that link appears. But if I do that, I guess that I can only extend the functionality for the DataGridView, but I need my control to be a composite control.
So, that's my question: how can I get those design-time capabilities on my custom control? I am specially interested on the columns layout and the datasource.
Best regards.
If you are doing a usercontrol (a control that has an .ascx codebehind file) there seems to be no way to control this:
How to hide the inner controls of a UserControl in the Designer?
If you are doing a WebControl (a class that inehrits from WebControl with no .ascx file) you may create your own designer and maybe somehow output the designers of both conrols. Have a look at: http://msdn.microsoft.com/en-us/library/12yydcke.aspx it explains how to create a webcontrol and its desgner.
Some things with usercontrols/webcontrols seem to be easy but are hard to implement...
Hope this helps!

How can a graphic be placed in the OneUI .lotusBanner area using the Application Layout Control

I am using the Extension Libraries Application Layout Control and need to have a banner graphic placed in the .lotusBanner div on the right. How can this be done as it seems that the Application Layout Control can't be modified.
You could use the utilityLinksFacet on the extended control that Steve Pridemore did.
http://www.openntf.org/internal/home.nsf/project.xsp?action=openDocument&documentId=CED2E61A75526CD086257997006DA95B
or you could use onload javascript to add it.
I was able to place a graphic in the upper right of the Application Layout Control in the Banner area by doing the following:
In the control under the Banner > Utility links I added a Basic node. For the node I specified the href and image. This worked and placed the image n the correct spot.
Artifacts of this were the location of the Banner Application links. To remedy this I used some CSS for the .lotusBanner ul.lotusLinks {margin-top: 45px;position:absolute;}
The margin-top was to push the links down so I could enlarge the logo that is used by the Application Layout Control.
The applicationLayout control in ExtLib is, as you have found out, locked down to only allow certain aspects of the configuration to be changed by the developer. You can add links to different sections of the applicationLayout but nothing beyond that.
One possible alternative is to NOT use the applictionLayout control itself but create your own approximation of it in a custom control, You would need to add all the necessary panels/divs with the special oneUI2 classes in all the correct places and then add editable areas and callbacks within these panels for the parts that you would want to customize throughout the application. All of the other sections in the applicationLayout control, like the bannerUtilityLinks are created using the ListofLinks control that is also found in the Extension Library.

Suggestions for a Monotouch model dialog (accessible from UITable) with text input

I'm looking for a configurable modal dialog to popup over the top when a cell is clicked in a UITableView with various actions, some of which require input, some don't. Is Monotouch.dialog appropriate or is there a better way to achieve this?
The behaviour I'm looking for with the dialog (activated in the UITable) is the following:
- Fixed actions. Click a button, do something.
- Text input. Enter text (for example, reset a password), do something.
Alternatively, is it possible to use a custom controller such as QuickDialog https://github.com/escoz/QuickDialog?
Sincerely,
Adam
Popover for user-input is quite a common task. I would recommend UIPopoverController with custom views inside that when presented allow the user to complete an action / task / input. Quick dialog is a rendition of MonoTouch.Dialog ported to obj-C. You can use straight-up MonoTouch.Dialog if you like: https://github.com/migueldeicaza/MonoTouch.Dialog
I would also recommend my managed C# implementation of UIPopover for MonoTouch here (with video): https://github.com/anujb/Devnos.Popover
Video: http://screencast.com/t/lGwsvtEot9V

Resources