Java: enforce a single instance of an app

The Console is an app which typical usecase fits within running a single instance. That’s by design. However, we sometimes forget to check whether some the app is waiting for us in the background and try to launch them. That’s when disaster happens. Two consoles placed on top of window and reacting to same hotkey? Cannot be!

Here’s a short story about preventing from having multiple instances of same app made in Java. There’s a note about communication, too.

→ Continue reading

The Console: script management

The biggest feature of my console software is ability to code own “commands” – scripts. It’s supposed to be easy and quick for programmers. I’m not trying to design my own DSL language or make users install some weird packages into system. JavaScript and console API is all you need to know to code your custom scripts.

If one of goals of The Console project is to make easy custom scripting then it’s logical that you need some way to manage your scripts. Putting all scripts in one file or even all scripts in one folder would be a mess. So, how to manage those files? How The Console deals with it?

→ Continue reading

JavaFX: comparison of rich text components

Rich text component is a user interface component that displays text by styling various parts of it differently. Very often Rich Text components are used for editors. An example may be any code editor that supports highlighting. I needed such UI component for my latest application – The Console so now I’ll shortly discuss a comparison between few options:

  • e(fx)clipse Runtime StyledTextArea
  • RichTextFX
  • JavaFX built-in TextFlow
  • JavaFX built-in WebView

→ Continue reading

JavaFX: taskbar-less undecorated window

Applications that are launched in Windows OS are by default listed on taskbar. For a utility software like The Console it is not the case. It shouldn’t pollute our task bar or even tray. It should be available under hotkey and that’s it.

Problem is, JavaFX won’t allow us. Previously presented line  stage.initStyle(StageStyle.UNDECORATED)  gives us undecorated window but collides with stage.initStyle(StageStyle.UTILITY) which makes window’s task not visible in taskbar but window itself is then decorated.

Between workarounds I’ve found a solution. TL;DR initialize window using Swing.

→ Continue reading

Retake on The Console

Some time ago I made this project https://github.com/Namek/TheConsole_POC for Windows OS. It’s usage goes like this: hit CTRL+TILDE and on the top of the screen will open a Quake 3 Arena thingie that’ll enable you to type in some commands. Commands are JavaScript’able and that’s the power of the tool. I did some hacks here and there so I decided to change some techs and remake whole beauty to improve efficiency of use.

→ Continue reading

Immutability of Java’s Integer

As Wiki states

In object-oriented […], an immutable object is an object whose state cannot be modified after it is created.

That totally applies to Java’s Integer. Let’s take a look at the code to talk about:

Integer is a class then why variables a and b have different values?! – you may ask. See the explanation if eager.
→ Continue reading