
Show HN: Hacker News desktop application in Kotlin/Swing - westoncb
https://github.com/westoncb/HNDesktop
======
hasenj
The other day there was a post recommending the use of JavaFX.

I would really like to see a non-trivial app built on JavaFX in Kotlin, with
the following properties:

\- Does not look ugly.

\- Is not composed of _merely_ OEM widgets. But includes custom elements, like
one would normally see on websites (and by extension, Electron apps).

\- Is lightweight and response, not just in terms of CPU and RAM, but in terms
of user experience (think VSCode vs Android Studio).

~~~
kiwee
I actually did with my company and anyway it was a bad decision. JavaFX and
swing customization is really not easy and not well documented. JavaFX uses
custom XML which make no sense to be honest when you want to do nice design.
And it requires custom CSS too.

Additionally, their design are bad(I mean their Java API).

We spend a whole year making an app with it, at the end we decided move away
from it, like the rest of the java community if fact that do not really
support desktop applications anymore.

~~~
TXV
> JavaFX uses custom XML which make no sense to be honest when you want to do
> nice design.

I don't see why the custom XML should be a problem. Definitely you are not
supposed to edit the .fxml files by hand, especially when you have apps like
Scene Builder that allow you to design everything from a GUI.

> And it requires custom CSS too.

That's true only for a few JavaFX-specific properties. The CSS syntax doesn't
change very much. Also, it's not a surprising feature: QT, the C++ GUI
framework, also uses custom CSS.

------
westoncb
Btw, this project started when my sister and I were eating at Panera and
decided it would be fun to each write an HN front-end. Hers was largely a
project to learn React, which you can see here:
[http://coribeecroft.com/hacker-news-
frontend/](http://coribeecroft.com/hacker-news-frontend/)

She's looking for work at the moment if anyone knows of someone who might want
to hire a somewhat junior but very smart developer with a good sense of humor.
See here for more: [http://coribeecroft.com](http://coribeecroft.com)

~~~
iamcreasy
Her website is inspiring. I am also graduating this semester, I will compile
my works similarly to her.

Hope she lands a great job.

------
noncoml
You were so preoccupied with wether you could, that you didn’t stop for one
moment and think I’d you should!

Just joking. Good job. I think it’s been years seen I saw a Java App, and have
to say, I am a bit disappointed at how Swing still looks.

~~~
copperx
Swing will always look like that. Java FX is the new stuff.

------
justboxing
Ask HN on Show HN: Why is Swing UI still so Ugly ?

2 Decades since it's introduction in 1997 ( I remember being forced to use it
in a trading OMS application in 2002), Swing UI looks frozen in time, ugly as
ever.

~~~
gruez
follow up question: why does swing use its own special snowflake design, when
it could the OS's native design?

~~~
hota_mazi
Because Sun made the boneheaded decision (and never admitted it was dumb) to
go for emulated widget controls instead of native ones. What this means is
that they have had to reimplement and imitate the behavior of native controls
on all platforms (realistically, Windows only) every time Microsoft came up
with a new version.

In contrast, IBM took the native approach with SWT / JFace, and the interfaces
written with that library look and feel infinitely more native and performant
than Swing and JavaFX ever did and ever will.

~~~
lmz
The toolkit based on native widgets existed before Swing. It was called AWT.

~~~
n3dst4
AWT wasn't native either - it just had one ugly appearance and couldn't be
themed. I seem to recall it kind of resembled Sun's CDE (Common Desktop
Environment) so it would have look sort of at home on Solaris.

~~~
pvg
AWT uses native widgets.

------
mberning
What framework does Jetbrains use for all their tools? They honestly look and
perform great on every platform that I have used them on.

~~~
stevoski
Java Swing, with lots of manual tiny tweaks for fidelity.

~~~
jm547ster
Wow I had no idea, assumed it was JavaFX, it has a much nicer feel to it than
the other 2 IDEs. Has Swing remained the same or has the API been overhauled
since idk, SE6-ish around last I perused? NetBeans certainly has had a nice
bit of a facelift last I saw of it. Eclipse I won’t say too much, looks like
their splash screen is the only thing has had much of an overhaul.

~~~
pjmlp
Just tiny improvements, mostly bug fixes.

The secret is to read "Filthy Rich Clients" and "Tricks of Swing Gurus", where
most of those programming knobs were described.

------
des429
Jesus. definitely looks like a swing app

~~~
egocentric
Definitely got that swing feeling to it :)

Is there any way to customize the theme? I'd love something that's more clean
and looks more modern.

~~~
westoncb
The only way is to change the Look and Feel, and unfortunately I think
'Nimbus' (which I show in one of the screenshots) is the most modern looking
of the built-in Look and Feels. There may be some decent 3rd party options
though... Like whatever IntelliJ is using.

~~~
vturner
Not true, you can get the platform feel easily. I've seen swing do Windows XP
through 7 easily. Never tried 10 yet.

~~~
westoncb
I tried using the platform look and feel on macOS, but it gives a number of
important elements tiny heights, including comments, making them unreadable.
I'm sure there's a fix but I haven't looked into it.

~~~
vturner
Ah, maybe it's been abandoned for JavaFX as others have pointed out?

------
_ar7
This is why electron is so popular

