Java how to render a program with GUI - java

I made a program that has Buttons and TextFields and is it possible to make and feel like real program. And render the program so that i can run in folders etc.

In Java you can use Swing or JavaFx to make GUI applications. Here is another link for JavaFx.
If you want to export your GUI as an application that you can double click and run from your Desktop, you can export as a runnable jar. To do this in eclipse go to File -> export -> Java -> Runnable Jar and then choose the destination etc... Also see this answer for more information on different ways to make a java file executable.

Related

Open another Java application from existing Java program

I'm building a Java tutorial where there is a button when clicked, opens a notepad application which I built. However how do I go about opening the notepad application in the ActionListener? Should I use ProcessBuilder?
If your separate program is a compiled .jar file, use the following code to launch it, but note you will not have any control over it.
Runtime.getRuntime().exec("java -jar 'path/to/file.jar'");
Note this method returns a Process object, which you can then modify to your individual needs.

Setup icon correctly in IntelliJ so that is gets compiled with program (to jar)

I've been learning Java at my university and the programs we made as homework assignments are quite nice. But I've been playing around with some extra features to learn more. I've created a GUI for a program using Swing and AWT. I've added an icon to the JFrame and when I run the the program in IntelliJ the icon is there. But when I try to compile the program into a JAR file the icon doesn't get compiled with it for some reason.. Is there a way to make this work?
The way I've currently set it up is as follows:
ImageIcon image = new ImageIcon("resources/icon.png");
This is how I've declared the image which is in the resources map of my project, I've marked this resources folder as a resources folder in the project structure under modules.
Then I set the icon as following:
frame.setIconImage(image.getImage());
The name of my JFrame is frame, this all works when running the program within IntelliJ but when I make a jar file it doesn't seem to be able to use the icon ;/
Does someone know how to fix this? I really like to learn from it so some extra explanation would be really nice!!

Java Console In Eclipse, But What If Using As Jar?

So,
I have made a little game in eclipse, it generates a rondom number from 1 - 1000 , when playing out of Eclipse, it plays in the eclipse console, but what if i want to play it without eclipse?
There is no console showing up?
Anyone a idea on how to fix this?
EDIT : I would like a new GUI instead of CMD.
Grts
PS: Tell me if you need a specific part of the source code
1) You should probably export your program as a .jar file.
This isn't absolutely necessary - but it's better. And it sounds like you've already done it :)
2) Be sure to specify the main class in Eclipse before you export the .jar
3) Once you have the .jar, you can:
a) execute "java -jar myjar.jar" from a command prompt (for a console-mode program)
b) execute "javaw2 -jar myjar.jar" from a command prompt (for a Swing/GUI program)
4) You can also set a "file association" with javaw in Windows so that you can just double-click on the .jar to execute it:
Running JAR file on Windows
It seems the OP wants to reroute console output to a location of his choosing, not open an actual shell.
Here is one way to reroute stdout.
You can send it to a string, stream, file, etc. and then print it yourself into a window.
If you want a GUI, you will have to develop one yourself. There is no "Java Console GUI" that I've ever heard of.

Running JAR application (Java) within the window of a VB.NET application?

I need to run an external JAR file (which is minecraft) within the window (form) of a VB.NET application, so like having the program in the center and additional text I like around it.
Is this possible, and if so, how?
With shell() command and java.exe -jar yourJarPath/file.jar It should works, if my memory of VB is good.

Open GUI Java file with Netbeans

I created a .java file with NetBeans 6.9 GUI builder. Then I transfered the file to my LInux machine and tried to open it up and continue editing with the GUI builder.
But I notice that I don't have the option for the GUI builder anymore. As in be able to drag and drop buttons and all that.
Any ideas or suggestions?
Swing classes depend on two files: The .java source file and a .form file. You need both to be able to keep working in Netbeans.
Swing classes depend on two files: The .java source file and a .form file. these two files should be same name,same path. then double click the .java file , you can switch it between 'source' and design.
I see two options:
Learn to handcode GUI's. JFrame is super simple! Here is a very nice tutorial.
Re-Install NetBeans. This should reset everything to the default setting. But, it will keep your projects intact.

Categories