Jump to content

I'm working on making a chess game in Java for one of my CS classes and I'm now up to building the GUI/View portion of the code, but I'm really not sure where to start or how to go about doing it. 

 

Obviously, I'll need the following methods (and probably some helpers), but I'm not sure how to implement any of them. But for right now, just printing the board is my priority (and will probably make the rest relatively trivial). (the model portion is finished and working -- as far as I can tell -- so I have a 2D array keeping track of the board status and an array of players)

 

 


Print/display the board's and the initial configuration. 

Show possible moves for the selected piece. 

Player names, score, move count, and timer.
 

 

PSU Tier List | CoC

Gaming Build | FreeNAS Server

Spoiler

i5-4690k || Seidon 240m || GTX780 ACX || MSI Z97s SLI Plus || 8GB 2400mhz || 250GB 840 Evo || 1TB WD Blue || H440 (Black/Blue) || Windows 10 Pro || Dell P2414H & BenQ XL2411Z || Ducky Shine Mini || Logitech G502 Proteus Core

Spoiler

FreeNAS 9.3 - Stable || Xeon E3 1230v2 || Supermicro X9SCM-F || 32GB Crucial ECC DDR3 || 3x4TB WD Red (JBOD) || SYBA SI-PEX40064 sata controller || Corsair CX500m || NZXT Source 210.

Link to comment
https://linustechtips.com/topic/660605-viewgui-in-java/
Share on other sites

Link to post
Share on other sites

bump 

PSU Tier List | CoC

Gaming Build | FreeNAS Server

Spoiler

i5-4690k || Seidon 240m || GTX780 ACX || MSI Z97s SLI Plus || 8GB 2400mhz || 250GB 840 Evo || 1TB WD Blue || H440 (Black/Blue) || Windows 10 Pro || Dell P2414H & BenQ XL2411Z || Ducky Shine Mini || Logitech G502 Proteus Core

Spoiler

FreeNAS 9.3 - Stable || Xeon E3 1230v2 || Supermicro X9SCM-F || 32GB Crucial ECC DDR3 || 3x4TB WD Red (JBOD) || SYBA SI-PEX40064 sata controller || Corsair CX500m || NZXT Source 210.

Link to comment
https://linustechtips.com/topic/660605-viewgui-in-java/#findComment-8543627
Share on other sites

Link to post
Share on other sites

16 hours ago, djdwosk97 said:

bump 

You can use Window Builder extension if you're using Eclipse IDE.

 

It helps you design a GUI and let you switch between code and GUI.

Judge a product on its own merits AND the company that made it.

How to setup MSI Afterburner OSD | How to make your AMD Radeon GPU more efficient with Radeon Chill | (Probably) Why LMG Merch shipping to the EU is expensive

Oneplus 6 (Early 2023 to present) | HP Envy 15" x360 R7 5700U (Mid 2021 to present) | Steam Deck (Late 2022 to present)

 

Mid 2023 AlTech Desktop Refresh - AMD R7 5800X (Mid 2023), XFX Radeon RX 6700XT MBA (Mid 2021), MSI X370 Gaming Pro Carbon (Early 2018), 32GB DDR4-3200 (16GB x2) (Mid 2022

Noctua NH-D15 (Early 2021), Corsair MP510 1.92TB NVMe SSD (Mid 2020), beQuiet Pure Wings 2 140mm x2 & 120mm x1 (Mid 2023),

Link to comment
https://linustechtips.com/topic/660605-viewgui-in-java/#findComment-8547347
Share on other sites

Link to post
Share on other sites

As someone already pointed out, Java offers 3 frameworks to build any GUI you'd need: AWT, Swing and JavaFX.

Though AWT and Swing are still supported, JavaFX is the hottest of all to build GUIs since you can pretty much use XML and then inject Java code into it.

 

I'm using IntelliJ as IDE and there's the SceneBuilder plugin which allows you to design your own GUI without spitting blood on XML, if you don't know it; but first let me introduce you to the JavaFX mentality.

Every action you do on the GUI has to be done within the JavaFX Thread, that means that both the GUI controller and the backend have to interact with methods such as Platform.runLater() to apply the visual changes to your chessboard.

This is pretty much the only drawback of JavaFX, since it's far superior to AWT and Swing in performances.

 

I hope it's allowed to link to external tutorial websites; if it is, here you go one of them.

P.S. JavaFX is enterely shipped in native Java code only since the 8th JDK release, so make sure to upgrade to it if you're not using it already.

Link to comment
https://linustechtips.com/topic/660605-viewgui-in-java/#findComment-8548609
Share on other sites

Link to post
Share on other sites

On 15/09/2016 at 2:12 PM, Erik Sieghart said:

You can use AWT (awful), Swing (less awful), or JavaFx (I don't know about this one). These are Java frameworks for building GUIs.

JavaFX is the newer platform, and the one that is going to be supported over Swing in future, but Swing would have more features as it's a tried and true framework. That said, JavaFX is only available from Java 8 and up, so if you're planning to target older Java platforms as well, FX won't be the way to go

Link to comment
https://linustechtips.com/topic/660605-viewgui-in-java/#findComment-8556535
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×