Java swing gui and lwjgl - java

A simple question: Is it possible to view gui of java Swing library and lwjgl 3D scene in the same window without using any additional gui libraries? How?

You can use the method Display.setParent(java.awt.Canvas) to put the LWJGL display on a canvas. You can then incorporate this canvas into your Swing GUI. Please note that there may be slight performance issues with said approach.

Related

How to create the windows 8 FLAT native look in Java Swing programming?

I am creating a java swing application and I am badly need to get the flat GUI look like in windows 8 to my swing application. But I couldn't find it yet. Can you help me?
You can PROBABLY use the default look and feel of swing apps, undecorate everything, and for those icons; I would use buttons with internal panels, images, labels, etc. To get the scroll functionality you should use mouse listeners to detect scrolling and slide the ui accordingly.

CSS on Java Swing from Java Code

I am designing a eclipse plugin, where i use Components of Swing and JavaFx. In this I can apply CSS on JavaFX. But i could not apply CSS for Swing components. I was forced to use Swing component for some features of the plugin. So i would like to apply CSS for Swing components too. Is there any api that supports CSS on Swing component?
//This code applies css for javafx components
SwingJavaFxSample.class.getResource("samples.css").toExternalForm();
Please help me in applying css for Swing components too.
You can not use the JavaFX CSS support on Swing controls so to me the question makes no sense. Let me also say that using 3 UI-Technologies together is not really a good idea you'll run into many threading issues (SWT & FX share the same event thread whereas Swing is on another one), ... .
What is the reason you still need Swing? JavaFX can be embedded directly into SWT.

Swing in JmonkeyEngine (JME)

Is it possible to add Swing components in JME3 canvas? If it is possible please share the logic.
I was able to achieve the other way round where I was able to integrate JME3 canvas in Swing.
No, you can't add Swing components to the JME3 canvas.

Using JavaFX Chart in Swing Application

I have a traditional Java swing application (extends JFrame and has a main class) that uses JFreeCharts for some charting functionality. I have recently seen JavaFX and think these charts look alot refresher and will give my users a better experience. I wish to embed a JavaFX chart scene into a jInternalFrame (which in turn is called from my jDesktopPane).
I have followed a simple tutorial on how to create both a javafx application and a javafx chart but I am stuck on to how I get the scene inside my existing code. One example I have been through shows me how to achieve this but means converting my project to a javafx one which extends "application" class.
How can I achieve what I want? Is it not possible to keep my existing JFrame as the top level class and simply add a JFXPanel to my jinternalframe.
Any help would be great, please note I have been through some tutorials and they require me to convert my project to javafx - I simply want a javafx scene in my existing swing app.
Many thanks,
You don't need to convert your Swing application to a JavaFX application. You can place a JavaFX Chart in a JFXPanel which may be placed in a Swing component. The javadoc I linked includes sample code for embedding a JavaFX node in a Swing application.
Review the official JavaFX for Swing Developers tutorial trail from Oracle.
Also look at the Embedding JavaFX in Swing sample of SwingInterop for embedding a chart in a Swing application. The sample is provided by Oracle under the BSD open source license so that you can use it in your application.
Despite all this, my advice, unless it is a large, existing Swing code base that you just want to use a couple of JavaFX features in, is to write your application as a pure JavaFX application rather than a mixed Swing/JavaFX application.

Selecting proper toolkit for a 2D simulation project in Java

I am looking for a toolkit that will allow me to design widgets containing 2D graphics for an elevator simulation in Java. Once created, those widgets will be integrated with SWT, Swing, or QtJambi framework.
Background information:
I am developing an Elevator Simulator for fun. My main goal is to increase my knowledge of Java, Eclipse IDE, and more importantly concurrency. It is certainly fun and I enjoyed implementing this State Machine Pattern.
Anyway, I am at a point where I would like to see the Elevator on the screen and not limit myself to log its operations on the console.
I will probably choose SWT, Swing, or QtJambi for the UI controls but I am wondering what to do with the graphical part of the simulation.
You can use an SWT canvas (or Swing canvas, or OpenGL canvas via JOGL, ...), and set it up as an Observer of your simulation, and whenever the simulation state changes, you can redraw the new state.
You could get some abstract graphics out of a Graph visualisation tool such as JGraph. You could use this to visualise which state your elevator is in. However, i'm not sure how flexible these sort of graph visualisation tools are and whether you can add your own graphics and animations.
Are you sure you actually want to be using widgets. Would using Graphics2D+friends and your own abstractions not be a better fit?

Categories

Resources