Creating a visual user interface to receive text input using java? - java

I have worked with Java in the past but have never created a visual user interface, only programs that read from the command line. I would like to create an interface that displays a box with text stating the required input on the left and on the right a blank text field that can be read from by the program. This is for a web app I am working on at my internship, I have very little guidance and would really appreciate any help as I am completely lost at this point. The program currently only reads line by line which is obviously unacceptable for a web app.
Thank you so much for any assistance you can offer.

You can use the browser as your user interface. Create an HTML file to create your form for the user to enter data (which they view in a browser like Google Chrome) and submit back to your app. JSP files are the java equivalent of HTML files with optional java code inside. Download the Eclipse IDE and the Tomcat server and run one of the tutorials for creating a web app. Here's a link to start: https://eclipse.org/webtools/community/tutorials/BuildJ2EEWebApp/BuildJ2EEWebApp.html

Related

Is there a way to replicate an IDE's console like Eclipse, or NetBean's on a website?

I've created a website portfolio and I want to show some of the projects I've done. But so far the many of the projects I've done have been in java, or C/C++ and the interactive/fun programs take input from the console.
I was wondering if there was a way to simulate those program using JavaServer Faces and taking input from a textbox (possibly) to be used in the java program I've created and posted back to the website.
Just to give you an idea of the kinds of programs I'd like to show. They range from simple things like determining if the entered data from the user is a leap year to a text I/O credit card validation program I've made up.
If my question is clear enough, does anyone have any ideas about how I can show the programs I've created?
I thought of creating a java class that writes the output data from the java file in a String and then posts that to the webpage, but then the user would have to frequently refresh the page. So I thought if I could somehow simulate the console on the website that would take care of that problem.
Extra: Is there any easy way to display javafx programs on a website?
Thank you in advance!

Call Java-Methods in browser

my main Problem I is that I'm new to this topic and don't know how to successfully google it.
I have a Java-program up and running which is just console-based (no GUI). I want to have a browser interface for it. I want to know how to:
Make a Link on a HTML-Page so that it calls a method in the java-program when clicked
print text from the java-program to the Html Page
enter Strings in a Input field and pass them to the java program
Simple exaample: A simple page with one input field, one "submit"-button and one text field. I enter a name, press submit, the java code gets the string, manipulates it, passes it back to the html page where it is displayed.
The question might seem simple but I need a place to start. Any tutorial link would be very welcomed.
Cheers
Google for Java Servlet programming for beginners
couple resources:
http://www.journaldev.com/1877/java-servlet-tutorial-with-examples-for-beginners
http://www.youtube.com/watch?v=tkFRGdUgCsE
I strongly recommend to study Java 2 Standard Edition before dealing with servlets.
You need to deeply understand how does the core java work, and only then approach to more complex technologies.
Good luck.

Web Browser in a Java Application

How can I open a webpage from a java application and enter username and password into it? I have seen questions here where people have referred to lobo or DJ Native Swing.
But as I am very new to java these libraries seem quite complex to me and I can not find a good tutorial in it, please refer to some good library with a solid tutorial which can be a beginning ground for me.
Note: I am developing a Java Swing application and show the user a page opening and user name and password being submitted.
What application do you develop? Web? Desktop/swing? Console? Mobile?
Take a look at Apache's HttpComponents project
It is not clear what you want to do.
1) Do you want to show it to the user?
join to WebKit browser in Java app on multiple platforms
2) You want to fetch some data from a web page that requires login?
then you should join to HttpClient login, search and get the XML content
Your question is not clear, are you trying to write a java application that will open a browser and enter data automatically?
If this is what you want then you can use selenium, a plugin for Mozilla. You can record your mouse movements, all your actions will get recorded as a jUnit test case.
You can then modify this junit test and read in the usernanme and password programatically from a file (or what ever you are trying to do.). This test can be run as a stand alone java application.

Launching a website from within a program, and inputting data to specific fields

Although I've been programming for a few years I've only really dabbled in the web side of things, it's been more application based for computers up until now. I was wondering, in java for example, what library defined function or self defined function I would use to have a program launch a web browser to a certain site? Also as an extension to this how could I have it find a certain field in the website like a search box for instance (if it wasnt the current target of the cursor) and then populate it with a string and submit it to the server? (maybe this is a kind of find by ID scenario?!)
Also, is there a way to control whethere this is visible or not to the user. What I mean is, if I want to do something as a background task whilst the user carries on using the program, I will want the program to be submitting data to a webpage without the whole visual side of things that would interrupt the user?
This may be basic but like I say, I've never tried my hand at it so perhaps if someone could just provide some rough code outlines I'd really appreciate it.
Many thanks
I think Selenium might be what you are looking for.
Selenium allows you to start a Web browser, launch it to a certain website and interact with it. Also, there is a Java API (and a lot of other languages, by the way) allowing you to control the launched browser from a Java application.
There are some tweaking to do, but you can also launch Selenium in background, using a headless Web browser.
as i understand it you want to submit data to a server via the excisting webinterface?
in that case you need to find out how the URL for the request is build and then make a http-call using the corresponding URL
i advice reading this if it involves a POST submit

How to programatically send input to a java app running in a browser window?

Consider the most excellent wordle tag cloud generator:
http://www.wordle.net/create
Entering text into the "textform" textarea and clicking the go button starts up the wordle java applet on that page. No traffic goes back to the server.
How can I cause this to happen programmatically? No hack too cheap!!
background for this question:
"tag cloud" generators?
If you mean starting it programmatically from a browser page, you can use the same type of JavaScript that that page uses, which calls the function Wordle.t() to start the applet.
If you want to call it from a Java program, you can download the Wordle.class or jar file yourself, and call the functions directly.
I'm the creator of Wordle.
In case anyone finds this page in the future, I thought it would be useful to explain that Wordle invokes its applet by constructing an applet tag with a huge <param> containing a sanitized version of whatever text you pasted in. It is the cheapest hack imaginable.

Categories