Java Code Examples for java.awt.Frame#getForeground()

The following examples show how to use java.awt.Frame#getForeground() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChildDialogProperties.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void testChildPropertiesWithFrameAsParent() {

        parentFrame = new Frame("parent Frame");
        parentFrame.setSize(WIDTH, HEIGHT);
        parentFrame.setLocation(100, 400);
        parentFrame.setBackground(Color.BLUE);
        parentLabel = new Label("ParentForegroundAndFont");
        parentFont = new Font("Courier New", Font.ITALIC, 15);
        parentFrame.setForeground(Color.RED);
        parentFrame.setFont(parentFont);
        parentFrame.add(parentLabel);
        parentFrame.setVisible(true);

        frameChildDialog = new Dialog(parentFrame, "Frame's child");
        frameChildDialog.setSize(WIDTH, HEIGHT);
        frameChildDialog.setLocation(WIDTH + 200, 400);
        childLabel = new Label("ChildForegroundAndFont");
        frameChildDialog.add(childLabel);
        frameChildDialog.setVisible(true);

        if (parentFrame.getBackground() == frameChildDialog.getBackground()) {
            dispose();
            throw new RuntimeException("Child Dialog Should NOT Inherit "
                    + "Parent Frame's Background Color");
        }

        if (parentFrame.getForeground() == frameChildDialog.getForeground()) {
            dispose();
            throw new RuntimeException("Child Dialog Should NOT Inherit "
                    + "Parent Frame's Foreground Color");
        }

        if (parentFrame.getFont() == frameChildDialog.getFont()) {
            dispose();
            throw new RuntimeException("Child Dialog Should NOT Inherit "
                    + "Parent Frame's Font Style/Color");
        }
    }