Unicode character ("\u232B") does not display on button - java

I'm building the keyboard of a calculator application for Android.
I'm using the unicode but the application did not display the button "erase to left"
static String[][] screen2L ={{"sin","asin","sinh","asinh","sind","asind","\u232B","AC"},
{"cos","acos","cosh","acosh","cosd","acosd","log2","gamma"},
{"tan","atan","tanh","atanh","tand","atand","log10","ln"}};
thanks

Unicode characters are not supported in all fonts. Check here to see the supported fonts for \u232B
Instead of using the character, make an image of the character and set it as the buttons background. A post that can help with that has already been answered here: How to make button with custom background image...
Also, as for using strings in java to print in your GUI, it's better practice to use xml for this. The buttons individual values would be stored to the app instead of having to assign them every time the app is run. I would write out instructions on how this is done, but the android developers guide that can be found here gives much better instructions than I could.

Related

Dynamically highlighting strings in javaFX

Please read before labelling this as a duplicate.
I am creating an application that calculates how fast a person can type by calculating WPM and CPM. However I have hit a snag with the UI as I found out that you cannot really highlight individual strings in a TextArea. My goal is to compare what the user is typing to the random text that is generated by having it so that the text is being dynamically coloured or highlighted as the user is typing.
See http://10fastfingers.com/typing-test/english to get an idea of what I mean
I recently read the following post Highlighting Strings in JavaFX TextArea
I was trying to achieve the same goal of highlighting individual strings inside a javaFX TextArea until I realised that it pretty much is not possible. So I looked into TextFlow which does allow me to edit individual strings. The problem with TextFlow is that all 200 of the generated words would have to appear at once which is not what I want. With a TextArea not all the text has to be displayed at once.
This is what I have so far just so that you can further get an idea of where I am heading with this.

getting square emoticons instead of actual emoticons

I am working a java chat application and I am adding emoticons by replacing the emoticon shortcut, like :) ,with ◕‿◕ . Its not an image that I am replacing it with but simple text. Now the problem that I am facing is that sometimes I get just Square boxes instead of the actual thing that I want. I am making these images/texts in MS Word by converting the unicode to the actual image. I am also using various online resources to get these images/text.
Can anyone tell me how to get rid of the boxes and get the actual text.
My encoding is in UTF-8 and my font is also set to monospaced.
Your unicode-character is probably not supported by your font. Either the font implements the character as a box, or the operating system / font-renderer draws a box instead of the glyph.
I would say the Font used in your application just cannot show some chars. Find one which font really can and use it there.
Font has boolean canDisplay(char c) method which you can use.
See also the doc about font

Sending Unicode Text to Cursor Position in Java

Doing linguistics and phonetics, I often need to use certain special phonetic symbols. Although I'm using a special keyboard layout that enables me to write some of those characters by typing, they key combinations can often get both quite complex and highly repetitive, so I would like to create a litle app that would contain some buttons, perhaps, each of them capable of sending a specified (phonetic) symbol to whatever the current cursor position is, no matter what window on one's screen is in focus.
Is anything of this sort possible to do in Java?
I've seen a solution that copies the values into clipboard and then pastes them (Java paste to current cursor position), but that is not a very clean way to do it, is it? Is there a way better than just pasting the charactedr(s) via ctrl+V?
Many thanks for any help or advice in advance!
P.
You can use the AWT Robot to generate key press events. This will not provided the ability to insert arbitrary unicode characters but you can combine it with the technique you already described: transfer the unicode characters to the clipboard and generate a CTRL+V key event afterwards. You can try to save and restore the original clipboard content but this will work with types supported by Java only.
The focus problem mentioned in the comments can be solved by setting the window to not receive the focus via Window.setFocusableWindowState with an argument of false.
An alternative is to provide the unicode text via drag&drop. Most applications support dropping text in their input fields. The code for exporting the text is very similar as both, clipboard and d&d use the same interfaces in Java.

Simple text formatting, such as superscript, in Java? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How do I write superscript word for checkbox text in java?
So I have this very simple program that basically consists of a GUI with a few text fields and a button.
The idea is that the user enters numbers into three fields and presses the button. Then what happens is a few mathematical procedures are carried out in the background, and the resuling answer is presented in a fourth text field.
Now, this does the job, but the formatting looks awful. At the very least, I would like to have part of the output superscripted. I have next to no experience with these things, but thought I would be able to get the hang of this on my own, but I'm stuck. I think I need to use AttributedString and possibly Font, but I can't get anything to work. And I've found no tutorials.
Does anyone have any quick pointers? That'd be most helpful!
Do you need the output field to be editable? If not, try using a JLabel with HTML code. Something like:
jLabel4.setText("<html>ax<sup>2</sup>+bx+c</html>");
You can add a border to that JLabel to make it look like a text field.
Why not use other swing components that support HTML to display the answer like JLabel. If you use a JLabel for instance you can use inline html to format your answer
The reasons you are having difficulty has to do with the lack of a default typsetting system. Font selection and such typically provides a very limited means to do proper math typesetting (which is a specialized subset of general typesetting).
I don't know of any math specific typesetting already built-in to the Java libraries, that said, perhaps you can integrate the ExTex project into your Java components or roll your own solution using the 2d API (look at baseline offsetting).
Other alternatives are to generate a graphic, and display it's rendered image. If the display is static, this might be a much easier choice.

showing Alphabets in spinner

Howdy,
I am writing a GRE app on android.i am new in this arena.
I want to show all the alphabets in the spinner control. what is best way to do it and how can I do it. Can some share the code.
Like in .NET , i would have filled an array with all the chars A-Z. then have called toChar and bind it with combo control.
I dont how to did the same think java and android ?
Do a search first, Anyway here is the tutorial
http://developer.android.com/resources/tutorials/views/hello-spinner.html

Categories