I am currently working on a Java applet. The Java app has a text box which only allows plain text (Java code) to be written which will then be converted to visually represent the codes written by the user, i.e assume the user has created a linked list, I have to display the linked list using Grahics2D to draw boxes and all. I'm not able to interpret the codes written by the user in the text area. I would be very grateful to receive some of your help.
I have tried to solve the issue using Beanshell like this:
Interpreter bsh = new Interpreter();
bsh.eval("import java.lang.String;");
bsh.eval(srcCode);
Where srcCode is the text I have retrived from the text field like this:
txtCode.getText()
The interpreter is not able to compile classes written by the user.
How could I solve the issue I'm having?
Related
I'm a beginner in android studio and was working on it for last few weeks and finally stuck with a problem. so how can we extract data entered in the text widgets to use them in our java code. For example I was working on making an application where the user will enter any random sequence of digits in a edit text widget and then can choose any sorting methods I've provided using buttons , after that the result will be shown in a text view widget. But in order to do this I need to have access to the data user have entered in the edit text widget. I already know that we can get their data using getText() and setText() but it's not working when I'm trying to
store the data in a normal primitive variable. I want to know how can I store that data in a normal java primitive variable to use them in my java code.
Any help would be appreciated.
Let me start off with saying that I've seen some questions in this regard but nothing actually specifically answering my issue.
Let's say I have a template version of a PDF received by someone else. It's a classic PDF that looks like a form but only one part is editable, the other parts are not because they are being filled in with data from an imported excel sheet. (Sadly I can't show an example)
I've been able to do most in iText 7 but I can't figure out for the life of me if I can change a flat text field into an editable form field, like on image 1.
Image 2 shows checkboxes that I want to make editable as well but I can only change their value within java and even then it only shows a cross, not a checkmark (even if I change the checktype).
It's a bit hard to explain but tl:dr is that I just want to know whether I can edit an existing flat PDF in java or if I have to do so in adobe itself.
Thanks
I followed the OCR text reader guide on Codelabs (https://codelabs.developers.google.com/codelabs/mobile-vision-ocr/#0).
Now, I would like to save, a single portion of the text that I am scanning.
I tried with reducing width, and height of the preview; but it doesn't work, the APK crashes (at least on the only device I have to test it).
I am completely new to Java, and Android development, but my Internship mentor said to do this; completely alone, with zero help (as no one in the company knows about development).
So, the app opens, it recognizes text. Now, I would like to to know if there is a way to take that text, and save it (XML or TXT file).
I tried to look in the code, and see if at some point, the text read is saved in a variable or something; but it looks like a live preview, done trough the Google's dependencies (or a similar process).
I am not sure, but this might be off topic, as it is similar to an open question, but I am giving details on what I have done so far, and what I have tried.
Thanks.
The detected text is displayed in the OcrGraphic.draw(Canvas) method. There, it is returned as a TextBlock. You can call textBlock.getComponents() to get the lines and textBlock.getComponents() again to get each individual word (as a Text object).
Then you can convert it to a string and write the text to a file if you would like.
How can I do password masking (to hide an input text from terminal window) in Java?
I got the solution of using the console but I want to do it in an IDE (BLUEJ) ,which is not possible using the console. I want help.
The console in any IDE or terminal/command line can not be edited after something is printed out in it and simply prints what you ask of it and takes in input that you type.
However, if you are working with a GUI in Swing or JavaFX, you can display your text in a JPasswordField or PasswordField which hides the input as its typed while still storing the correct string values.
I am working on a project of question paper generator(offline) which requires the the user to input the questions. Obviously there will be some questions of mathematics as well hence I need to invoke or create a text editor that will create mathematical expressions such as integral symbol or limit operator etc.
I am using java swing GUI and mysql database to achieve the purpose and hoping to use JEditorPane for text area.
Please help me , I took about a day to search the internet to solve this problem.
And also I need to know whether the mathematical expression the text editor will create could be stored in mysql database column?
Things I tried:-
Tried changing the text type of JEditorPane to text/html but I realised that I can add subscript, superscript and even images but this wont add that beautiful LaTeX mathematical expressions and many complex operators.
Tried using JMathTex but I couldn't resolve how it will enable the user to input the expressions, according to me JMathTex is not the solution to my problem.
Even thought tries of using MathJax but it requires java script and JEditorPane does not support java script.
I repeat the problem, I want to create a text editor (just like MathType) in my swing application so that user can input the question along with the required expressions so that the question can be added to database for random generation.