How are big applications (with lots of windows, lets say users administration, roles, payments, etc) designed. I'm a web developer and I'm used to develop different screens in different html files. I wanna know how to split windows generations in different files instead of having only one huge Application class.
Thanks in advance..
The question is a bit too broad to thoroughly answer, but I still think providing a partial answer here might be useful.
For an implementation of Banislav's strategy of hyperlinks controlling a swappable pane (which does not use FXML), see the related question: How to have menus in java desktop application.
For a small FXML based framework for switching panes see: Loading new fxml in the same scene with associated sample code. Note that sample is for small apps, for large apps a more rigorous framework would be preferred.
The next step up from the small framework listed above would be something like afterburner.fx, which is "a minimalistic (3 classes) JavaFX MVP framework". Even though small, afterburner.fx would probably suffice to be used as the core for a medium sized application. You can find a small sample application built using afterburner.fx named airhacks-control.
For something a bit more involved you can study the source of SceneBuilder and SceneBuilderKit. SceneBuilder is an open source design tool written in JavaFX. Understanding and adapting that code may be challenging for somebody coming from a web background as its implementation differs significantly from a traditional web application.
For very large applications, basing the application on a fully featured platform such as NetBeans RCP would probably be a preferred approach, though, as of this time, that is probably a large and difficult task to do well and likely requires mixing multiple frameworks rather than writing everything purely in JavaFX.
In JavaFX, you can use similar approach as in web development.
Use BorderPane as root pane.
Create main menu
You can use MenuBar with Menus and MenuItems. You can also use TreeView or ListView on like left side of screen. To position TreeView/ListView on left side you could use BorderPane and set it to left with setLeft.
Approach I prefer would be to use HyperLink control. Add multiple HyperLink's to VBox and again, set them on left side of BorderPane. Upon click, they will handle event which set's desired form on center of BorderPane.
I.e.
Related
To improve my programming skills I would like to set up a little project for my work. I would like to create a kind of to do list, with several columns (Note, PO Order, Shipping, Done (as a Checkbox), ect.).
At the end of a day, I want to be able to click on the checkbox for every row which is done and save them in a data file. Also I would like to create this as a web application, running on the server in the company.
Since I would like to improve especially my java skills I would like to do this (if possible) mostly in java and to get in touch with frameworks, so I started to read about Vaadin.
My question is, if you guys could give maybe some experience about a project like this and if it's in general possible to realise this with Vaadin.
To improve my programming skills
If you want to build web apps using pure Java on the server-side, Vaadin fits the bill.
You describe the layout and widgets you want to appear in the user interface using Java code. Then, at runtime, Vaadin automatically generates the necessary HTML, CSS, JavaScript, DOM, AJAX, WebSocket, and Push code needed to render that UI on the client-side in the user’s web browser.
The beautiful part is that you get all the benefits of using those web standards technologies without having to learn them or code them.
create a kind of to do list, with several columns (Note, PO Order, Shipping, Done (as a Checkbox), ect.).
Vaadin provides a powerful and well-designed data-grid widget, Vaadin Grid, that can display such columns including the checkbox.
I want to be able to click on the checkbox for every row
The Vaadin Grid tool has an interactive mode that allows the user to directly edit the row, including clicking on the checkbox.
You could alternatively let the user select several rows and click a button (that you programmed) than would mark them as done, checking the checkboxes of the group at once.
Also, Grid has a built-in feature where it displays a column of checkboxes to be clicked en masse as an alternative to selecting rows. This helps the many users who are not adept at maneuvering through a multi-row selection with mouse-and-keyboard gestures.
I would like to create this as a web application, running on the server in the company.
Your Vaadin-based web app is built on standard Java Servlet technology. So you can deploy to your choice of any of a dozen or more web containers such as Apache Tomcat, Eclipse Jetty, Glassfish, Wildfly, and many more.
I would like to do this (if possible) mostly in java
You can build your web app entirely with Java code by using Vaadin. All Java on the server-side, no Java on the client-side.
You may eventually want to learn a bit of CSS to tweak the fonts and colors and such. But this is optional.
if it's in general possible to realise this with Vaadin.
Indeed, this project sounds like an ideal match to Vaadin.
In contrast, where Vaadin is contraindicated would be:
For web sites with crazy complicated layouts such as slick magazine sites. Vaadin is aimed at business-oriented data-entry apps.
For programmers who want to grapple directly with the HTML, CSS, JavaScript, etc. rather than avoid it.
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)
I know that there are already some question about this, but I can't find my way!
I want to implement a desktop chat application with java which is able to send text,image, video, etc.
Now I am using swing component for my chat conversation window.
I create a JFrame and add JTabbedPane to it inorder to have tab for each new conversation.
for creating each tab I act as follow :
create JPanel (I add this to my JTabbedPane as tab)
newtab = new JPanel();
newtab.setLayout(new BoxLayout(newtab, BoxLayout.PAGE_AXIS));
create JTextPane for display's part of the chat (to have style for conversation like android application such as viber, ....)
I want to be able for following styling:
diffrent alignment
change font, color
insert JComponent (to show other type of messages )
setborder of each message round (I don't want the squre one)
...
context = new StyleContext();
kit = new HTMLEditorKit();
chatPane = new JTextPane();
chatPane.setEditable(false);
chatPane.setContentType("text/html");
chatPane.setEditorKit(kit);
chatPane.setText("");
doc = (HTMLDocument) chatPane.getStyledDocument();
CSS(); // it is for adding ccs style to stylesheet of document
JScrollPane scroll = new JScrollPane(chatPane);
newtab.add(scroll , BorderLayout.CENTER);
My problem is to set perfect stying to my display part, since javax.swing.text.html.CSS provides HTML 3.2 support, so the CSS properties that are supported are limited!
while searching on Internet I find JavaFX, but I don't know is it good to use JavaFX and swing together or even is it possible?!
also which layout manager is better for the JPanel (newtab) to have my JTextPane with scroll.
As its already been said, it is possible to mix Swing and JavaFX especially since Java 8 you can do it both ways:
Embed Swing Components in JavaFX with SwingNode
Embed JavaFX Components in Swing with JFXPanel
Recently we had to make the same decision. We had an application and wanted to migrate to JavaFX to get a more modern design and to make use of all the introduced language features like PropertiesBindings etc., which is nicely supported by JavaFX Components.
So first we tried to embed JavaFX in Swing. All new components were embedded with the help of JFXPanel. It was really easy, but from time to time we had some rendering issues which got more and more annoying. "Unfortunatly" we got used to the new JavaFX API, which is why we deceided redesigning our appliction to make it a JavaFX application with some Swing Parts in it, which was possible, when Java 8 was released, since we didn`t wonna waste time on fixing thoses kind of rendering issues. The redesign was actually some work since some concepts are just different. Benefitting from the new API caused some refactorings, we didnt really wonna do in first place.
But then again mixing Swing and JavaFX got a bit fuzzy, and the look and feel of the application didnt really feel convincing, so then we finally removed all Swing Parts and replaced them by JavaFX Components. So far we don`t regret that step, but it was more work then we expected it to be, eventhough we already used patterns like MVP, where only Views had to be refactored, since presenters were (mostly) free from UI stuff (which was really an interesting process, were we learned a lot about MVP and designing an application).
So in conclusion I just can suggest to create a list of views you have and think of all the components you would need and try to find the corresponding components in JavaFX. Make small examples for the most complex components to see if they fullfill all your usecases. If that is the case and you still have enough time to switch to JavaFX I personally would go for a pure JavaFX approach, because of the experiences I made with mixing JavaFX/Swing, especially since your UI design seems to be in an early state. In the end it is just a question of time you have available for your project and if you are really up to learn about the new concepts and components of JavaFX.
Concerning the JavaFX CSS Support, you find a reference here.
It IS possible to mix JavaFX and Swing. But I have no experience in it. I just did a little FX-UI for a small project which was pretty nice. Especially the CSS-Feature is great.
According to mixing, I just recently found a blog which discouraged mixing both technologies: http://dlemmermann.wordpress.com/2014/07/17/javafx-tip-9-do-not-mix-swing-javafx/
Maybe this gives you a little help.
Recently I was asked same question.
About one month ago I started new project with my team. We use Java 8.0 + JavaFX 2.2.
What problems did I find in JavaFX?
It's new technology, so many issues still not answered. And you must look for it own.
No tray supporting, so you must use java.awt.SystemTray.
Also I found one problem in the design.
For example you want to make beautiful list with cells which contains label which stuck to left side and checkbox about right side. But there is no good way to do it and you have to calculate length of cells and etc..
But JavaFX provide great opportunities for cutomizing GUI. And you can incapsulate your design in jxml file. It's very convient, because it even more separate code from design.
About mixing I think that if platform allows it than you have to use a solution that provided a platform.
And I think that the decision to use JavaFX correct, if only because it is a relatively new technology, developed by Oracle and it probably will soon replace the swing.
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.
I'm writing a genome browser designed primarily to view the history of chromosomal rearrangements. Right now the project is a series of proof-of-concept demos written using Processing. At this point if I don't make any radical changes the final application will be a web applet with a gui built of swing components that open PApplets to actually show the rearrangements happening.
My question is: Should I give up on processing and switch over to pure Swing/AWT? This is my first big java project. I'm building in eclipse, but I can use netbeans as well. If I could embed PApplet objects inside a JFrame, for example, that would make my day.
processing.core.PApplet extends java.applet.Applet, so it should be possible to embed
a PApplet in a java.awt.Frame, as discussed in the article Applet ⇒ application: Hybrid Switch Hitters. See also, Mixing heavy and light components.
Addendum: From the API, "Processing runs in a Frame and not a JFrame. However, there's nothing to prevent you from embedding a PApplet into a JFrame," except for the limitations mentioned above.
Keep in mind that I know almost nothing about either Processing or your project, so I can only give you general advice.
The question that you should ask yourself before every major design change: what problem am I trying to solve by making this change? If the current architecture works, then you should keep it. If it's not working, then you should start by defining the specific things that are wrong with it (which I notice you didn't do).