Java Reference
In-Depth Information
private static class MySwingNode extends SwingNode {
@Override
public double minWidth(double height) {
return 250;
}
@Override
public double minHeight(double width) {
return 200;
}
}
private static class MyRectangle extends JComponent {
private final Model model;
public MyRectangle(Model model) {
this.model = model;
}
@Override
public void paint(Graphics g) {
g.setColor(model.getStrokeColor());
g.fillRect(0, 0, 200, 200);
g.setColor(model.getFillColor());
g.fillRect(10, 10, 180, 180);
}
@Override
public Dimension getMaximumSize() {
return new Dimension(200, 200);
}
}
}
When the program in Listing 7-15 is run, the GUI in Figure 7-21 is displayed. The rectangle in the center of the
JavaFX application is a Swing JComponent .
Search WWH ::




Custom Search