Swing Menu that can be customized by user - java

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.

Related

How to implement repsonsive design in Eclipse RAP?

The Eclipse RAP (Remote Application Platform) project provides a way to write web applications using SWT.
Due to single sourcing, the written code can also be used in desktop SWT/RCP applications.
Since it is a framework for web applications I was wondering if it supports responsive design?
If so, a simple example would be great. It does not need to be RCP compatible.
I didn't find a lot on the internet, has there been any efforts towards supporting responsive design?
Due to the fact that RAP shields you from web technology, native CSS and other web-techniques won't work.
To summarize the comments, you will likely have to implement one or more custom layouts that adapt to the available space and show/hide/resize the managed controls accordingly.
You may also want to use custom controls or manipulate existing controls to adapt to the available space. in some places. For example, hide texts on toolbar buttons when space becomes rare.
RAP theming can also be leveraged to a certain extent in order to change the appearance and space of certain controls.
Further reading:
EclipseCon 2014 talk: https://www.eclipsecon.org/na2014/sites/default/files/slides/Responsive%20Applications%20Tutorial%20-%20EclipseCon%202014.pdf
A blog post with code examples about responsive UIs with SWT: http://www.codeaffine.com/2014/02/24/responsive-uis-with-eclipse-and-swt/
RAP Theming: https://eclipse.org/rap/developers-guide/devguide.php?topic=theming.html
Understanding SWT Layouts: https://www.eclipse.org/articles/article.php?file=Article-Understanding-Layouts/index.html (ignore the deprecation warning, the core concepts haven't changed since)
You can make it responsive with the use of Passe-Partout created by Tabris. This works in RAP and should be compatible with RCP.
They have made a custom layout : FluidGridLayout.
It's best you use it through the factory class com.eclipsesource.tabris.passepartout.PassePartout.
Source can be found on github:
https://github.com/eclipsesource/tabris/tree/master/com.eclipsesource.tabris.passepartout
Add this plugin to your dependency or just copy the source in your project.
See the blogpost at eclipsesource for basic info:
https://eclipsesource.com/products/tabris/eclipse-rap-documentation/responsive-design/
The great thing about it, is that you program it all in java.
Only issue that I now experience is with scrolling.
In my case I have a workbench and my editorpart needs a scrolledcomposite, only set to V_SCROLL. I've added two resize listeners to set the new minsize of the scrolledcomposite.
One resize listener on the display when the entire browser resizes.
A second resize listener for the parent when only the editorpart resizes. (fe when a view is resized or the editorpart is maximized)

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.

How to show GUI design view in java.class?

I'm linking a database to NetBeans now and I need to create a interface for this. But when I need to adjust the position of button, label is difficult. Is it possible that show a GUI design view that easy for me to adjust without use the JFrame component?
If I understood your question correctly, you're looking for a GUI builder for Swing.
Netbeans ships with the Matisse Swing GUI Builder which will help you build GUIs easily and quickly. Tutorials aren't uncommon (such as the official tutorial or some user created videos on YouTube).
Some folks are fine with this work flow (since it speeds up development quite a bit). Others want to use custom frameworks and have requirements to use specific layouts in which case I recommend reading about different layout managers.
Take your pick and happy development! :)
Instead of trying to design your entire application in the GUI editor, you may be able to adapt the approach shown here. This will let you focus on a single container at a time. Also, remember to backup your .form files; more here.

Creating JFrame

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.

Creating a simple gui in java for running a background process

Well, I had this question in mind for a long time.
Even though I have a complex requirement,i will keep it as simple as possible.
I have background process which takes two arguments which I use to execute from command line.
The first argumets can have three valid values and the secong argument can have two valid values.
I usually run that process on command line in solaris unix.and that process is completely coded in C++.
What I want now is I wish to create a simple gui in java for running the process in background.
I am complete new to the advanced concepts of java, and I am aware of some core java which I studied in my college days.
So,My question overe here how do I start creating a gui?
What all do I need to create a simple gui using java?
I am confident enough to learn gui programming in java as I am a c++ programmer.
Please give me some right directions to give some life to my thought and any some good materials available on the net would be helpful.
I would start by looking at;
Creating a GUI with Swing
Concurrency in Swing
Concurrency in Java
I'd also become familiar with ProcessBuilder (a simple example) and Basic IO
MarvinLabs also makes some great points as well
The Google search you'll want to use is "java swing tutorial". Swing is Java's GUI library.
You can also have a look at: Java GUI frameworks. What to choose? Swing, SWT, AWT, SwingX, JGoodies, JavaFX, Apache Pivot?
You really just need a JFrame and a JPanel. The JFrame is the physical window that the gui lives in, while the JPanel is the content manager. You place JComponents (e.g. JLabel, JComboBox) into the JPanel.
Java Api: http://docs.oracle.com/javase/7/docs/api/
Examples of using each component: http://docs.oracle.com/javase/tutorial/uiswing/components/index.html
IMO, you may try using JavaFX 2.1 to develop your GUI in java. It has Scene builder tool to design your application, built-in support css-like skin.
Check the concurrency in Javafx 2.1 here.

Categories

Resources