本文整理汇总了Java中java.awt.Dialog.setBackground方法的典型用法代码示例。如果您正苦于以下问题:Java Dialog.setBackground方法的具体用法?Java Dialog.setBackground怎么用?Java Dialog.setBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Dialog
的用法示例。
在下文中一共展示了Dialog.setBackground方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.awt.Dialog; //导入方法依赖的package包/类
public static void main(String[] args) {
final Frame frame = new Frame("Test");
frame.setSize(400, 400);
frame.setBackground(FRAME_COLOR);
frame.setVisible(true);
final Dialog modalDialog = new Dialog(null, true);
modalDialog.setTitle("Modal Dialog");
modalDialog.setSize(400, 200);
modalDialog.setBackground(DIALOG_COLOR);
modalDialog.setModal(true);
new Thread(new Runnable() {
@Override
public void run() {
runTest(modalDialog, frame);
}
}).start();
modalDialog.setVisible(true);
}
示例2: testChildPropertiesWithDialogAsParent
import java.awt.Dialog; //导入方法依赖的package包/类
public void testChildPropertiesWithDialogAsParent() {
parentDialog = new Dialog((Dialog) null, "parent Dialog");
parentDialog.setSize(WIDTH, HEIGHT);
parentDialog.setLocation(100, 100);
parentDialog.setBackground(Color.RED);
parentLabel = new Label("ParentForegroundAndFont");
parentFont = new Font("Courier New", Font.ITALIC, 15);
parentDialog.setForeground(Color.BLUE);
parentDialog.setFont(parentFont);
parentDialog.add(parentLabel);
parentDialog.setVisible(true);
windowChild = new Window(parentDialog);
windowChild.setSize(WIDTH, HEIGHT);
windowChild.setLocation(WIDTH + 200, 100);
childLabel = new Label("ChildForegroundAndFont");
windowChild.add(childLabel);
windowChild.setVisible(true);
if (parentDialog.getBackground() == windowChild.getBackground()) {
dispose();
throw new RuntimeException("Child Window Should NOT Inherit "
+ "Parent Dialog's Background Color");
}
if (parentDialog.getForeground() == windowChild.getForeground()) {
dispose();
throw new RuntimeException("Child Window Should NOT Inherit "
+ "Parent Dialog's Foreground Color");
}
if (parentDialog.getFont() == windowChild.getFont()) {
dispose();
throw new RuntimeException("Child Window Should NOT Inherit "
+ "Parent Dialog's Font Color");
}
}
示例3: main
import java.awt.Dialog; //导入方法依赖的package包/类
public static void main(String[] args) {
Robot robot = Util.createRobot();
Frame frame = new Frame("Frame");
frame.setBackground(Color.BLUE);
frame.setBounds(200, 50, 300, 300);
frame.setVisible(true);
Dialog dialog1 = new Dialog(frame, "Dialog 1", false);
dialog1.setBackground(Color.RED);
dialog1.setBounds(100, 100, 200, 200);
dialog1.setVisible(true);
Dialog dialog2 = new Dialog(frame, "Dialog 2", false);
dialog2.setBackground(Color.GREEN);
dialog2.setBounds(400, 100, 200, 200);
dialog2.setVisible(true);
Util.waitForIdle(robot);
Util.clickOnComp(dialog2, robot);
Util.waitForIdle(robot);
Point point = dialog1.getLocationOnScreen();
int x = point.x + (int)(dialog1.getWidth() * 0.9);
int y = point.y + (int)(dialog1.getHeight() * 0.9);
try {
if (!Util.testPixelColor(x, y, dialog1.getBackground(), 10, 100, robot)) {
throw new RuntimeException("Test FAILED: Dialog is behind the frame");
}
} finally {
frame.dispose();
dialog1.dispose();
dialog2.dispose();
}
}
示例4: testChildPropertiesWithDialogAsParent
import java.awt.Dialog; //导入方法依赖的package包/类
public void testChildPropertiesWithDialogAsParent() {
parentDialog = new Dialog((Dialog) null, "parent Dialog");
parentDialog.setSize(WIDTH, HEIGHT);
parentDialog.setLocation(100, 100);
parentDialog.setBackground(Color.RED);
parentLabel = new Label("ParentForegroundAndFont");
parentFont = new Font("Courier New", Font.ITALIC, 15);
parentDialog.setForeground(Color.BLUE);
parentDialog.setFont(parentFont);
parentDialog.add(parentLabel);
parentDialog.setVisible(true);
dialogChild = new Dialog(parentDialog, "Dialog's child");
dialogChild.setSize(WIDTH, HEIGHT);
dialogChild.setLocation(WIDTH + 200, 100);
childLabel = new Label("ChildForegroundAndFont");
dialogChild.add(childLabel);
dialogChild.setVisible(true);
if (parentDialog.getBackground() == dialogChild.getBackground()) {
dispose();
throw new RuntimeException("Child Dialog Should NOT Inherit "
+ "Parent Dialog's Background Color");
}
if (parentDialog.getForeground() == dialogChild.getForeground()) {
dispose();
throw new RuntimeException("Child Dialog Should NOT Inherit "
+ "Parent Dialog's Foreground Color");
}
if (parentDialog.getFont() == dialogChild.getFont()) {
dispose();
throw new RuntimeException("Child Dialog Should NOT Inherit "
+ "Parent Dialog's Font Style/Color");
}
}