Creating JFrame - java

We can create Java GUI based application using net-beans IDE and also we can create it using Notepad . Using netbeans or eclipse it is very easy . But I saw every where that every one used notepad. So I just want to know that the best way for create Java GUI application.

Its better preferring some IDE like Netbeans , Eclipse since because, you can consume time in creating the gui by utilizing the features like drag and drop, in-build function support suggestion which proper demonstration of usage and syntax.
If you are developing gui from scratch using notepad, it may takes more time, one developing things in that way should be thorough knowledge in syntax and all other functionalities
The Java Tutorials on Swing are a pretty good resource. If you don't like hand-coding your UI with Java code there are several GUI builders out there where you can lay out your UI visually and just fill in the behaviour in code-behind. E.g. Netbeans has such a thing and there is WindowBuilder for Eclipse.

Related

How do I create an interface with buttons and text?

I've tried different ways of creating different interfaces and applets. One of the main things I'm trying to do is to get these gui's to display text and show multiple buttons with different text leading to different outcomes. What I'm asking is, what code is necessary to create an applet or an interface (because I fail at telling the difference between the two) and how should I approach building and structuring that.
I recommend you use netbeans because it has an editor and is the easy way to create Applet.
https://netbeans.org/kb/docs/web/applets.html
You have three main choices I can think of, others will for sure think of something else:
Create a web server and actually serve a web site with your interface. You can code the interface yourself and communicate with your java server using ajax, you can let GWT among others do that for you. COnsider also frameworks like Struts
Create an applet which will become an embedded object in a web site. This is quickly falling out of grace, and I'd strongly discourage you from doing it, if only because of the pains of java plugins in the browser
Create an application with an interface by using AWT or Swing (which come with Java) or, and this is my personal opinion, more elegantly with SWT
It's hard to tell what will best help you without knowing more of your requirements, but if you are going web, I'd suggest you check out GWT, and if you are going desktop app, look into SWT. Also, please understand these are all well tested frameworks and my preferences are just that, preferences.
To create an interface in eclipse using java you can use swing.
In eclipse:
Create a new Java Project (File -> New -> Java Project).
Right Click on src folder and click New -> Other -> WindowBuilder -> Swing Designer -> [Application Window]/[JApplet].
Add the components that you want (buttons, textfields...).
Seems to me like your trying to graduate from console programs to GUI programs. A GUI works differently from a console program. A console program you have a bunch of loops and if statements, but a GUI program work completely differently. The main difference is that GUI programs are event driven.
With that being said, you want to choose a GUI framework, like Swing. Then decide if you want your application to be web based or desktop. An applet is more for web. If you want a desktop program, then you want a JFrame which will be the top-level container of your application.
You can learn all the components that are available to you in the standard Swing API here. IMO it seems like you need to start from the beginnging, so I would start from the very being of How to Create GUIs with Swing. You will want to pay close attention to section on Writing Event Listeners
If you do want to create an Applet instead of a desktop program, you can see the Applets, where you'll learn how to develop Applets and how to deploy them. You will still need to learn some basics though from the Swing link I mentioned.
Also, before you start using drag and drop gui builder tools, I would strongly urge you to first learn to hand code. It will work best for you in the long run.
I hope this gets you started in the right direction.
The defacto world standard GUI for all platforms is becoming Html5 and css3.
So the easiest way for you to write an interface is in HTML. You don't need an applet unless you have real specific needs like having a constant connection to the server for a chat or whatever. Anyway most of the applet reasons to exist are now resolved in standard HTML. If you want to learn a new langue, try Dart (dartlang.org)
You could use dart to have the more adaptable GUI to standards in the world
I explain why in this blog post
http://1veu.blogspot.com/2013/12/why-i-think-dart-will-detrone-java.html
Naturally even if you need to write a stand alone application with native GUI, HTML5 and css3 are still widely employed along with webkit or native code transformers like PhoneGap.

What is the easiest way to design Java Swing GUIs in Eclipse IDE?

