flickering when resizing my processing canvas using swing components - java

I have written a RCP platform (swing components) that displays a bar Graph drawn in processing. When I manually resize the frame, flickering occurs. I would like to find out how to keep this from happening.

Processing and Swing don’t mix well. Have a look at the discussions on the Processing Forum.

Related

Displaying VTK in JavaFX

Anyone has an idea if rendering VTK is already somehow possible in JavaFX?
I managed that in Swing using vtkRenderWindowPanel which can then be added to JPanel. But I still could not find a binding for JavaFX.
The option of displaying the VTK in Swing and then adding the Swing component in JavaFx using SwingNode also doesn't work for me (a green screen is displayed, nothing is rendered).
Any ideas and suggestions are very appreciated!!!

Jframe loading window in java

I need to do a loading window in java like this:
I tried with the jframe but I can't figure it out, I can't remove the close button, my jframe should look like a jpanel before that program begin, somebody know how to do this.
You Could...
Use Java's inbuild splash screen support. This is good as it gets loaded relatively earlier in the process by the JVM itself, so it comes up reasonably quick.
The major drawback (in my opinion) is it can be troublesome to get right as it doesn't follow the standard painting process that most developers are use to and you are going to have to paint it all yourself, there's no component support
How do I use SplashScreen without throwing a NullPointerException?
How to Undo the splash screen painting in java
Splash Screen Progress bar not drawing
You Could...
Create a JWindow. This is a frameless window, which won't appear on the taskbar (at least for some OSs).
You gain complete control over what and how things get displayed, as it's like dealing with any other window.
The only problem is that it won't become available for you to load until the JVM has completed loading your application. If the JVM needs to download resources over the network, for example, this could produce an undesirable delay
For example
Splashscreen in Java
SplashScreen java change alpha
Why won't this draw the image?
You Could...
Use an undecorated frame. This is pretty much the same as the JWindow option, except that a taskbar icon will be displayed, but on some OSs, this can't be completely helped.
See Frame#setUndecorated for more details
Final thoughts
Swing is not thread safe. So if you're displaying a splash screen, this means you should be ensuring that whatever actions you are taking are done off the Event Dispatching Thread, possibly through the use of SwingWorker

Canvas on JFrame in java

I've seen in many threads it's not recommended to mix awt and swing components. However I've seen examples in which they add the Canvas to a JFrame (No other swing components are involved). Canvas is an awt component and JFrame is a swing component, so is it ok to do so? and if not, how exactly to use the Canvas?
You could get some unusual display problems with older JDKs, but mixing swing and AWT is fine nowadays. See this article: http://www.oracle.com/technetwork/articles/java/mixing-components-433992.html
I've written a game which used swing components for most of the UI/controls but a canvas for drawing the main game area (see https://github.com/qwerky/Towers/blob/master/src/main/java/lineup/ui/UI.java). It worked fine with no problems.

What problems might arise when adding JComponents to a component

I am making some changes to an existing application whoose screens have been implemented by using awt components. Using swing in the new elements will make life easier but i know that there are some problems of mixing swing and awt components.
What i would like to know is:
Prior to java 6 what problems might arise when someone adds swing components to an awt container?
(My appliation has custom mdi which every window is an awt panel. What I would realy like to do is use the same awt panel as my window and implement everything inside of it with swing using java 1.5)
In some forums people says that after java6u? some of the problems of mixing awt and swing components how been fixed. is there any problem still exists that you know of ?
See Mixing Heavyweight and Lightweight Components for answers to both your questions.
Here is an example of the problem.

Reduce overlapping of JWebBrowser in Swing

I am developing application based on Swing.
My problem is I use JWebBrowser and I put one in a scrollable panel. When I scroll down the panel the web browser overlaps the panel/frame of the application.
What can I do so the browser does not overlap the panel?
I don't see an answer here, so as someone who has been down this bumpy road, I can sympathize with these issues and would like provide some guidance.
First of all, the JWebBrowser is an AWT heavyweight component, and does not play nicely in Swing (since it uses lightweight components) without some intervention.
Instantiate JWebBrowser like this for the first step of friendly Swing integration:
new JWebBrowser(NSComponentOptions.destroyOnFinalization(),
NSComponentOptions.constrainVisibility(),
NSComponentOptions.proxyComponentHierarchy())
That instantiation alone should prevent the browser from overlapping the Swing lightweight components, however, it will not work as you would expect with transparencies or layers unless you do some additional steps.
So, during construction, call these:
webBrowser.setDoubleBuffered(true);
webBrowser.getNativeComponent().createBackBuffer();
And then, right before the web browser is to be used with any kind of transparency or layers, call these:
rects[0] = webBrowser.getBounds();
webBrowser.getNativeComponent().updateBackBuffer(rects);
Those calls will repaint the backbuffer right before the component is to be used and so when being used, it will be displayed with that most recent backbuffer and will look pretty much like a regular Swing component at that point.
There are some nuances with all of this, but that's the basics and should be enough to get anyone started with it.

Categories

Resources