I am writing a program that uses a JFrame for rendering. This is what my frame setup looks like:
//Creating the frame.
frame = new JFrame(this.title);
frame.setSize(this.width, this.height);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.setVisible(true);
//Creating the canvas.
canvas = new Canvas();
canvas.setSize(this.width, this.height);
canvas.setBackground(Color.BLACK);
canvas.setVisible(true);
canvas.setFocusable(false);
//Putting it all together.
frame.add(canvas);
canvas.createBufferStrategy(3);
bufferStrategy = canvas.getBufferStrategy();
graphics = bufferStrategy.getDrawGraphics();
When I want to draw something I simply use the object graphics. There is only one issue; I find that the JFrame border is overlapping the draw area. Is there a way to find the native (I assume it changes per OS but I have not tested it) border thickness of the JFrame in order to compensate for that?
EDIT: This question is not a dupe of Drawing in Java using Canvas. The difference is that in that question the 'asker' could not draw anything at all. My problem is that the decoration/border of the JFrame is being placed over the top of some of the draw area. For example if I were to draw something at 0, 0 with the graphics object some of it would be hidden behind the JFrame border.