本文整理汇总了Java中java.awt.Panel.setBackground方法的典型用法代码示例。如果您正苦于以下问题:Java Panel.setBackground方法的具体用法?Java Panel.setBackground怎么用?Java Panel.setBackground使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Panel
的用法示例。
在下文中一共展示了Panel.setBackground方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBorderPanel
import java.awt.Panel; //导入方法依赖的package包/类
/**
* Method declaration
*
*
* @param center
*
* @return
*/
protected static Panel createBorderPanel(Component center) {
Panel p = new Panel();
p.setBackground(SystemColor.control);
p.setLayout(new BorderLayout());
p.add("Center", center);
p.add("North", createLabel(""));
p.add("South", createLabel(""));
p.add("East", createLabel(""));
p.add("West", createLabel(""));
p.setBackground(SystemColor.control);
return p;
}
示例2: PointListDialog
import java.awt.Panel; //导入方法依赖的package包/类
/**
* Constructs an empty PointListDialog
*
* @param owner
*/
public PointListDialog(final Frame owner) {
super(owner, "Point list");
panel = new Panel();
gridbag = new GridBagLayout();
panel.setLayout(gridbag);
panel.setBackground(Color.WHITE);
c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
c.anchor = GridBagConstraints.NORTHWEST;
c.weighty = 0.1f;
c.fill = GridBagConstraints.NONE;
final ScrollPane scroll = new ScrollPane();
scroll.add(panel);
add(scroll);
}
示例3: displayColors
import java.awt.Panel; //导入方法依赖的package包/类
private void displayColors(World world) {
this.setSize(600, 800);
for (byte i = 1; i <= num; i++) {
Panel pnl = new Panel();
pnl.setPreferredSize(new Dimension(pnlSize + 8, pnlSize + 32));
Panel col = new Panel();
col.setPreferredSize(new Dimension(pnlSize, pnlSize));
col.setBackground(world.getType(i).getColor());
pnl.add(col);
Label lb = new Label();
lb.setText(world.getType(i).getName() + " " + Integer.toString(i));
pnl.add(lb);
add(pnl);
}
}
示例4: createBorderPanel
import java.awt.Panel; //导入方法依赖的package包/类
protected static Panel createBorderPanel(Component center) {
Panel p = new Panel();
p.setBackground(SystemColor.control);
p.setLayout(new BorderLayout());
p.add("Center", center);
p.add("North", createLabel(""));
p.add("South", createLabel(""));
p.add("East", createLabel(""));
p.add("West", createLabel(""));
p.setBackground(SystemColor.control);
return p;
}
示例5: createBorderPanel
import java.awt.Panel; //导入方法依赖的package包/类
/**
* Method declaration
*
*
* @param center
*/
private Panel createBorderPanel(Component center) {
Panel p = new Panel();
p.setBackground(SystemColor.control);
p.setLayout(new BorderLayout());
p.add("Center", center);
p.add("South", createLabel(""));
p.add("East", createLabel(""));
p.add("West", createLabel(""));
p.setBackground(SystemColor.control);
return p;
}
示例6: createBorderPanel
import java.awt.Panel; //导入方法依赖的package包/类
/**
* Method declaration
*
*
* @param center
*
* @return
*/
private Panel createBorderPanel(Component center) {
Panel p = new Panel();
p.setBackground(SystemColor.control);
p.setLayout(new BorderLayout());
p.add("Center", center);
p.add("South", createLabel(""));
p.add("East", createLabel(""));
p.add("West", createLabel(""));
p.setBackground(SystemColor.control);
return p;
}
示例7: initGUI
import java.awt.Panel; //导入方法依赖的package包/类
/**
* Create the graphical user interface. This is AWT code.
*/
private void initGUI() {
// all panels
Panel pQuery = new Panel();
Panel pCommand = new Panel();
Panel pButton = new Panel();
Panel pRecent = new Panel();
Panel pResult = new Panel();
Panel pBorderWest = new Panel();
Panel pBorderEast = new Panel();
Panel pBorderSouth = new Panel();
pQuery.setLayout(new BorderLayout());
pCommand.setLayout(new BorderLayout());
pButton.setLayout(new BorderLayout());
pRecent.setLayout(new BorderLayout());
pResult.setLayout(new BorderLayout());
pBorderWest.setBackground(SystemColor.control);
pBorderSouth.setBackground(SystemColor.control);
pBorderEast.setBackground(SystemColor.control);
// labels
Label lblCommand = new Label(" Command", Label.LEFT);
Label lblRecent = new Label(" Recent", Label.LEFT);
Label lblResult = new Label(" Result", Label.LEFT);
lblCommand.setBackground(SystemColor.control);
lblRecent.setBackground(SystemColor.control);
lblResult.setBackground(SystemColor.control);
// buttons
butExecute = new Button("Execute");
butScript = new Button("Script");
butImport = new Button("Import");
pButton.add("South", butScript);
pButton.add("Center", butExecute);
pButton.add("North", butImport);
// command - textarea
Font fFont = new Font("Dialog", Font.PLAIN, 12);
txtCommand = new TextArea(5, 40);
txtCommand.setFont(fFont);
// recent - choice
choRecent = new Choice();
// result - grid
gResult = new Grid();
// combine it
setLayout(new BorderLayout());
pRecent.add("Center", choRecent);
pRecent.add("North", lblRecent);
pCommand.add("North", lblCommand);
pCommand.add("East", pButton);
pCommand.add("Center", txtCommand);
pCommand.add("South", pRecent);
pResult.add("North", lblResult);
pResult.add("Center", gResult);
pQuery.add("North", pCommand);
pQuery.add("Center", pResult);
add("Center", pQuery);
add("West", pBorderWest);
add("East", pBorderEast);
add("South", pBorderSouth);
// [email protected] 20011210 - patch 450412 by [email protected]
doLayout();
}
示例8: ComponentIsNotDrawnAfterRemoveAddTest
import java.awt.Panel; //导入方法依赖的package包/类
public ComponentIsNotDrawnAfterRemoveAddTest() {
frame = new Frame("ComponentIsNotDrawnAfterRemoveAddTest");
frame.setSize(500, 500);
frame.setLocation(200, 200);
frame.setLayout(null);
frame.setBackground(Color.RED);
panel = new Panel();
panel.setLayout(null);
panel.setBounds(25, 100, 455, 295);
panel.setBackground(Color.GREEN);
for (int i = 0; i < 10; i++) {
TestCanvas canv1 = new TestCanvas();
canv1.setBounds(i * 45 + 5, 15, 30 + i, 30 + i);
panel.add(canv1);
compList.add(canv1);
TestButton btn1 = new TestButton();
btn1.setBounds(i * 45 + 5, 60, 30 + i, 30 + i);
panel.add(btn1);
compList.add(btn1);
TestCanvas canv2 = new TestCanvas();
canv2.setBounds(i * 45 + 5, 105, 30 + i, 30 + i);
panel.add(canv2);
compList.add(canv2);
TestButton btn2 = new TestButton();
btn2.setBounds(i * 45 + 5, 150, 30 + i, 30 + i);
panel.add(btn2);
compList.add(btn2);
TestCanvas canv3 = new TestCanvas();
canv3.setBounds(i * 45 + 5, 195, 30 + i, 30 + i);
panel.add(canv3);
compList.add(canv3);
TestButton btn3 = new TestButton();
btn3.setBounds(i * 45 + 5, 240, 30 + i, 30 + i);
panel.add(btn3);
compList.add(btn3);
}
frame.add(panel);
frame.setVisible(true);
}
示例9: displayDecisionVariables
import java.awt.Panel; //导入方法依赖的package包/类
private void displayDecisionVariables() {
Panel dvPanel = new Panel();
ScrollPane scrollPane = new ScrollPane();
GroupLayout dvlayout = new GroupLayout(dvPanel);
dvlayout.setAutoCreateGaps(true);
dvlayout.setAutoCreateContainerGaps(true);
ParallelGroup groupForElementsInLine = dvlayout.createParallelGroup(Alignment.LEADING);
SequentialGroup groupForElementsInColumns = dvlayout.createSequentialGroup();
for (Displayable displayable : decisionVariables) {
List<InfoGUI> infos = displayable.getInfo();
for (InfoGUI infoGUI : infos) {
DecisionVariableGUI dvGui1 = new DecisionVariableGUI(infoGUI);
groupForElementsInLine.addGroup((dvlayout.createSequentialGroup().addComponent(dvGui1.getLabel())
.addComponent(dvGui1.getComponent())));
groupForElementsInColumns.addGroup((dvlayout.createParallelGroup(Alignment.CENTER)
.addComponent(dvGui1.getLabel()).addComponent(dvGui1.getComponent())));
mapWithControls.add(dvGui1);
}
}
dvlayout.setHorizontalGroup(groupForElementsInLine);
dvlayout.setVerticalGroup(groupForElementsInColumns);
dvPanel.setLayout(dvlayout);
dvPanel.setBackground(Color.lightGray);
Collections.sort(mapWithControls);
Dimension scrollPaneDimension = new Dimension(dvPanel.getPreferredSize().width + 30,
dvPanel.getPreferredSize().height + 35);
scrollPane.setPreferredSize(new Dimension(250, 700));
if (scrollPaneDimension.height < scrollPane.getPreferredSize().height) {
scrollPane.setPreferredSize(scrollPaneDimension);
}
scrollPane.add(dvPanel);
controlPanel.add(scrollPane);
}
示例10: MakeMyDialog
import java.awt.Panel; //导入方法依赖的package包/类
public MakeMyDialog (int X, int Y, int width, int height, Color fg, Color bg, String title,
String text, boolean oneLine) {
// Create a frame from which we will launch a dialog warning window
final Frame mw = new Frame(title);
mw.setLayout(new BorderLayout());
mw.setSize(width,height);
mw.setLocation(X,Y);
Label hT = new Label(text,Label.CENTER);
hT.setForeground(fg);
hT.setBackground(bg);
hT.setFont(warnFont);
mw.add("Center", hT);
mw.setTitle(title);
// Add show warning button
Panel botPanel = new Panel();
botPanel.setBackground(Color.lightGray);
Label label1 = new Label();
Label label2 = new Label();
Button showButton = new Button("Show Modal Warning Window");
botPanel.add(label1);
botPanel.add(showButton);
botPanel.add(label2);
// Add inner class event handler for show warning button. This must be
// added to the showButton before botPanel is added to mw.
showButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
MakeMyDialog.this.makeTheWarning(200,200,200,100,Color.black,
Color.lightGray,"Warning","Warning message",
true, MakeMyDialog.this);
}
});
mw.add("South", botPanel);
// Add window closing button (inner class)
mw.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
mw.hide();
mw.dispose();
System.exit(0);
}
});
mw.show();
}
示例11: GenericHelpFrame
import java.awt.Panel; //导入方法依赖的package包/类
public GenericHelpFrame(String s, String t, int h, int w, int X,int Y, int lines, int columns) {
Font textFont = new java.awt.Font("SanSerif", Font.PLAIN, 12);
FontMetrics textFontMetrics = getFontMetrics(textFont);
Font buttonFont = new java.awt.Font("SanSerif", Font.BOLD, 11);
FontMetrics buttonFontMetrics = getFontMetrics(buttonFont);
Color bgColor = MyColors.helpColor; //new Color(245,245,245);
this.pack();
this.setSize(w,h);
this.setLocation(X,Y);
this.setTitle(t);
this.setResizable(false);
setLayout(new BorderLayout());
TextArea hT = new TextArea("",lines,columns, TextArea.SCROLLBARS_NONE);
hT.setEditable(false);
// Set color and font for TextArea.
hT.setForeground(Color.black);
hT.setFont(textFont);
hT.setBackground(bgColor);
// hT.disable();
ScrollPane sp = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
sp.add(hT);
this.add("Center", sp);
Panel leftPanel = new Panel();
leftPanel.setBackground(MyColors.gray204);
this.add("West",leftPanel);
// Add Dismiss button and bottom panel
Panel botPanel = new Panel();
botPanel.setFont(buttonFont);
botPanel.setBackground(MyColors.gray204);
Button dismissButton = new Button("Cancel");
botPanel.add(dismissButton);
this.add("South", botPanel);
// Insert the text string in the TextArea
hT.appendText("\n" + s);
// Add inner class event handler for Dismiss button
dismissButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
hide();
dispose();
ParamSetup.helpWindowOpen = false;
}
});
// Add window closing button (inner class)
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
hide();
dispose();
ParamSetup.helpWindowOpen = false;
}
});
}