DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • What Are Events? Process, Data, and Application Integrators
  • 5 Data Models for IoT
  • 7 Salesforce CRM Integration Methods You Must Know About
  • Implement a Distributed Database to Your Java Application

Trending

  • How To Handle Technical Debt in Scrum
  • A Complete Guide to Open-Source LLMs
  • Freedom to Code on Low-Code Platforms
  • A Better Web3 Experience: Account Abstraction From Flow (Part 1)
  1. DZone
  2. Data Engineering
  3. Big Data
  4. JavaFX - Fullscreen, Animation, and Transparency

JavaFX - Fullscreen, Animation, and Transparency

Sergey Surikov user avatar by
Sergey Surikov
·
Feb. 26, 08 · Interview
Like (0)
Save
Tweet
Share
22.07K Views

Join the DZone community and get the full member experience.

Join For Free

Sometimes we need to switch an application to full-screen mode. Let's examine an example of such an application...


The transparent window expands on all screen. You can draw and write down a note at this window. Control buttons appear at the top of the screen:

  • Hide - iconify a window
  • Clear - clears a window
  • Exit - exit from the application

How to create a window similar to this example

Here we have code for switching a window in an exclusive mode:
var w=frame.getWindow ();
GraphicsEnvironment.getLocalGraphicsEnvironment ().getDefaultScreenDevice()
.setFullScreenWindow (w);
Let's make a screenshot of the desktop and we shall place it on the form for imitation of transparency:
Canvas {
scaleToFit: true
content: me.imageView
}
How to create screenshot of the desktop:
var file=File.createTempFile ("fsmemo", ".jpg");
file.deleteOnExit ();
var background = robot.createScreenCapture (screenRectangle);
ImageIO.write (background, "jpg", file);
var image=new Image {preloadIfLocal: true};
image.url=file.toURL () .toString ();
imageView.image=image;
- a variable robot is a java.awt.Robot

Let's place this code in the trigger on frame attribute /iconified/ so that at each minimzing of the window, a new screenshot is taken.

Drawing on the screen

Let's create Canvas and place a Polyline on it:
curve: Polyline
curves: [Polyline]
...
Canvas {
content: bind me.curves
}

We shall add points in MouseDragged event:

onMouseDragged: operation (e: CanvasMouseEvent) {
insert [e.x, e.y] as last into me.curve.points;
}

We shall add this line in a array of lines in MousePressed event:

onMousePressed: operation (e: CanvasMouseEvent) {
me.curve = Polyline {
points: [e.x, e.y]
stroke: new Color (1,0,0,1)
strokeLineCap: ROUND
strokeWidth: 5
};
insert me.curve as last into me.curves;
}

How to store lines

Let's use standard class Properties for a data storage

    operation save (curves:Polyline *) {
var s = "";
for (all in curves) {
for (one in all) {
var c = "/y ";
for (p in one.points) {
if (c.equals ("/y")) {
c = ", x ";
} else {
c = "/y ";
}
s = " {s} {c} {p} ";
}
s = " {s}; ";
}
}
var properties=new Properties ();
properties.setProperty ("curves", s);
properties.store (new FileOutputStream (propertiesFileName(), "FxMemo");
}

The code above will save data about the drawn lines in a user home folder

Animation

Let's create an animation at start of the application. Let the picture from last session appear not at once but in parts. We shall create the trigger for this purpose:

trigger on FSFrame.tick [oldTick] =nextTick {
var numberFormat=NumberFormat.getInstance ();
for (i in [oldTick.. nextTick-1]) {
var one=lastSession [i];
if (one.trim () .length ()> 0) {
var tcurve = Polyline {
stroke: new Color (1,0,0,1)
strokeLineCap: ROUND
strokeWidth: 5
};
var xyArray=one.split (",");
for (xy in xyArray) {
if (xy.trim () .length ()> 0) {
var points=xy.split ("/");
var x=numberFormat.parse (points [0] .substring (1));
var y=numberFormat.parse (points [1] .substring (1));
insert [x, y] as last into tcurve.points;
}
}
insert tcurve as last into curves;
}
}
}

We shall change attribute /tick/ in a following code:

if (count> 0) {
var time=250*count;
frame.tick = [1.. count] dur time linear;
}

Loading of data will looks approximately so:

Source

fsmemo.zip - 2.5 Mb

- The source, the compiled application and JavaFx runtime.

For start of the application it is necessary to click a file dist/JavaFXFullScreen.jar.

Drawing is saved before exit in a user home folder in a file fxmemo.properties.txt and loaded at next start.

 

JavaFX application Data storage Data (computing) Clear (Unix) Desktop (word processor) Attribute (computing) Event

Opinions expressed by DZone contributors are their own.

Related

  • What Are Events? Process, Data, and Application Integrators
  • 5 Data Models for IoT
  • 7 Salesforce CRM Integration Methods You Must Know About
  • Implement a Distributed Database to Your Java Application

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: