本文整理了Java中javax.swing.JComponent.setOpaque()
方法的一些代码示例,展示了JComponent.setOpaque()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComponent.setOpaque()
方法的具体详情如下:
包路径:javax.swing.JComponent
类名称:JComponent
方法名:setOpaque
暂无
代码示例来源:origin: stackoverflow.com
JLabel javaHomeLabel = new JLabel("java.home=" + System.getProperty("java.home"));
setLayout(new BorderLayout());
add(versionLabel, BorderLayout.PAGE_START);
add(javaHomeLabel, BorderLayout.PAGE_END);
JFrame frame = new JFrame("MyJavaMacOSXApp");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
MyJavaMacOSXApp newContentPane = new MyJavaMacOSXApp();
newContentPane.setOpaque(true);
frame.setContentPane(newContentPane);
frame.pack();
frame.setVisible(true);
代码示例来源:origin: stackoverflow.com
constraints.fill = GridBagConstraints.BOTH;
JLabel l = new JLabel("You have got 2 new Messages.");
panel.add(l, constraints);
constraints.gridx++;
constraints.weightx = 0f;
b.setOpaque(false);
b.setMargin(new Insets(1, 4, 1, 4));
b.setFocusable(false);
panel.add(b, constraints);
dialog.setUndecorated(true);
dialog.setSize(300, 100);
setOpaque(true);
代码示例来源:origin: stackoverflow.com
s.getViewport().add(m_tree);
getContentPane().add(s, BorderLayout.CENTER);
setVisible(true);
m_borderSelectionColor = UIManager.getColor(
"Tree.selectionBorderColor");
setOpaque(false);
代码示例来源:origin: io.snappydata/gemfirexd-tools
private static void createAndShowGUI(JPanel jtop) {
JFrame frame = new JFrame("GfxdTop");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JComponent contentPane = (JComponent) frame.getContentPane();
contentPane.add(jtop, BorderLayout.CENTER);
contentPane.setOpaque(true);
contentPane.setBorder(new EmptyBorder(12, 12, 12, 12));
frame.setContentPane(contentPane);
frame.pack();
frame.setVisible(true);
}
代码示例来源:origin: org.jboss.jbossts/jbossjta
private static void createAndShowGUI(TxPerfGraph perfPanel) {
JFrame frame = perfPanel.getFrame();
// Create and set up the window.
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Create and set up the content pane.
JComponent contentPane = (JComponent) frame.getContentPane();
contentPane.add(perfPanel, BorderLayout.CENTER);
contentPane.setOpaque(true); //content panes must be opaque
contentPane.setBorder(new EmptyBorder(12, 12, 12, 12));
frame.setContentPane(contentPane);
// Display the window.
frame.pack();
frame.setVisible(true);
}
代码示例来源:origin: stackoverflow.com
borderPanel.setBorder(
BorderFactory.createTitledBorder("BorderLayout"));
borderPanel.setOpaque(true);
borderPanel.setBackground(Color.WHITE);
for (int i = 0; i < 5; i++) {
buttons[i] = new JButton(borderConstraints[i]);
borderPanel.add(buttons[i], borderConstraints[i]);
flowPanel.setBorder(
BorderFactory.createTitledBorder("FlowLayout"));
flowPanel.setOpaque(true);
flowPanel.setBackground(Color.WHITE);
for (int i = 5; i < 8; i++) {
buttons[i] = new JButton(Integer.toString(i));
flowPanel.add(buttons[i]);
gridPanel.setBorder(
BorderFactory.createTitledBorder("GridLayout"));
gridPanel.setOpaque(true);
gridPanel.setBackground(Color.WHITE);
for (int i = 8; i < 12; i++) {
gridBagPanel.setBorder(
BorderFactory.createTitledBorder("GridBagLayout"));
gridBagPanel.setOpaque(true);
gridBagPanel.setBackground(Color.WHITE);
buttons[12] = new JButton(Integer.toString(12));
cardPanel.setBorder(
代码示例来源:origin: stackoverflow.com
public static void createGUI(){
JFrame frame = new JFrame("My Frame");
JComponent component = new Drawing();
component.setOpaque(true);
frame.add(component);
frame.setSize(600,400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
代码示例来源:origin: stackoverflow.com
gui.add(l1);
l2.setOpaque(true);
gui.add(l2);
p1.add(new JLabel("Panel 1"));
p1.setBorder(brdrRight);
p1.setOpaque(false);
gui.add(p1);
代码示例来源:origin: stackoverflow.com
import java.awt.Color;
import javax.swing.JPanel;
public class NewClass1 extends javax.swing.JFrame
{
public NewClass1() {
setLayout(null);
JPanel panel=new JPanel();
panel.setOpaque(true);
add(panel);
panel.setBackground(Color.red);
panel.setBounds(0,0,400,300);
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewClass1().setVisible(true);
}
});
}
}
代码示例来源:origin: stackoverflow.com
JFrame f = new JFrame("AnimationTest");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(this);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
timer.start();
this.setOpaque(false);
this.setPreferredSize(new Dimension(WIDE, HIGH));
this.addMouseListener(new MouseHandler());
Dimension d = field.getPreferredSize();
field.setBounds(e.getX(), e.getY(), d.width, d.height);
add(field);
代码示例来源:origin: kousen/java_8_recipes
private static void createAndShowGUI() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JComponent newContentPane = new MyUI();
newContentPane.setOpaque(true);
frame.setContentPane(newContentPane);
System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "MyUI");
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
frame.pack();
frame.setVisible(true);
}
代码示例来源:origin: stackoverflow.com
this.setLayout(new BorderLayout());
checkBox = new JCheckBox();
add(checkBox, BorderLayout.CENTER);
setOpaque(false);
checkBox.setOpaque(cn.isSelected && cn.hasChildren && ! cn.allChildrenSelected);
return this;
代码示例来源:origin: stackoverflow.com
usrNameFeild.setOpaque(false);
usrNameLabel.setLabelFor(usrNameFeild);
passFeild.setBorder(compundBorder);
passFeild.setOpaque(false);
passwordLabel.setLabelFor(passFeild);
add(usrNameLabel, labCnst);
add(usrNameFeild, txtCnst);
add(passwordLabel, labCnst);
add(passFeild, txtCnst);
JFrame frame = new JFrame("Demo: LogIn Dialogue");
frame.add(new MainContainer());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
代码示例来源:origin: biojava/biojava
/**
* Create the GUI and show it. As with all GUI code, this must run
* on the event-dispatching thread.
*/
private static void createAndShowGUI(GUIAlignmentProgressListener progressListener) {
//Create and set up the window.
JFrame frame = new JFrame("Monitor alignment process");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
JComponent newContentPane = progressListener;
newContentPane.setOpaque(true); //content panes must be opaque
newContentPane.setSize(new Dimension(400,400));
frame.setContentPane(newContentPane);
//Display the window.
frame.pack();
frame.setVisible(true);
}
代码示例来源:origin: camunda/camunda-bpm-platform
public CategoryNodeRenderer() {
_panel.setBackground(UIManager.getColor("Tree.textBackground"));
if (_sat == null) {
// Load the satellite image.
String resource =
"/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif";
URL satURL = getClass().getResource(resource);
_sat = new ImageIcon(satURL);
}
setOpaque(false);
_checkBox.setOpaque(false);
_panel.setOpaque(false);
// The flowlayout set to LEFT is very important so that the editor
// doesn't jump around.
_panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
_panel.add(_checkBox);
_panel.add(this);
setOpenIcon(_sat);
setClosedIcon(_sat);
setLeafIcon(_sat);
}
代码示例来源:origin: stackoverflow.com
for (int col = 0; col < GRID_COLS; col++) {
panelGrid[row][col] = new JPanel(new GridBagLayout());
backingPanel.add(panelGrid[row][col]);
redLabel.setOpaque(true);
redLabel.setBackground(Color.red.brighter().brighter());
redLabel.setPreferredSize(LABEL_SIZE);
panelGrid[4][3].add(redLabel);
blueLabel.setOpaque(true);
blueLabel.setBackground(Color.blue.brighter().brighter());
blueLabel.setPreferredSize(LABEL_SIZE);
panelGrid[1][1].add(blueLabel);
JFrame frame = new JFrame("DragLabelOnLayeredPane");
frame.getContentPane().add(new DragLabelOnLayeredPane());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("LayeredPaneDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
JComponent newContentPane = new LayeredPaneDemo();
newContentPane.setOpaque(true); //content panes must be opaque
frame.setContentPane(newContentPane);
//Display the window.
frame.pack();
frame.setVisible(true);
}
代码示例来源:origin: stackoverflow.com
int step = w/3;
JPanel p = new JPanel(new GridLayout(3,3));
p.setOpaque(false);
int count = 0;
for (int ii=0; ii<w; ii+=step) {
p.add(button);
} else {
JLabel label = new JLabel(new ImageIcon(icon));
p.add(label);
center.add(p);
JOptionPane.showMessageDialog(null, center);
代码示例来源:origin: stackoverflow.com
private JFrame frame = new JFrame();
label.setOpaque(true);
label.setBackground(Color.RED);
label.setForeground(Color.WHITE);
setLayout(new FlowLayout(FlowLayout.RIGHT));
add(label);
add(new MainPanel(), BorderLayout.CENTER);
add(new BorderPanel(), BorderLayout.PAGE_START);
setBorder(new LineBorder(Color.BLACK, 5));
frame.setUndecorated(true);
frame.add(new OutsidePanel());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
代码示例来源:origin: AliView/AliView
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("DropDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
JComponent newContentPane = new DropDemo();
newContentPane.setOpaque(true); //content panes must be opaque
frame.setContentPane(newContentPane);
//Display the window.
frame.pack();
frame.setVisible(true);
}
内容来源于网络,如有侵权,请联系作者删除!