How to reduce the Font of a text in LWUIT TextArea - java-me

I have created LWUIT TextArea,and I have added paragraphs of text to my TextArea ,now i want to reduce my TextArea's font size,I have used the code below:
TextArea big = new TextArea(detailNews.getDescription());
Font createSystemFont = Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_ITALIC, Font.SIZE_SMALL);
big.getStyle().setFont(createSystemFont);
big.setEditable(false);
form2.addComponent(big);
form2.show();
But, why I am not able to reduce the font of my text?

Create font in Resource editor. Then, import the font from resource file in your app. By using this method, you can apply any font to your app that is installed in your system. You can also set any font size to the font.
Explore the link to know how to create font in resource editor.
http://docs.oracle.com/javame/dev-tools/lwuit-1.4/LWUIT_Developer_Guide_HTML/cjbcgcdd.html#z400088e1296018

Use:
TextArea big = new TextArea(detailNews.getDescription());
Font createSystemFont = Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_ITALIC,Font.SIZE_SMALL);
big.getUnselectedStyle().setFont(createSystemFont);
big.getSelectedStyle().setFont(createSystemFont);
// Added TextArea object big to the Form object form.
form.addComponent(big);
form.show();

Related

Using PathMenu with SVG in a Paintcode StyleKit

I need to change the image programmatically that PathMenu uses to design.
I have a PaintCode generated StyleKit which draws .SVG files, not an image in a Asset.xcassets.
PathMenu uses something like this to take the images:
let menuItemImage = UIImage(named: "bg-menuitem")!
but I need to make something like
let menuItemImage = myImageFromMyStyleKit
How can I make this work?
In PaintCode document, select canvas and in Inspector, select StyleKit Image Method from dropdown menu in Code Export section.
This canvas will then generate imageOfCanvas... method, instead of drawCanvas... method. This way, you can then simply obtain image of this canvas and use it in the menu item.
PathMenuItem(image: StyleKit.imageOfCanvas)

How to set the global font of word file via Apache poi?

I'm a newbie of apache poi, and am using poi to write some data to docx file. Recently I encountered a problem of font, hope any body can give me some help.
I began the writing with an empty word file named empty.docx, as following.
InputStream input = getClass().getClassLoader().getResourceAsStream("empty.docx");
XWPFDocument document = new XWPFDocument(input);
In the empty.docx the default font is 'Arial', that means if you add any content they will inherit this font as long as you don't change the font manually.
But after I filled the content and write it to a new docx file,the default font was changed to 'Century'.
OutputStream output = new FileOutputStream("output.docx");
document.write(output);
I want to change it back to 'Arial', but after a lot of search only found the methods to set font of XWPFRun.
run.getCTR().getRPr().getRFonts().setEastAsia(eastAsiaFontName);
run.getCTR().getRPr().getRFonts().setHAnsi(normalFontName);
I want to know if there is any method to change the global font of the whole document?
You can set the default font of the document like this (using your variable names):
XWPFStyles styles = document.createStyles();
CTFonts fonts = CTFonts.Factory.newInstance();
fonts.setEastAsia(eastAsiaFontName);
fonts.setHAnsi(normalFontName);
styles.setDefaultFonts(fonts);
I am currently stuck at how I set the default font size. That's why I found this question... The XWPFStyles class has a member "CTStyles ctStyles" with which it would be possible to define any property defined in the XML spec. But unfortunately it has only a public setter, but no getter.

Using a Webview in a splitview controller

I'm having trouble displaying content properly in a splitview application. In the detail view I have a webview and I'm loading locally saved html files. However the files don't display properly - they are slightly zoomed in and missing detail on the left and right. Double taping them zooms them out and they display correctly. I have scaletofitpages=YES set.
Any advice?
Well, if i'm understanding you correctly, you can use auto layout.. it will fit your content from left and right.
to set the font size you must edit your html content add "css style" to them...
// Get result into string format
NSString *htmlData = [objSQLiteProtocol getDatabaseResults:fileNameToRead];
// reduce the size of font to set in iPad
htmlData = [htmlData stringByReplacingOccurrencesOfString:#"25pt" withString:#"12pt"];
[moreWebView loadHTMLString:htmlData baseURL:nil];
moreWebView.scalesPageToFit = YES;

JavaFX HTML styling (or equivalent) labels

In Swing, it was trivially easy to style a JLabel using HTML - you simply used the HTML you wanted as the text for the label, and it was rendered appropriately.
In JavaFX this isn't available, but we can set the style of a particular label (or node in general) using the setStyle() method.
However, using this approach it's not obvious how to set part of a label to be a certain style, for instance the equivalent of:
JLabel label = new JLabel("<html>Part of this <b>text is b</b>old and part isn't.</html>");
What would be the easiest way to achieve something like the above?
You can try using TextFlow to combine different styled text nodes like
TextFlow textFlow = new TextFlow();
Text first=new Text("Part of this ");
first.setStyle("-fx-font-weight: regular");
Text second=new Text("text is b");
second.setStyle("-fx-font-weight: bold");
Text third=new Text("old and part isn't.");
third.setStyle("-fx-font-weight: regular");
textFlow.getChildren().addAll(first, second, third);
Pseudo-selectors could have been a work-around but unfortunately most of them are not supported yet - http://docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html#introlimitations. As for Rich Text Support in controls, they will be provided by JavaFX8 - https://bugs.openjdk.java.net/browse/JDK-8091709.

How to properly Set Background Color of LWUIT Widget that is already themed?

I tried the following code:
final Container root = getRootAncestor(c);
TextArea resultBox = findResultBox(root);
Style style = resultBox.getUnselectedStyle();
style.setBgImage(null);
style.setBgColor(0x00ff00);
style.setFgColor(0xff0000);
resultBox.setUnselectedStyle(style);
resultBox.setSelectedStyle(style);
What works is only the font/foreground color, however the background color persists (it still uses the background image from the theme). I also tried:
style.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED);
style.setBgImage(Image.createImage(1, 1, 0x00ff00));
But this also doesn't work.
Using LWUIT 1.5.
Try setting the background transparency to opaque: 255. Its possible that the color is just transparent. Creating a bgImage overrides color settings so make sure the image is set to null.

Resources