I've been coding basic UIs in Java manually and using NetBeans, but recently switched to Eclipse Indigo. I use the visual class builder to design SWT user interfaces in Eclipse but found out that it's painfully slow and laggy. It takes about four seconds for a change to be displayed and it's virtually impossible to build complex and large UIs with it effectively. Is this its usual behavior and is this the preferred way of building a Java Swing GUI in Eclipse?
Since Google aquired Instantiations and then donated WindowBuilder to Eclipse foundation it is the preferred free, open source visual GUI editor for Swing, SWT and GWT.
You can also use Jigloo.
Their eclipse update site it, http://cloudgarden.com/update-site
I have used it in windows quite well. But when I use it in mac, most of the time it crash.
But windows builder seems better to me.

Netbeans Project Types

I'm building a Java application using NetBeans 7.0. The app is intended for use on Windows, so I guess the tool I'm really making most use of is Java Swing (for the cool, nifty screen elements).
My question relates to NetBeans' process of creating the various project types. The application I'm building is based on the "Java Desktop Application" template (?). My problem is that there seems to be a nice load of bloat built into that, and I can't figure out how to remove most of it without blowing up the app.
As a test, I created a "Java Application"project, but this has the opposite problem -- there's absolutely nothing built into the code, and I can figure out how to add anything. Specifically, a Java Desktop Application project created in NetBeans give me the ability to directly edit the screen layout like in Visual Studio. However, a Java Application does not appear to have this capability, I have no idea how (or even if) this can be addressed.
If I could start with a no-frills Java application, and add some capability to edit its layout and control the function of the screen elements (i.e. make it a windows application, I think), that would be just about perfect.
Does anybody have a suggestion for a minimal, but functional NetBeans application start point??
Thanks,
R.
If you start with a plain Java Application then as you realize you start with a bare bones type application. To add a GUI you can add New>JFRame Form. It adds a class that extends JFrame and Netbeans will recognize that it should open it in the visual editor for you.

where is the eclipse desktop framework

i'm new for java how can i add a button or others like Microsoft visual studio?
If you mean that you want a GUI builder, you'd better consider NetBeans with its Matisse. I think it is the most popular now for Swing apps.
This Google search shows a number of GUI builders for Eclipse
Many people prefer building GUI in Swing manually (just writing code) because it is by far not that difficult as in MSVC++ applications.
If you are looking for the Eclipse IDE to help with the development of Java applications, this can be found on eclipse.org.
Though I'm not sure I understood your question correctly.
What you are looking for is Eclipse Visual Editor. However, as pointed out by others, the GUI Builder from NetBeans (formerly known as Matisse) is more popular for Swing development.
Download Netbeans, its visual editor is very good, and will give you a the perfect Swing User Interface. Its also very easy to use.
When making desktop applications, i always do it with Netbeans, if i know the application will be more complicated later, then i do only one or two JFrame classes with Netbeans, and use them in a new project in Eclipse :)

Swing Menu that can be customized by user

Is there any framework or lib out there to create a Java swing menue that can be edited by the user via drag and drop?
Added: Implementing a polished solution myself can take a lot of time. What i would like to see: display the entry while dragging, opening submenus automaticially, showing a line where the item would be placed when releasing the mouse. Actually like the windows startmenu in XP. This would take a lot of time, i am still hoping to find framework or a subclassed Jmenu with these features.
You can implement drag and drop on most (all?) Swing components. See this tutorial to get started.
Update: based on your updated question. have a look at JFrameBuilder (note that its not free).
JFrameBuilder is an easy-to-use visual Java GUI builder.
JFrameBuilder provides the application GUI solution for Java developers. It enables Java developers to create sophisticated Swing GUI applications using drag-and-drop interface without spending a lot of time writing code.
Personally I find it a lot simpler to write pretty UIs in SWT (the toolkit used by Eclipse), it has more access to the underlying OS and provides a richer experience that's closer to what you're after in my opinion. Here's a guide to implementing drag and drop in SWT.

Categories

Resources