I tried to run my Codename app on my Android phone
after sending the Android build
and I realized that the theme is perhaps wrong. I chose the native theming in the app.
Indeed I get a dark-grey side menu with black text that is very small, while the TextFields are in the right font and white background.
On the simulator (various Android devices skin) the theme seemed right, with good text size and background color.
Here's the relevant code:
mainForm.setToolbar(toolbar);
toolbar.setEnabled(true);
toolbar.showToolbar();
BackCommand backCommand=new BackCommand("Back");
mainForm.setBackCommand(backCommand);
Container topBar = BorderLayout.west(new Label());
String tagLine=.menu_tagline;
topBar.add(BorderLayout.WEST, new Label(tagLine, "SidemenuTagline"));
topBar.setUIID("SideCommand");
toolbar.addComponentToRightSideMenu(topBar);
toolbar.addMaterialCommandToRightSideMenu(help_menu_item, ' ', e -> {
toolbar.closeRightSideMenu();
new HelpViewer(appData, mainForm).show();
});
toolbar.addMaterialCommandToRightSideMenu(liability_disclaimer_menu_item, ' ', e -> {
toolbar.closeRightSideMenu();
openDialog(mainForm,liability_disclaimer_dialog_title,liability_disclaimer));
});
....
....
....
toolbar.addMaterialCommandToRightSideMenu(about_menu_item, ' ', e -> {
toolbar.closeRightSideMenu();
openDialog(mainForm,about_dialog_title,about_dialog_text);
});
What can be done to have the same theme for the menu? Or the readability for it?
This video is a bit old but the basic concepts are still applicable: https://www.codenameone.com/how_di_i/how-do-i-create-gorgeous-sidemenu.html
The same concepts can be applied in CSS if you use CSS styling for the app. It's theoretically possible to customize a side menu from code but it would be REALLY hard as the menu is created dynamically internally within the framework.
Related
I tried to add an overlay plugin. https://vaadin.com/directory/component/overlays
I have a problem with image overlay. Im getting that error:
The type com.vaadin.terminal.Resource cannot be resolved.
It is indirectly referenced from required .class file
problem is with this line:
io.setImage(res);
how can I fix it? I put icon-new.png to the class package folder and added into maven overlays plugin
My code:
final ImageOverlay io = new ImageOverlay(button);
Resource res = new ClassResource(this.getClass(), "../icon-new.png");
io.setImage(res);
io.setComponentAnchor(Alignment.TOP_LEFT); // Top left of the button
io.setOverlayAnchor(Alignment.MIDDLE_CENTER); // Center of the image
io.setClickListener(new OverlayClickListener() {
public void overlayClicked(CustomClickableOverlay overlay) {
Notification.show("ImageOverlay Clicked!");
}
});
layout.addComponent(io);
io.setEnabled(true);
I need to achive that on the button will show up an overlay. If the user clicked on this button and added a new content something like taht show up on the button
That's because it's compatible with Vaadin 6 only as it's indicated in the add-on page:
If you scroll to the comments section, someone is suggesting a fork of the add-on compatible with Vaadin 7, but I could not see anything related to 8:
HI ALL! You can find version 1.1.3 for Vaadin 7.6 here: https://github.com/Haulmont/vaadin-overlays/releases
YURIY ARTAMONOV
Add-ons that are compatible with multiple Vaadin versions, indicate this explicitly, and usually (but not necessarily... dev's choice) have different version numbering, eg: 1.x for Vaadin 6, 2.x For Vaadin 7, 3.x for Vaadin 8, etc:
Either way, clicking on the link for a specific Vaadin version, will select the latest add-on release compatible with it. Or, if you select an add-on release from the drop-down, the Vaadin version compatible with it will be updated accordingly.
Edit after update
You can use a regular button + the predefined BUTTON_ICON_ALIGN_RIGHT Valo style. From the javadoc:
/**
* Align the icon to the right side of the button caption. Can be combined
* with any other Button style.
*/
public static final String BUTTON_ICON_ALIGN_RIGHT = "icon-align-right";
Please note that for the best UI result, I've used 24x24 icons, but depending on your requirements you can tweak your theme for the size you need. Also if you don't have icons and don't want to spend money or time buying or creating your own icons, you can use the existing Vaadin Font Icons (list of icons and matching java enum)
public class ButtonWithIconOnTheRightComponent extends VerticalLayout {
public ButtonWithIconOnTheRightComponent() {
// text filed to specify icon URL
TextField urlField = new TextField("Icon URL", "http://files.softicons.com/download/toolbar-icons/status-icons-set-by-iconleak/png/16x16/30.png");
// button which updates its icon using the URL specified in the text field above
Button button = new Button("Update icon", event -> event.getButton().setIcon(new ExternalResource(urlField.getValue())));
// use valo style to align icon to the right
button.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_RIGHT);
// add components to the UI
addComponents(urlField, button);
setSpacing(true);
}
}
I'm stuck with this Codename one UI component for two days and still couldn't get a proper solution...I added tabs in my application but when I run the application, the tabs I added don't look as I expected.
The height of my tab is too big and I want to reduce it.
See the screenshot of how the tab currently looks below:
And here is the code I'm using in my application:
Tabs t = new Tabs();
Style s = UIManager.getInstance().getComponentStyle("Tab");
FontImage icon1 = FontImage.createMaterial(FontImage.MATERIAL_QUESTION_ANSWER, s);
Container container1 = BoxLayout.encloseY();
Container container2 = BoxLayout.encloseY();
t.addTab("Tab1", icon1, container1);
t.addTab("Tab2", container2);
hi.add(BorderLayout.SOUTH, t);
hi.show();
Open your GUI Builder and style the Tab Uiid to reduce the padding as necessary:
Style the Unselected, Selected and Pressed to have the same padding size, see the image below to know the key elements to touch:
I am making a project in eclipse. I have uploaded a .png file using 'image view' option.It has some transparent areas .I want to write code such that it only detects the click of the user's mouse when it is over opaque area and take that user to a new window defined by me.
This code should work in most circumstances.
imageView.addEventFilter(MouseEvent.MOUSE_CLICKED, e -> {
Color color = image.getPixelReader().getColor(e.getX(),e.getY()));
if(color.getAlpha() != 0)
{
//execute your code here
}
});
I'm building a Cordova app and using the excellent cordova-music-controls-plugin to create a notification card with pause/forward/etc. controls.
https://github.com/homerours/cordova-music-controls-plugin
The icon it uses looks pretty naff and if like to switch it out for the ones used on Google's material design icons site.
https://www.google.com/design/icons
I'm very confident with the JavaScript and HTML side of the app, but to make this change I need to edit some Android (I assume Java) code.
Can anybody help by letting me know:
- where I need to import the icon files
- how I reference then in the plugin code
/* Pause*/
nbControls++;
Intent pauseIntent = new Intent("music-controls-pause");
PendingIntent pausePendingIntent = PendingIntent.getBroadcast(context, 1, pauseIntent, 0);
builder.addAction(android.R.drawable.ic_media_pause, "", pausePendingIntent);
You only have to fork the plugin, and replace the icon for the one that you want, keeping the file format, size and name
I am currently developing a JavaFX application with Slovak language localization and inside the application I am using an Alert dialog for showing exceptions with expandable content pane as shown below on images:
I would like to have this dialog completely translated which is going well with Header, Title or Content but I cannot find a way how to translate the Show/Hide details label of the expandable area.
So my question can be a little bit generalized: How to change/translate text of JavaFX internal elements?
Thanks in advance for any help.
PS: For creation of this Alert dialog for exceptions I am using code as found on code.makery.ch
For your particular use case, you can add another listener to expandedProperty which will override the texts shown of "details button":
Platform.runLater(() ->
{
Hyperlink detailsButton = ( Hyperlink ) alert.getDialogPane().lookup( ".details-button" );
alert.getDialogPane().expandedProperty().addListener(
( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue ) ->
{
detailsButton.setText( newValue ? "My less text" : "My more text" );
});
// trigger listeners
alert.getDialogPane().setExpanded( true );
alert.getDialogPane().setExpanded( false );
});
For more common hack see Localizing JavaFx Controls. From there you need to put the following keys to your custom properties file:
// translate these
Dialog.detail.button.more = Show Details
Dialog.detail.button.less = Hide Details