Java Reference
In-Depth Information
private void jBtnZeichnenActionPerformed(ActionEvent evt) {
try {
x1 = Integer.parseInt(jTFPositionx1.getText());
y1 = Integer.parseInt(jTFPositiony1.getText());
x2 = Integer.parseInt(jTFPositionx2.getText());
y2 = Integer.parseInt(jTFPositiony2.getText());
switch (figur) {
case 'R':
if (jCheckBgefuellt.isSelected()) {
jPanelZeichenflaeche.getGraphics().fillRect(x1, y1, x2, y2);
}else{
jPanelZeichenflaeche.getGraphics().drawRect(x1, y1, x2, y2);
}
break;
case 'K':
if (jCheckBgefuellt.isSelected()) {
jPanelZeichenflaeche.getGraphics().fillOval(x1, y1, x2, x2);
}else{
jPanelZeichenflaeche.getGraphics().drawOval(x1, y1, x2, x2);
13
}
break;
case 'O':
if (jCheckBgefuellt.isSelected()) {
jPanelZeichenflaeche.getGraphics().fillOval(x1, y1, x2, y2);
}else{
jPanelZeichenflaeche.getGraphics().drawOval(x1, y1, x2, y2);
}
break;
case 'L':
jPanelZeichenflaeche.getGraphics().drawLine(x1, y1, x2, y2);
break;
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, "Die Eingaben sind ungültig.");
}
}
Listing 13.5 Die Zeichenmethode
Search WWH ::




Custom Search