"Proper" way to develop a JAVA GUI application [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I would appreciate it a lot if someone enlightened me on what is the "proper" way to build a java application which utilizes the Swing. How you navigate through the views of the program?
To further elaborate on what I have in mind:
I need a menubar at the top of my Frame and when the user selects a menu item the application should present him the right view. These "views", are they panels? How do you create such an application? I have tried with panels and show, hide functions but I am not pleased with the result. Is this the proper way to build such an application? Looking forward to your answers guys!
Thanks a lot in advance!

If it is a simple application, JFrame and JMenuBar is enough. If it is built out of a number of screens, as your question suggests, then CardLayout can be useful to manage which screen is showing. Building those out of individual JPanels is a good idea.
There are various GUI builders built into Java IDEs which can help you design those panels and wire them up to your code that implements the logic of the application.
How the pieces of the application communicate with each other is up to you; the typical pattern is to have a "model" class for each one which populates the models of the individual components.
If it is a very complex application, you may want to use a framework which takes care of the plumbing of a desktop application, such as the NetBeans Platform or other similar frameworks.

You can use a JFrame.On the top of it, have a menu bar, you can add items to it.You can also add sub menu to items.You can perform action on its event.Netbeans provide a easy way, but it is not recommended from coding point of view.

Related

Should I use a drag-and-drop or self-program my user interface? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 months ago.
This post was edited and submitted for review 3 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
As a CS student trying to make my first application is it better to program the user interface myself or should I use the drag and drop option of JFrame?
Drag and drop seems quicker, but I find it hard to understand instructions generated. So the dilemma is do it myself or drag and drop and try to understand afterwards.
Write the code yourself.
Drag-and-drop GUI builders generate poor code that is quite hard to maintain. That may or may not matter for a school project, but if you plan to write any programs for any other purpose, you’ll want to be able to fix them and update them.
Drag-and-drop builders usually generate GUI elements with hard-coded sizes and positions, which is something GUIs must avoid—a button will need a different pixel size to accommondate its text in Windows than it needs on a Mac, and the default preferred size already accounts for that.
Furthermore, laying out a GUI is about more than how it looks. It’s also about how the GUI behaves. When the user resizes the window, which GUI elements in the window should resize with it? Which ones should stick to the edges, and which edges should they stick to? While you can specify all of this in a drag-and-drop GUI builder, the builder makes it very easy to ignore all of it. You will have a GUI that looks right at a glance, but it may not behave right.
Finally, if you plan to do GUI development for any jobs, you will need to know how to write the code. So learning to do it now is doing yourself a favor.
Writing the code yourself will likely require perusing the documentation a lot. No one is expected to memorize it, of course, but as you keep going back to it for information about various GUI elements, you will probably learn things about them that you might not have known if you had relied on a drag-and-drop builder.
I think you can definitely use the drag and drop GUI.
Netbeans has support for automatic resizing of components which allows really nice and fast development.
But avoid all the "code" parts of netbeans, like code when you click on buttons etc. Those it's better to code yourself so you understand what happens.
Later, you can of course learn to program editors yourself, but usually, most companies use different GUI frameworks anyway (or don't use desktop at all), and the GUI parts are the simple part of programming.
Of course, it doesn't hurn to know how to create simple JFrame / JDialog and a few buttons programmatically, especially for stuff like dynamic content (ie. creating elements when program is running)

Material button in java? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
Can we use material UI in java?
Basically, I am making a calculator in eclipse using swing and awt and I want to try materialUI, so I want to use the material button in it.
Is it possible?
Yes. You could use Material UI with Java. Implement your calculator as a webapp and use Material UI components to implement the calculator (web) UI to run in the user's web browser.
But it doesn't make sense to use Material UI with Swing / AWT.
Material UI is a Javascript component library that runs in the user's web browser.
Swing / AWT are for implementing user interfaces on the user's desktop.
(Trying to use Material UI with Swing / AWT would be like trying to put wheels on a fish.)
There is nothing preventing you from designing and implementing cool buttons (e.g. buttons that look like Material buttons) in Java using Swing / AWT as the foundation. It would "just" be a Java coding exercise; see Andrew Thompson's answer for some a starting point.
But my advice: don't bother. It would be a waste of effort ... IMO.
.. looks cool ..
If it is purely about the look of Swing GUI controls, that could be implemented using a custom look-and-feel. See the Modifying the Look and Feel lesson in the tutorial for details. Note there are also many 3rd party look and feel implementations that might come close to what you think is 'cool'.

Java GUI programming beginner tips [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Im quite good with writing text based programs using Java and ill like to proceed to writing GUI programs and animations ive checked several youtube playlists and they dont seem do helpful so i would appreciate any tips on where to start.
For desktop applications, You should start with Java Swing.
Swing API is a set of extensible GUI Components to ease the
developer's life to create JAVA based Front End/GUI Applications.
There are some good tutorials, I would suggest the following:
JavaTPoint and TutorialsPoint
After completing swing, you can move on to JavaFX.
JavaFX is a set of graphics and media packages that enables developers
to design, create, test, debug, and deploy rich client applications
that operate consistently across diverse platforms.
For that, you may follow to begin with
code.makery
Sounds as a great question, but not self explanatory. Before making assumptions just ask your self -
Do I feel myself as Web developer or a Desktop(Core) developer?
From a prospective of Desktop developer - take a look at Swing - it allows to make GUI forms and etc. If you decide to learn web, then take a look at Vaadin (which is made on top of GWT, and easier to dive in)..
Both of them have simlar syntax, so it would be always easier re-qualify...
UPDATE: While you still decide where to go, see this humble example of Vaadin Application

How to make, what when check box checked, there would come different options? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'm making a java program with netbeans, using jFrame
I want to make program for easy use and for advanced use.
So my purpose would be, whet user check "normal user" checkbox
he can edit one kind of options
and when he check "advanced user" checkbox
he would only be able to edit advanced options.
One option is to create two JPanels, one with the easy use components on it, and another with advanced use components, and then swap them via a CardLayout when the appropriate JRadioButton has been selected. Note that I would JRadioButtons not JCheckBoxes since your selection sounds to be an either-or situation.
Some useful links:
How to use the CardLayout
How to use JRadioButtons
The Layout Manager Tutorial
As an aside, as per Andrew, I also feel that while GUI builders can help you save time when creating GUI applications it is best to avoid using them til you are somewhat familiar with the use of the Swing library. Otherwise it could shield you from having to know these details thereby allowing you to paint yourself into a corner that can be hard to get out of.

Converting Swing application to JavaFX [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
What are the necessary steps for converting a Swing application into JavaFX?
It would also be interesting to know about the best practices when performing this task (i.e. problems that can be encountered and resolutions).
I don't know if there are "best" practices there, as JavaFX is quite new and people are more busy making new JavaFX programs than converting old Java ones...
First, I would ask why you want/need to do that... Second, I would say it depends on the purpose and complexity of the Swing program.
If that's a plain dialog, it shouldn't be hard. If it is a complex application with sub-panels, lot of pop-up dialogs, menus, MDI behavior with docking, etc., it might be hard to impossible to port...
Somehow, it might be better to rewrite the GUI from scratch, knowing that you have to either use a wrapper of Swing components in JavaFX, or limit yourself to the (currently) limited range of native JavaFX components.
Now, if your application was written with good principles, you can rewrite only the view and controller parts, and re-use (most of) the models / business logic as JavaFX can very well exploit Java classes.

Categories

Resources