本文整理汇总了Java中javax.swing.Box.setBackground方法的典型用法代码示例。如果您正苦于以下问题:Java Box.setBackground方法的具体用法?Java Box.setBackground怎么用?Java Box.setBackground使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.Box
的用法示例。
在下文中一共展示了Box.setBackground方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createP3
import javax.swing.Box; //导入方法依赖的package包/类
JPanel createP3() {
p3 = new JPanel(new BorderLayout());
model = new DefaultListModel();
list = new JList(model);
list.setCellRenderer(new YTListRenderer());
p3.add(new JScrollPane(list));
Box box = Box.createHorizontalBox();
box.add(Box.createHorizontalGlue());
btnDwnld = new JButton("Download");
btnDwnld.addActionListener(this);
btnCancel = new JButton("Close");
btnCancel.addActionListener(this);
box.add(btnDwnld);
box.add(Box.createHorizontalStrut(10));
box.add(btnCancel);
btnCancel.setPreferredSize(btnDwnld.getPreferredSize());
box.add(Box.createHorizontalStrut(10));
box.add(Box.createRigidArea(new Dimension(0, 40)));
p3.add(box, BorderLayout.SOUTH);
box.setOpaque(true);
box.setBackground(StaticResource.titleColor);
return p3;
}
示例2: createLeftPanel
import javax.swing.Box; //导入方法依赖的package包/类
void createLeftPanel() {
Box leftBox = Box.createVerticalBox();
leftBox.setOpaque(true);
leftBox.setBackground(StaticResource.titleColor);
JLabel title = new JLabel(getString("CONFIG_TITLE"));
title.setForeground(Color.white);
title.setFont(title.getFont().deriveFont(Font.BOLD,
title.getFont().getSize() * 1.2f));
title.setBorder(new EmptyBorder(20, 20, 20, 40));
leftBox.add(title);
centerPanel.add(leftBox, BorderLayout.WEST);
arrLbl = new JLabel[9];
for (int i = 0; i < 9; i++) {
String id = "CONFIG_LBL" + (i + 1);
arrLbl[i] = new JLabel(getString(id));
arrLbl[i].setName(id);
arrLbl[i].addMouseListener(clickHandler);
arrLbl[i].setForeground(Color.white);
arrLbl[i].setFont(plainFont);
arrLbl[i].setBorder(new EmptyBorder(5, 20, 5, 20));
leftBox.add(arrLbl[i]);
}
}
示例3: createP1
import javax.swing.Box; //导入方法依赖的package包/类
void createP1() {
Box p11 = Box.createVerticalBox();
p11.setBackground(Color.white);
p11.setOpaque(true);
p1 = new JPanel(new BorderLayout());
Box b1 = Box.createHorizontalBox();
b1.setBackground(Color.white);
b1.setOpaque(true);
b1.setBorder(new EmptyBorder(25, 15, 10, 15));
JLabel lbl = new JLabel();
lbl.setText(StringResource.getString("YT_LBL1"));
lbl.setOpaque(false);
JLabel icon = new JLabel(XDMIconMap.getIcon("YT_ICON"));
icon.setMaximumSize(new Dimension(75, 75));
b1.add(icon);
b1.add(Box.createRigidArea(new Dimension(10, 10)));
b1.add(lbl);
ytaddr = new JTextField();
ytaddr.setMaximumSize(new Dimension(ytaddr.getMaximumSize().width,
ytaddr.getPreferredSize().height));
p11.add(b1);
Box b2 = Box.createHorizontalBox();
b2.add(ytaddr);
b2.setBackground(Color.white);
b2.setOpaque(true);
b2.setBorder(new EmptyBorder(10, 15, 15, 15));
p11.add(b2);
p11.add(Box.createVerticalStrut(20));
p1.add(p11);
Box b3 = Box.createHorizontalBox();
get_video = new JButton(StringResource.getString("YT_LBL4"));
btnDim = get_video.getPreferredSize();
get_video.setName("YT_LBL4");
get_video.addActionListener(this);
cancel = new JButton(StringResource.getString("CANCEL"));
cancel.setName("CANCEL");
cancel.addActionListener(this);
cancel.setPreferredSize(btnDim);
b3.add(Box.createHorizontalGlue());
b3.add(get_video);
b3.add(Box.createRigidArea(new Dimension(10, 10)));
b3.add(cancel);
b3.setBorder(new EmptyBorder(10, 15, 10, 15));
b3.setOpaque(true);
b3.setBackground(StaticResource.titleColor);
p1.add(b3, BorderLayout.SOUTH);
}