public Dimension getPreferredSize() { return getSize();
}
public Dimension getSize() { returnnew Dimension(200, 200);
}
publicstaticvoid main(String args[]) throws Exception {
SwingUtilities.invokeAndWait(() -> createAndShowGUI());
Robot robot = new Robot();
robot.delay(5000);
robot.waitForIdle();
Color c = robot.getPixelColor(frame.getX() + 100, frame.getY() + 100); int red = c.getRed();
frame.dispose(); // Should be 126-128, but be tolerant of gamma correction. if (red < 122 || red > 132) { thrownew RuntimeException("Color is not as expected. Got " + c);
}
}
static Frame frame; privatestaticvoid createAndShowGUI() {
frame = new Frame("Alpha Color Test") {
@Override publicvoid paint(Graphics g) {
g.setColor(Color.black);
g.fillRect(0, 0, getWidth(), getHeight()); super.paint(g);
}
};
Color color = new Color(255, 255, 255, 127);
frame.add("Center", new AlphaColorTest(color));
frame.setUndecorated(true);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.