Question: Given the following Java code how can I center on screen the graphics drawing made in a myPanel class? I just need a pseudo example

Given the following Java code how can I center on screen the graphics drawing made in a myPanel class? I just need a pseudo example since I cant post the whole code while enrolled in this class. import javax.swing.JFrame; public class Main { public static void main(String[] args) { JFrame myFrame = new JFrame("Minesweeper"); myFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); myFrame.setLocation(400,150); myFrame.setSize(1920, 1080); //Hard coded Resolution myFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); // sets Frame to full screen on launch MyPanel myPanel = new MyPanel(); myFrame.add(myPanel); MyMouseAdapter myMouseAdapter = new MyMouseAdapter(); myFrame.addMouseListener(myMouseAdapter); myFrame.setVisible(true); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!