Scala: Equivalent of WPF Canvas and Polygon

561 views Asked by At

I'm developing a Hex based Game. Having wrestled with the limitations of the C# type system, on discovering Scala I knew I had to rewrite the application in Scala. I need a basic GUI to be able to develop the main functionality. I've been using a WPF Canvas with Polygon class. I also use Wpf Border class and Line class on the Canvas. I don't need most of the functionality of Wpf. I don't use Xaml. i just need to map the graphical objects to the desired coordinates, receive left and right mouse click events from them and put up tool tips and display context menus. I don't even need the Wpf context menu property as as I prefer to the context menus to be dynamic. I handle scrolling and zoom through my own code.

The best that I've found to make Polygons is the awt GeneralPath class. Although this is supposedly depreciated. I've started with Scala Swing, but the MainFrame class will not allow me to use the awt canvas class as content. Any help / recommendations appreciated

1

There are 1 answers

0
Alex On BEST ANSWER

just override paint of some Component:

public class MyCanvasPanel extends JPanel{
  ...
  @Override
 public void paint(Graphics g){/* do your java2d stuff here*/}
}