Ich habe zwei Klassen. Draw und DrawGUI. In DrawGUI habe ich ein JPanel. Für meinen JUnit Test muss ich die Klasse Draw nach getWidth() und getHeight() fragen. So ist mein Code wie folgt aus:Ich habe zwei Klassen und möchte eine Variable von einem zum anderen
public class Draw {
public static void main(String[] args) throws ColorException {new Draw();}
/** Application constructor: create an instance of our GUI class */
public Draw() throws ColorException { window = new DrawGUI(this); }
protected JFrame window;
public void getWidth(){
}
}
class DrawGUI extends JFrame {
JPanel drawPanel;
public DrawGUI(Draw application) throws ColorException {
super("Draw"); // Create the window
app = application;
drawPanel = new JPanel();
}
}
So wie ich getWidth implementieren? getWidth sollte die Breite der JPanel DrawPanel
'' 'return window.getWidth();' ''? –
@JornVernee Ich möchte getWidth aus dem JPanel DrawPanel und nicht das komplette Fenster. – Sonius