I trying to build web app in Hebrew.
but all of the components or Navbar are LTR.
how can I make my NavBar or all my site to be RTL?
onemore question can I change the style of the navbar?
#Viewport("width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes, viewport-fit=cover")
#Theme(Lumo.class)
#Route
#PWA(name = "SimpleIT", shortName = "SimpeIT")
public class MainView extends AppLayout {
public static final String ITM_DASHBOARD = "DashBoard";
private Map<Tab, Component> tab2Workspace = new HashMap<>();
public MainView() {
// setPrimarySection(Section.DRAWER);
Image img = new Image("https://i.imgur" +
".com/GPpnszs.png", "Vaadin Logo");
img.setHeight("75px");
addToNavbar(new MenuBar(), img);
Tabs menu = new Tabs(dashBoard()
,new Tab("Customers"),new Tab("Todo"),new Tab("Tickets"));
menu.setOrientation(Tabs.Orientation.HORIZONTAL);
menu.addSelectedChangeListener(event -> {
final Tab selectedTab = event.getSelectedTab();
final Component component = tab2Workspace.get(selectedTab);
setContent(component);
});
addToNavbar(menu);
this.setPrimarySection(Section.NAVBAR);
setContent(new Span("click in the menu ;-) , you will see me never again.."));
}
private Tab dashBoard() {
final Span label = new Span("DashBoard");
final Icon icon = DASHBOARD.create();
final Tab tab = new Tab(new HorizontalLayout(icon,label));
tab2Workspace.put(tab, new DashBoardView());
return tab;
}
}
You can turn RTL by adding the CSS rule direction:rtl to the body. Alternatively you can use the RTL mode add-on that does that for you: https://vaadin.com/directory/component/rtl-mode/discussions
Many of the component work in RTL mode, but some have still some issues. They will be hopefully fixed in the first half of 2020.
Updated information: RTL is officially supported since Vaadin 14.3 (LTS) and Vaadin 17: https://vaadin.com/blog/localization-gets-an-update-with-right-to-left-rtl-support
Related
I am new to selenium automation and while learning radio button handling in selenium, I tried to automate language setting in amazon.in page. I am unable to select the radio button listed in the page.
site: https://www.amazon.in/customer-preferences/edit?ie=UTF8&preferencesReturnUrl=%2F&ref_=topnav_lang
code used: driver.findElement(By.xpath("//input[#value = 'ta_IN']")).click(); (I tried to select the language tamil- TA (3rd radio button)). Can anyone guide me in this?
public class seleniumTutorial2 {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.amazon.in/customer-preferences/edit?ie=UTF8&preferencesReturnUrl=%2F&ref_=topnav_lang");
driver.manage().window().maximize();
driver.findElement(By.xpath("//input[#value = 'ta_IN']")).click();
}
}
'''
try using this xpath://span[text() = 'TA']
driver.findElement(By.xpath("//span[text() = 'TA']")).click();
Maybe try to click on //input[#value = 'ta_IN']/following-sibling::i
I'm currently trying to make a custom button using JavaFX. I have defined 2 styles that contain 2 different images for 2 button states(Pressed and Free). I'm using Intellij Idea and when defining the paths it shows no error's, but the button doesn't show up. Its just transparent, but I can click it. I have tried specified different paths, but haven't gotten any result. Here is the code where I define the styles and my file tree. Thanks!
public class CustomButton extends Button {
private final String FONT_PATH = "src/Resources/GUI/pixelFont.ttf";
private final String BUTTON_PRESSED_STYLE = "-fx-background-color: transparent;" +
" -fx-background-image: url('../../Resources/GUI/Buttondown.png');";
private final String BUTTON_FREE_STYLE = "-fx-background-color: transparent;" +
" -fx-background-image: url('../../Resources/GUI/Buttonup.png');";
public CustomButton(String text) {
setFont();
setPrefWidth(180);
setPrefHeight(53);
setText(text);
setStyle(BUTTON_PRESSED_STYLE);
initButtonListeners();
}
}
File tree
Moving all of the files into the pre-generated by Intellij Idea resources folder and then using that folder solved the issue.
I am using Apache POI to modify a pptx. I would like to change the font of the whole pptx at once.
I know in Powerpoint this is possible by changing the fonts of the theme (if the slides all use these fonts), but I cannot make it work through Apache POI.
What I found so far is that I can set the font family of a single XSLFTextRun by using e.g. run.setFontFamily(HSSFFont.FONT_ARIAL).
Edit: I found that the XSLFTheme Class of the XSLFSlideMaster does have a getMajorFont() and a getMinorFont() method. I think these might be the fonts I need to change, but there are no setters for these fields.
Thanks for your help!
If your attempt is to do the same as Change the default font in PowerPoint, then this changes the major font and the minor font of the font scheme in used theme.
You can get XSLFTheme from each slide of the slide show, so also from the master. But as you found already there are getters but no setters for major font and minor font. So we need using low level ooxml-schemas classes.
Following code example provides setMajorFont and setMinorFont method which sets type face of major font and minor font in the theme for either Latin script, east Asia script or complex script.
import java.io.FileInputStream;
import java.io.FileOutputStream;
import org.apache.poi.xslf.usermodel.*;
import org.openxmlformats.schemas.drawingml.x2006.main.*;
public class PowerPointChangeThemeFonts {
enum Script {
LATIN, //Latin script
EA, //east Asia script
CS //complex script
}
static void setMajorFont(XSLFTheme theme, Script script, String typeFace) {
CTOfficeStyleSheet styleSheet = theme.getXmlObject();
CTBaseStyles themeElements = styleSheet.getThemeElements();
CTFontScheme fontScheme = themeElements.getFontScheme();
CTFontCollection fontCollection = fontScheme.getMajorFont();
CTTextFont textFont = null;
if (script == Script.LATIN) {
textFont = fontCollection.getLatin();
textFont.setTypeface(typeFace);
} else if (script == Script.EA) {
textFont = fontCollection.getEa();
textFont.setTypeface(typeFace);
} else if (script == Script.CS) {
textFont = fontCollection.getCs();
textFont.setTypeface(typeFace);
}
}
static void setMinorFont(XSLFTheme theme, Script script, String typeFace) {
CTOfficeStyleSheet styleSheet = theme.getXmlObject();
CTBaseStyles themeElements = styleSheet.getThemeElements();
CTFontScheme fontScheme = themeElements.getFontScheme();
CTFontCollection fontCollection = fontScheme.getMinorFont();
CTTextFont textFont = null;
if (script == Script.LATIN) {
textFont = fontCollection.getLatin();
textFont.setTypeface(typeFace);
} else if (script == Script.EA) {
textFont = fontCollection.getEa();
textFont.setTypeface(typeFace);
} else if (script == Script.CS) {
textFont = fontCollection.getCs();
textFont.setTypeface(typeFace);
}
}
public static void main(String args[]) throws Exception {
XMLSlideShow slideShow = new XMLSlideShow(new FileInputStream("./PPTX.pptx"));
if (slideShow.getSlideMasters().size() > 0) {
XSLFSlideMaster master = slideShow.getSlideMasters().get(0);
XSLFTheme theme = master.getTheme();
setMajorFont(theme, Script.LATIN, "Courier New");
setMinorFont(theme, Script.LATIN, "Courier New");
}
FileOutputStream out = new FileOutputStream("./PPTXNew.pptx");
slideShow.write(out);
out.close();
slideShow.close();
}
}
I wish to use one of my local sound files to provide background music, but I get this error message:
Caused by: java.lang.UnsatisfiedLinkError: Can't load library: C:\Program Files\Amazon Corretto\jdk1.8.0_232\jre\bin\glib-lite.dll
But my code is as follow:
public class DungeonGUI extends Application {
private Dungeon dungeon;
private Stage stage;
private GridPane root;
private Button attack;
private Button heal;
// private Button checkInventory;
private Button save;
private Text characterHealth;
private Text characterPower;
private Text characterInventory;
private Text monsterHealth;
private Text monsterPower;
private File audioFile = new File("C:/Users/15774/Downloads/oof.mp3");
#Override
public void start(Stage stage) throws Exception {
setButtons();
dungeon = new Dungeon();
setTexts();
this.stage = stage;
root = new GridPane();
heal.setOnAction(this::onHeal);
attack.setOnAction(this::onAttack);
save.setOnAction(this::onSave);
stage.setTitle("Dungeone Dungeon");
root.setAlignment(Pos.CENTER);
setMedia();
setupRoot();
setStage(stage);
}
private void setMedia() {
Media media = new Media(audioFile.toURI().toString());
MediaPlayer mediaPlayer = new MediaPlayer(media);
mediaPlayer.setAutoPlay(true);
}
As you can see I did not call program files at any time. What might be the problem?
P.S.: this is only part of my code. If you guys need more information just shoot a comment.
Amazon Corretto for Java 8 does not support JavaFX. See here for full insight. However, as short, I refer to the following quote from the page:
The recommended way of using JavaFX is with Corretto 11 and pulling in OpenJFX separately e.g. with a Maven dependency. The latest version (currently 14) is compatible with Corretto 11.
src: Corretto's github
jccampanero also here answered a similar question.
I'm using the following to show a cross in a label, that accompanies an if statement.
JLabel.setIcon(new ImageIcon(path + "Resource/cross.png"));
Instead of loading the icon everytime I would prefer to have it imported into my project and call it from there. I know how to import it but how do I modify the line of code above to point to the imported icon.
you can create a static loader methode (in an utility class) and store it there
private static Map<String, Icon> lookUpMap = new HashMap<>();
public static Icon getImageIcon(String res){
Icon icon = lookUpMap.get(res);
if(icon = null){
icon = new ImageIcon(res);
lookUpMap.put(res, icon);
}
return icon;
}
you can access the icons now everywhere
JLabel.setIcon(UtilitClass.getImageIcon(path + "Resource/cross.png));