本文整理匯總了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);
}