Open-source News

Raspberry Pi "V3D" OpenGL Driver Improving Performance With On-Disk Shader Cache

Phoronix - Sat, 03/19/2022 - 02:46
It's arguably long overdue, but landing today within Mesa 22.1 is support in the V3D driver for Mesa's on-disk shader cache functionality. By adding this shader cache to V3D it can help with the performance of this Gallium3D open-source driver most notably used by the Raspberry Pi 4 and newer single board computers...

Dav1d 1.0 AV1 Decoder Released With Improved Threading, AVX-512 Support

Phoronix - Fri, 03/18/2022 - 23:51
The much anticipated dav1d 1.0 open-source AV1 video decoder has been released! Dav1d 1.0 is a big update to this leading CPU-based AV1 decoder that now offers AVX-512 support for newer Intel CPUs, threading enhancements, and more...

AMD Makes A Compelling Case For Budget-Friendly Ryzen Dedicated Servers

Phoronix - Fri, 03/18/2022 - 21:00
While AMD EPYC processors offer phenomenal performance at the high-end for servers with up to 64 cores / 128 threads per socket, eight memory channels, and other features, not all server deployments call for such capabilities. In the lower-end dedicated web server rental space, budget web hosting, and similar personal / small office server space, AMD Ryzen processors can prove more than capable. Already some dedicated server providers are offering AMD Ryzen powered servers and more are expected to come soon -- especially with even more server-minded wares for Ryzen expected next generation. In looking at this space, we have been testing a number of AMD Ryzen processors recently compared to Intel Xeon E class competition for looking at the performance and value in the low-end dedicated server space.

Rusticl Posted For Working On OpenCL 3.0 Within Rust For Mesa Gallium3D Drivers

Phoronix - Fri, 03/18/2022 - 17:50
Mesa has long had the OpenCL "Clover" Gallium3D state tracker that has supported OpenCL 1.x but lacked important extensions that impaired its practicality. With AMD backing their ROCm compute stack in more recent years and Intel going with their Compute-Runtime stack for oneAPI and OpenCL support, there also isn't a major backer to Clover besides Red Hat engineers and the community. Now though "Rusticl" has been published as a new Mesa OpenCL implementation written in the Rust programming language...

Last Minute Sapphire Rapids Change Lands In GCC 12

Phoronix - Fri, 03/18/2022 - 17:26
A small but important change was just merged into GCC 12 ahead of its upcoming release in a month or so and also the same patch back-ported now for the GCC 11 stable series...

FreeBSD 13.1 BETA 2 Released With Updated OpenZFS

Phoronix - Fri, 03/18/2022 - 17:11
Last week marked the release of FreeBSD 13.1 Beta 1 with many changes in particular benefiting this BSD OS on POWER and RISC-V hardware. Out today is the latest beta release...

How to beautify your Java applications

opensource.com - Fri, 03/18/2022 - 15:00
How to beautify your Java applications Seth Kenlon Fri, 03/18/2022 - 03:00 Up Register or Login to like.

What's not to love about Java?

I love that Java lets me write applications on one platform and run them on other platforms. You don't have to mess around with platform-specific SDKs, using a different library for that one platform, or inserting little code hacks to make that other platform behave. To me, that's how easy all modern programming ought to be. There's great infrastructure around Java, too, like the Maven build system and SDKMan.

But there's one thing about Java I don't love: the look and feel of its default GUI toolkit, called Swing. While some people feel there's a charming nostalgia to Swing, for the modern computerist, it can look a little dated.

Fortunately, that's an easy problem to solve. Java is a programming language, so if you're writing an app in Java you can reprogram its look and feel using one of several Java theming libraries.

More on Java What is enterprise Java programming? Red Hat build of OpenJDK Java cheat sheet Free online course: Developing cloud-native applications with microservices arc… Fresh Java articles Default theme of Java Swing

The default theme of Java Swing hasn't changed much in the past decade. This is a screenshot of an example Java app from 2006—or is it 2022?

Hard to tell.

 

You can see a simpler version for yourself with this demo code:

package com.opensource.myexample2app;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Insets;
import javax.swing.JRadioButton;

public class App extends JFrame {

    private void run() {
        var window = new JPanel();
        window.setLayout(new BoxLayout(window, BoxLayout.X_AXIS));
        window.setBorder(new EmptyBorder(new Insets(15, 15, 15, 15)));

        JButton btn_hello = new JButton("Hello");
        btn_hello.setSize(new Dimension(80, 20));
        window.add(btn_hello);
       
        window.add(Box.createRigidArea(new Dimension(10, 15)));

        JRadioButton rad_world = new JRadioButton("World");
        rad_world.setSize(new Dimension(80, 20));
        window.add(rad_world);

        add(window);
        pack();

        setTitle("Hello world");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
    }

    public static void main(String[] args) {

        EventQueue.invokeLater(() -> {
            var app = new App();
            app.run();
            app.setVisible(true);
        });
    }
}

Run that in the Java IDE of your choice or with Java directly:

$ java App.java

The result is simple but demonstrative:

 

Look and Feel Java libraries

Java Swing gets its theme from Look and Feel (LAF) libraries.

The few that are bundled with Java suffice in a pinch, but newer ones are available, and you can bundle those libraries with your code to give your application a different theme. You can find LAF libraries by searching for "laf" on sites like Mvnrepository.com, or on popular coding sites like GitLab or GitHub.

My favorite is FlatLaf, but there are very good themes by NetBeans, IntelliJ, and many others under a variety of different licenses to fit any project.

The easiest way to use one of these libraries is to add it to Maven, then make minor modifications to your code to invoke the theme.

First, add the library to Maven:

<dependencies>
  <dependency>
    <groupId>com.formdev</groupId>
    <artifactId>flatlaf</artifactId>
    <version>2.0.1</version>
  </dependency>
</dependencies>

Next, import the Java UIManager library and the LAF theme you're using to your project.

import com.formdev.flatlaf.FlatLightLaf;
import javax.swing.UIManager;

In the class that creates your GUI, use UIManager to set the application's look and feel:

try {
    UIManager.setLookAndFeel( new FlatLightLaf() );
} catch( Exception ex ) {
    System.err.println( "Failed to initialize theme. Using fallback." );
}

That's it! Launch your application to see the new look and feel.

 

Flatlaf happens to have variant themes, so you can change FlatLightLaf to FlatDarkLaf for a dark theme:

 

Or use FlatIntelliJLaf for an IntelliJ-like look and feel:

 

Or FlatDarculaLaf for a dark IntelliJ look and feel:

 

Looking good, Java

Java Swing is an easy toolkit to use. It's been well maintained for two decades, and it provides a great desktop experience.

With look and feel libraries, Swing can look good, too.

Programming in Java doesn't have to be ugly. Follow these simple steps to spruce up Java Swing.

Java What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Pages