Dynamic manipulation of font components - java

I am developing an application to dynamically change the components of a font which is already displayed on screen.
Let me explain this . Suppose I have typed a letter in a certain font style on the screen.
On click of a button I need to change the pixel density on the text to change like this
Is this possible with Java.

Related

Vaadin - adding text on top of an image

I am building a custom layout with Vaadin and I have Images that act as buttons (with a clicklistener). However I also need to display some text and I would like to display it over the image, so inside the image really. Is this possible and if yes, how?
Image dayCourt = new Image(null, new FileResource(new File(basepath + "/VAADIN/images/9_Available_18_Available.png")));
However I also need to display some text and I would like to display it over the image, so inside the image really. Is this possible and if yes, how?
The most straight forward way to do this is to wrap Image and Label (with the text you want to place over the image) inside CssLayout. Then you need to add style name to the label. In your theme you need to set z-index for the Label (so that it floats on top of image) (see: https://www.w3schools.com/cssref/pr_pos_z-index.asp ) and position absolute to Label (see: https://www.w3schools.com/cssref/pr_class_position.asp) relative to corner of the CssLayout
Also, if your Image happens to be static content, i.e. you do not have need to change the image on the fly, you could have even simpler solution. Instead of thinking composite of two components inside CssLayout, you could have only the Label and set the image from theme resources to be the background of the Label (see: https://www.w3schools.com/cssref/pr_background-image.asp).

Change EditTextPreference widget color in XML?

I have been having a tuff few days with the EditTextPreference object. No matter which emulator I use this on, it seems to change color slightly but always makes my text the same color as the widget itself. (Yes, I know it's not really a widget).
I can change the TEXT color and the BACKGROUND TEXT color in the XML code, but this does not help because the "CANCEL" and "OK" confirmation buttons (which are part of the widget)to tap are yellow and impossible to see on the white widget background.
Is there any way in XML to make this widget a different color? This has been very frustrating.
You can set background colour of any widget by property
android:background="#ffff00"
enter any hex code at place of #ffff00
You can pick up hex code from here
you can also set a picture as a background of widget
android:background="#drawable/your_image"
place your_image in drawable folder

Moving JButton text over its icon by pixels

I am creating a desktop application in Java with lots of customized UI.
It also has a breadcrumb.
I've extended JButton class to customize it for my Breadcrumb buttons.
This is the screenshot of expected breadcrumb.
http://puu.sh/4MtvZ.jpg
The background of this breadcrumb is an ImageIcon.
But now, I am not able to perfectly align the JButton text over this background icon.
This is the screenshot of actual breadcrumb.
http://puu.sh/4MtDc.png
I've used following code to align the text.
setHorizontalTextPosition(CENTER);
setVerticalTextPosition(CENTER);
So, is their a way that I can move this text in pixels to its right position?
And also, I want root breadcrumb button "Schemes" to overlap some part of its preceding breadcrumb button "2000 Avenues" as shown in expected breadcrumb screenshot!
How can I achieve that?
Check out the Overlap Layout for one solution.
So, is their a way that I can move this text in pixels to its right position?
I don't understand this question. Why are you setting the alignment to center if you want it aligned to the left.
Edit:
I see. You are just using an Icon for the button outline and are then painting the text on top of the Icon. I thought your were using a custom shaped button with text). You can just use the default vertical/horizontal text position settings.
To shift the text to the left you can use:
button.setIconTextGap(10 - button.getIcon().getIconWidth());

Getting graphical buttons to line up in xml

I have a custom popup window with a custom image background in which I need to place three custom buttons with their own background images. I have only one set of images for all the components, so I want all the parts to scale appropriately. My question now is how do I make sure that the buttons line up with the appropriate parts of the background image of the popup window. I have been experimenting with all sorts of widths and heights and I can not make it look consistent on all my test devices. Can anyone give me some pointers?
EDIT: Just to make it as clear as possible, the image below illustrates the kind of thing I am talking about:
I want the graphical button to line up with the arrows which are a part of the popup window background image.
arrange buttons in an xml layout and set this view to your custom popup and you can set images to buttons from code.

how to make java run time sizable image box

I'm making a Unicode translator in Java. I did all hard parts, but now I want to add a resizable, relocatable image to the textpane. The user must be able to resize image with its corners and drag & drop the image within the textpane where he likes. (like Microsoft Word or Photoshop)
Something like this:
I tried the Styled Document properties. But I couldn't find way except inserting only an ImageIcon.
May be a better choice would be not to use textPane.
If you have an custom editable label, that can be edited by double clicking on it to show a text box to edit the contents, and change the text of the label when enter key is pressed.
Also give a shot of JDesktoppane, JLayeredPane, and check what components can be added to it.
try this
http://mgeisler.net/downloads/browser/src/ImageBox.java.html
try loading the image inside a JLabel component in JFC Swing.
Otherwise try some other non editable components in the same technology with resizable property.
try this http://sourceforge.net/projects/ird/
the iRD is a component for Resize and move(drag&drop) compoennts on runtime in java.

Categories