I'm quite new to this. When I manually change the Jframe border size, it still updates at "19201080" , I'm trying to get the actual Jframe width and height so I'm able to have my Circle component change size based on jframe screen size,
CircleComponent class
package advancedjava;
import java.awt.*;
import javax.swing.JComponent;
import java.awt.Toolkit;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Ellipse2D.Double;
/**
*
* @author eeu8c6
*/
public class CircleComponent extends JComponent{
@Override
public void paintComponent(Graphics g){
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
int width = screenSize.width;
int height = screenSize.height;
System.out.println("test: " + width + height);
double swidth = width * 0.8;
double sheight = height * 0.8;
Graphics2D g2 = (Graphics2D) g;
Circle c1 = new Circle(50, 50);
g2.setPaint(Color.RED);
c1.draw(g2);
Ellipse2D ellipse = new Ellipse2D.Double();
g2.fill(ellipse);
}
}
Circle Class:
package advancedjava;
import java.awt.*;
import java.awt.geom.*;
/**
*
* @author eeu8c6
*/
public class Circle {
private double xLeft;
private double xRight;
public Circle(double x, double y){
xLeft = x;
xRight = y;
}
public void draw(Graphics2D g2){
Ellipse2D.Double circle = new Ellipse2D.Double(xLeft, xRight, 400, 400);
g2.draw(circle);
}