~~~
westoncb
As the author of this—yep, I can agree with that. I'm generally baffled when I
see folks complain about Electron's slowness—but that's probably 'cause I
started out building Swing apps :)

~~~
thejosh
Also the memory usage is killer.

~~~
captainmuon
Memory usage is often a bad indicator of bloat. Especially GC languages like
Java and JS will just go ahead and allocate a lot of memory from the OS
without using all of it all the time. If you sum the "used" memory of all
apps, it will often be more than the available RAM, even though there is no
swapping going on. The OS memory management is really clever nowadays.

Actually, an app not using much memory may be sacrificing performance by not
using a caching opportunity.

Unfortunately, apps coordinating how much memory to best use is an unsolved
problem, as far as I know.

~~~
mrighele
Is it really the case ? I would expect the language to expand the size of the
heap only if after a GC the amount of free memory is still below a certain
threshold.

------
j_s
Add this to the list!

Other ways to read Hacker News |
[https://news.ycombinator.com/item?id=15310291](https://news.ycombinator.com/item?id=15310291)
(Sep 2017, 181 comments)

Includes mention of alternate websites, mobile apps, and a pair of CLIs:
haxor-news and hn-cli. I'm not sure but this might be the first desktop GUI
app for HN I've heard of!

------
vturner
The HTML5 parsing in Java is awesome now! built a desktop app with Bootstrap 3
recently and the logic in Kotlin, fun stuff. Your Swing metal L&F is great :)

------
PleaseHelpMe
Very nice app and promising. However, I would the UI would look more "modern"
(don't know if this is possible or not). Right now the button and the
scrollbar is a bit outdated. The bonus point for me that this is written in
Kotlin, not another Electron RAM killer app.

------
harisamin
Very cool! I made a native macOS desktop client . It does use a web view to
render the article but the article list, comments, voting, commencing, login
interactions are all native . [http://mackernews.com](http://mackernews.com)

------
anon6412
Has anyone successfully compiled it with the kotlinc command line tool?

~~~
westoncb
Hey anon6412, so this was my first Kotlin project, and I don't really know
much at all on the ecosystem. I could check out kotlinc and write up something
on how to build with it—I imagine it's just adding ./lib to the classpath,
though I'm not sure. There's no package structure to the source.

------
solidsnack9000
It don’t mean a thing...

~~~
westoncb
Haha I was very confused until:

"It Don't Mean a Thing (If It Ain't Got That Swing)"
[https://www.youtube.com/watch?v=qDQpZT3GhDg](https://www.youtube.com/watch?v=qDQpZT3GhDg)

:)

------
camus2
By the way there is still no HN OAUTH API. There are tricks to authenticate
users and send messages but I don't want to share my password with a 3rd
party.

------
wcauchois
this is awesome! i love the mix of age-old apis with a cutting edge
programming language. this must've been really fun to code.

~~~
westoncb
Haha, yep, it was a lot of fun. Especially going back and using Swing after
about a decade of using other UI libs—that was a very interesting experience.
When I was initially using Swing it was all I knew and at first I thought of
all new systems in terms of it. I even tried re-writing a super stripped down
version of it on OpenGL way back when:
[http://symbolflux.com/statichtml/oldprojects/openglguisystem...](http://symbolflux.com/statichtml/oldprojects/openglguisystem.html)
:)

------
marktangotango
Doesn't look like a regular jtree in the right pane, what did you use for
showing the comment hierarchy?

~~~
westoncb
It is a regular JTree! —mostly. I am using a custom TreeCellRenderer, which
uses a JPanel with some labels on top, and a JTextPane for to display the
comment itself (since the HN API gives back comments as html, I use JTextPane
to parse/render that html).

Edit: it also may look different if you aren't used to seeing the 'Nimbus'
Look and Feel—its JTree looks fairly different.

------
kevinherron
Some suggestions:

1) don't start a new project in Swing when you could use JavaFX instead. Since
you're using Kotlin, you'd also want to use TornadoFX, a nice DSL for JavaFX.

2) use Maven or Gradle (or hell, any build tool). Don't store artifacts in
source control.

I was really hoping someone who knew what they were doing was building this
after the mini Electron debate earlier this week :/

~~~
crispinb
Excuse a quick aside -- do you know of any good examples of real non-
enterprisey apps using JavaFX?

Java desktop apps seem almost universally awful, but it doesn't seem like it
has to be that way. I'd love to see some counter examples (IntelliJ's IDEs are
honourable exceptions, but they're a bit of a special case).

~~~
brabel
The old LoadUI (load testing tool) was written in JavaFX, you can still see
the old screenshots in the documentation: [https://www.loadui.org/working-
with-loadui/projects.html](https://www.loadui.org/working-with-
loadui/projects.html)

Also, there's LoadFX (a logging viewer) which was part of the rage post
against Electron last week:
[https://github.com/renatoathaydes/LogFX](https://github.com/renatoathaydes/LogFX)

And Gluon keeps a list of sample apps:

[http://gluonhq.com/developers/samples/](http://gluonhq.com/developers/samples/)

~~~
crispinb
Cheers. I might have a go at some JavaFX stuff for fun sometime (or more
likely TornadoFX with kotlin).

