本文整理匯總了Java中java.awt.Frame.getBackground方法的典型用法代碼示例。如果您正苦於以下問題:Java Frame.getBackground方法的具體用法?Java Frame.getBackground怎麽用?Java Frame.getBackground使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.Frame
的用法示例。
在下文中一共展示了Frame.getBackground方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testChildPropertiesWithFrameAsParent
import java.awt.Frame; //導入方法依賴的package包/類
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);
frameChildWindow = new Window(parentFrame);
frameChildWindow.setSize(WIDTH, HEIGHT);
frameChildWindow.setLocation(WIDTH + 200, 400);
childLabel = new Label("ChildForegroundAndFont");
frameChildWindow.add(childLabel);
frameChildWindow.setVisible(true);
if (parentFrame.getBackground() == frameChildWindow.getBackground()) {
dispose();
throw new RuntimeException("Child Window Should NOT Inherit "
+ "Parent Frame's Background Color");
}
if (parentDialog.getForeground() == windowChild.getForeground()) {
dispose();
throw new RuntimeException("Child Window Should NOT Inherit "
+ "Parent Frame's Foreground Color");
}
if (parentDialog.getFont() == windowChild.getFont()) {
dispose();
throw new RuntimeException("Child Window Should NOT Inherit "
+ "Parent Frame's Font Color");
}
}
示例2: testChildPropertiesWithFrameAsParent
import java.awt.Frame; //導入方法依賴的package包/類
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");
}
}