Приказивање постова са ознаком full screen. Прикажи све постове
Приказивање постова са ознаком full screen. Прикажи све постове

понедељак, 14. јануар 2019.

Java Swing GUI Application Full Screen on Linux

How to make your Java Swing application full screen on Linux

I have found this code on the stack overflow site:

static public boolean fullScreen(final JFrame frame, boolean doPack) {

  GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
  boolean result = device.isFullScreenSupported();

  if (result) {
    frame.setUndecorated(true);
    frame.setResizable(true);

    frame.addFocusListener(new FocusListener() {
      @Override
        public void focusGained(FocusEvent arg0) {
          frame.setAlwaysOnTop(true);
}

        @Override
        public void focusLost(FocusEvent arg0) {
          frame.setAlwaysOnTop(false);
        }
    });

    if (doPack)
      frame.pack();
      device.setFullScreenWindow(frame);
    } else {
      frame.setPreferredSize(
        frame.getGraphicsConfiguration().getBounds().getSize());


      if (doPack)
        frame.pack();

      frame.setResizable(true);

      frame.setExtendedState(Frame.MAXIMIZED_BOTH);
      boolean successful = frame.getExtendedState() == Frame.MAXIMIZED_BOTH;

      frame.setVisible(true);

      if (!successful)
          frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    }
    return result;
}

This is important peace of code if you want to make a full screen application that works the same on both Linux and Windows OS.

For example, if you just write this:

setExtendedState(JFrame.MAXIMIZED_BOTH);
setUndecorated(true);

... the code above would make a full screen on Windows, but on Linux you would still see the task bar:


The code that I found on the stack overflow makes a full screen on both Windows and Linux:


At the top of the screen, you can see burnt in pixels from the previous version of software which did not do the full screen (it had the task bar on it).


недеља, 14. октобар 2018.

Electronic art or Raspberry PI as a wall clock

Raspberry pi as a wall clock

In one of my posts, I have described how I have used old Android phones to show time and temperature. Both phones were connected to the power supply, and without a battery. (One of the highlights of that post was the manual how to remove the battery and yet have the phone working). In that post I was more worried about the display being turned on constantly, 365x24, than anything else. I thought that since I have removed the battery, the only thing that could break would be the screen, since it worked constantly, day and night.

Well, I was wrong. Both phones died (both managed to work that way for more than a year), but it was not the display, nor the motherboard or the CPU. The WiFi module in both phones died. One interesting fact is that one of those phones (Samsung Galaxy S plus) had the Super AMOLED capacitive touchscreen, and that screen did have a kind of burned pixels from my program. Not too noticeable, but existent.

When the first phone died, I had one spare RPI and one small touch screen for that RPI. I have written a small Swing Java program that connects to my weather server, pulls the data and displays that, just as the Android application on those dead phones. The program writes the information one pixel to the left every second, to save the pixels (not all pixels - those displaying the taskbar will be more burned). 

The result was - from this:
to this:


If you look carefully, you will notice that the display (and the RPI) is turned upside-down. That is because of the USB power cable, which tends to crack if it stands upright without any support (this RPI stands upright on its own). So, I have made one additional transformation of the picture to flip it. 

The small red rectangle at the lower right corner turns on and off each second to give me a visual indicator that the computer did not freeze (RPIs tend to freeze for too much reasons).

Then the second phone died. Again, I had another unused RPI and a 7-inch display purchased to be a portable HDMI monitor when I need to service my other RPIs permanently placed around the apartment. Well, that screen (and the RPI) has found its new purpose - to be a wall clock.

The only problem was that there were too many cables. I had 5V adapter which powers both RPI and the screen, the RPI and the screen. Two USB power cables and one HDMI cable.

So, instead of this phone:

I have created a kind of electronic art:


On the picture above, you can spot the power adapter at the lower left corner, RPI at the lower right corner, and the screen placed inside a portable LCD TV which died long time ago, but had the same-sized LCD display, so I was able to recycle the case.

Now, if you look closely at the picture, you will notice that the picture is not flipped. On this RPI, I don't have the problem with the power cable (everything was secured inside the frame), so I did not have to flip the picture. So I have introduced one additional configuration parameter: to flip the picture or not. 

The RPI connects to the weather server using WiFi. I plan to bring the Ethernet cable there as a next step.