If I wanted to scroll to a newly generated component after some work is done/outputted, how would I do that via Java? Or would I need to introduce additional functions with JS/CSS files into the build?
This should work:
UI.getCurrent().getPage().executeJs("arguments[0].scrollIntoView({behavior:'smooth'});", component));
Here component would just be the name of the target component, and the behavior of the scrolling would be smooth. There is also "auto" for the behavior but I prefer the former.
Related
I design a custom component (mainly override paintComponent for desiring appearance) and compile it then drag it to a JPanel in the Netbeans design mode.
It works correctly and the Netbeans designer renders it in time and correctly when changing the property of the component. But when I modify the custom component source code and recompile it, the Netbeans UI designer doesn't update the appearance of the component unless deleting it then dragging the recompiled component to the panel.
Is there a way to update the modified and recompiled components in Netbeans UI designer without deleting them?
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've been coding a GUI in JavaFX and have gotten to styling it with CSS. However, I came to learn that there is no support for setting layout parameters such as min-width, pref-width, etc. (These show up in the docs but are filed under WebView only.) Instead of getting a nicely sized TextField, I have one that's spread across the entire screen.
Now I know the solution is to just go hardcode these layout parameters in Java (the documentation pointed me to JavaFX Script but that's been dead since 2009), but I'm wondering why I have to do this? What's the point? I'm not a CSS pro, but it seems like bad design to only abstract some of your styling. Now it's in two places? Are there any plans to change this?
The feature you request has been implemented in Java 8.
See RT-20906 Support setting min/pref/max sizes via css.
It could be argued that layout and styling a separate things and JavaFX already has FXML as a declarative layout system, so perhaps the need for layout parameters in CSS is slightly less if you are using SceneBuilder and FXML for your layout (at least that is what my experience with the technology has lead me to believe).
I am designing the swing JFrame form using NetBeans . I am not sure about the layout setting in JFrame form .When we change the resolution of the windows the forms are not adjusted automatically
but i want the forms and control designed on forms should be re
sized automatically. How is it possible
You can change the LayoutManager in by right clicking your panel. Look at this Layout Manager guide to find which suits best for your program.
Or: For the default NetBeans Layout Manager, you need to "anchor" the components for auto-resizing. And setting them resizable, too (but it is the default).
For any component that you want to add layout below images will guide you:
You need to choose layout that fit to your requirements.
Also you can customize the layout, to do that:
Also you can do it manualy or you can change the properties from Customize code.
To do that like the above image right click on the component and go to customie code(Cannot do it for JFrame).
Scenario : In NetBeans, you create Swing components via drag & drop and customize some properties via the given GUI.
Question : Later on, If you see the generated code of these components, either in source or by by right-clicking the component and selecting customize code, we can see that the property changes are implemented via AWT. Why is this so?
As mentioned in Using Top-Level Containers,
Each program that uses Swing components has at least one top-level
container. This top-level container is the root of a containment
hierarchy — the hierarchy that contains all of the Swing components
that appear inside the top-level container.
java.awt.Container, an AWT Componenet, is that container.
Addendum: This overview suggests how pervasively the interface java.beans.PropertyChangeListener is used throughout AWT and Swing.