本文整理了Java中javax.swing.JLayeredPane
类的一些代码示例,展示了JLayeredPane
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLayeredPane
类的具体详情如下:
包路径:javax.swing.JLayeredPane
类名称:JLayeredPane
暂无
代码示例来源:origin: stackoverflow.com
private JFrame frame = new JFrame();
private JLayeredPane lpane = new JLayeredPane();
private JPanel panelBlue = new JPanel();
private JPanel panelGreen = new JPanel();
public Main()
frame.setPreferredSize(new Dimension(600, 400));
frame.setLayout(new BorderLayout());
frame.add(lpane, BorderLayout.CENTER);
lpane.setBounds(0, 0, 600, 400);
panelBlue.setBackground(Color.BLUE);
panelBlue.setBounds(0, 0, 600, 400);
panelGreen.setBounds(200, 100, 100, 100);
panelGreen.setOpaque(true);
lpane.add(panelBlue, new Integer(0), 0);
lpane.add(panelGreen, new Integer(1), 0);
frame.pack();
frame.setVisible(true);
代码示例来源:origin: magefree/mage
private void removePermanent(UUID permanentId, final int count) {
for (Component c : this.jPanel.getComponents()) {
final Component comp = c;
if (comp instanceof Permanent) {
if (((Permanent) comp).getPermanentId().equals(permanentId)) {
comp.setVisible(false);
this.jPanel.remove(comp);
}
} else if (comp instanceof MagePermanent) {
if (((MagePermanent) comp).getOriginal().getId().equals(permanentId)) {
Thread t = new Thread(() -> {
Plugins.instance.onRemoveCard((MagePermanent) comp, count);
comp.setVisible(false);
BattlefieldPanel.this.jPanel.remove(comp);
});
t.start();
}
if (((MagePermanent) comp).getOriginal().isCreature()) {
removedCreature = true;
}
}
}
}
代码示例来源:origin: magefree/mage
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
int w = getDlgParams().rect.width;
int h = getDlgParams().rect.height;
jLayeredPane = new JLayeredPane();
add(jLayeredPane);
jLayeredPane.setSize(w, h);
jLayeredPane.setVisible(true);
jLayeredPane.setOpaque(false);
jTitle = new CustomLabel();
jTitle.setBounds(new Rectangle(5, 3, w, 16));
jTitle.setFont(new Font("Dialog", Font.BOLD, 14));
jTitle.setText("Current stack: ");
this.setLayout(null);
jLayeredPane.setLayout(null);
jLayeredPane.add(jTitle, null);
//jLayeredPane.add(jTitle2, null);
jLayeredPane.add(getJButtonAccept(), null);
jLayeredPane.add(getJButtonResponse(), null);
makeTransparent(jLayeredPane);
}
代码示例来源:origin: stackoverflow.com
JLayeredPane pane = new JLayeredPane();
JLabel ontop = new JLabel("On top");
JLabel behind = new JLabel("Behind");
pane.add(ontop, 2, 0);
pane.add(behind, 1, 0);
代码示例来源:origin: magefree/mage
public void cleanUp() {
for (Component c : this.jPanel.getComponents()) {
if (c instanceof Permanent || c instanceof MagePermanent) {
this.jPanel.remove(c);
}
}
permanents.clear();
// Plugins.getInstance().sortPermanents(uiComponentsList, permanents.values());
this.bigCard = null;
}
代码示例来源:origin: stackoverflow.com
layeredPane = new JLayeredPane();
layeredPane.setPreferredSize( boardSize );
layeredPane.addMouseListener( this );
layeredPane.addMouseMotionListener( this );
getContentPane().add(layeredPane);
chessBoard.setLayout( new GridLayout(8, 8) );
chessBoard.setPreferredSize( boardSize );
chessBoard.setBounds(0, 0, boardSize.width, boardSize.height);
layeredPane.add(chessBoard, JLayeredPane.DEFAULT_LAYER);
square.setBackground( (i + j) % 2 == 0 ? Color.red : Color.white );
chessBoard.add( square );
frame.setDefaultCloseOperation( DISPOSE_ON_CLOSE );
frame.setResizable( false );
frame.pack();
frame.setLocationRelativeTo( null );
frame.setVisible(true);
代码示例来源:origin: stackoverflow.com
private JTable table = new JTable(30, 5);
private JScrollPane scroll = new JScrollPane(table);
private JLayeredPane layer = new JLayeredPane();
private JFrame frame = new JFrame("Frame with resiziable JLayeredPane");
textArea.setBorder(new LineBorder(Color.DARK_GRAY));
textArea.setText("Frame with resiziable JLayeredPane");
textPanel.setOpaque(false);
textPanel.add(textArea, BorderLayout.NORTH);
Font font = textArea.getFont();
FontMetrics fontMetrics = textArea.getFontMetrics(font);
int h = fontMetrics.getHeight() + frame.getInsets().top +
textPanel.getInsets().top + textArea.getInsets().top
+ textArea.getInsets().bottom;
scroll.setBounds(0, h, 400, 300);
layer.add(textPanel, new Integer(2));
layer.add(scroll, new Integer(1));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 400);
frame.addComponentListener(new ComponentAdapter() {
frame.setLocationRelativeTo(null);
frame.add(layer);
resizeAll();
frame.setVisible(true);
代码示例来源:origin: stackoverflow.com
private static JFrame mainFrame = new JFrame();
private static JPanel mainPane = new JPanel();
public Main(){}
JLayeredPane westPanel = new JLayeredPane();
westPanel.setLayout(null);
westPanel.setPreferredSize(new Dimension(200,0));
westPanel.setBackground(Color.blue);
layerOne.add(new JLabel("This is layer 1"));
layerOne.setBounds(0, 0, 100, 100);
westPanel.add(layerOne, new Integer(0), 0);
layerTwo.add(new JLabel("This si layer 2"));
layerTwo.setBounds(0, 100, 100, 100);
westPanel.add(layerTwo, new Integer(1), 0);
centerPanel.setBackground(Color.yellow);
mainPane.add(eastPanel, BorderLayout.EAST);
mainFrame = new JFrame("Learning to use JLayeredPane");
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.setBounds(200, 200, 800, 500);
mainFrame.setContentPane(mainPane);
mainFrame.setVisible(true);
代码示例来源:origin: stackoverflow.com
setLayout(new BorderLayout());
pane = new JLayeredPane();
pane.setBorder(new LineBorder(Color.RED));
players.setBackground(Color.RED);
players.setSize(getPreferredSize());
players.setLocation(0, 0);
pane.add(players, new Integer(0));
game.setSize(game.getPreferredSize());
game.setBackground(Color.BLUE);
game.setLocation(385, 405);
pane.add(game, new Integer(2));
add(pane);
JFrame frame = new JFrame();
JComponent newPane = new MainPanel();
newPane.setOpaque(true);
frame.setContentPane(newPane);
frame.pack();
frame.setVisible(true);
代码示例来源:origin: stackoverflow.com
frame.setSize(950, 600);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setBackground(Color.black);
layeredPane.add(redCanvas, new Integer(0));
layeredPane.add(upperPanel, new Integer(1));
getContentPane().add(layeredPane);
layeredPane = new JLayeredPane();
layeredPane.setLayout(null);
jButton.setSize(50, 50);
jButton.setBounds(50, 50, 50, 50);
upperPanel.add(jButton);
upperPanel.setLocation(70, 5);
upperPanel.setOpaque(false);
upperPanel.setSize(400, 200);
upperPanel.setBackground(new Color(0, 0, 0, 15));
redCanvas.setBackground(Color.RED);
redCanvas.setOpaque(true);
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame(title);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
dogLabel.setBounds(0,0,640,480);
JLayeredPane layeredPane = new JLayeredPane() ;
layeredPane.add( dogLabel, new Integer( 0 )) ;
layeredPane.setPreferredSize( new Dimension(500, 500) ) ;
jp.add( layeredPane ) ;
frame.getContentPane().add( scrollPane, BorderLayout.CENTER);
frame.setSize(300, 200);
frame.setVisible(true);
代码示例来源:origin: stackoverflow.com
private static JFrame frame = new MyFrame();
private static JPanel wkp = new JPanel();
private static JPanel panel = new JPanel();
private static JPanel table = new JPanel();
private static JLayeredPane lpane = new JLayeredPane();
public void run() {
wkp.setBackground(Color.YELLOW);
panel.setBackground(Color.GREEN);
table.setBackground(Color.BLUE);
frame.pack();
frame.setVisible(true);
代码示例来源:origin: stackoverflow.com
JLayeredPane pane = new JLayeredPane();
pane.setLayer( one, JLayeredPane.DEFAULT_LAYER );
pane.add( one );
pane.setBorder(new javax.swing.border.LineBorder(Color.BLACK,1));
JFrame frame = new JFrame();
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.add( pane );
frame.setSize( 500, 500 );
frame.setLocationRelativeTo( null );
frame.setVisible( true );
public RotateLabel( String text, int x, int y ) {
super( text );
setBorder( new javax.swing.border.CompoundBorder( new javax.swing.
border.LineBorder( Color.red, 1), getBorder() ) );
int width = getPreferredSize().width;
int height = getPreferredSize().height;
setBounds(x, y, width, height);
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame("FrameDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLayeredPane mainLayer = new JLayeredPane();
frame.add(mainLayer, BorderLayout.CENTER);
label.setBounds(100, 100, 200, 100);
label.setOpaque(true);
label.setBackground(Color.cyan);
mainLayer.add(label, 1);
subLabel.setBounds(20, 20, 200, 100);
subLabel.setOpaque(true);
subLabel.setBackground(Color.yellow);
subLayer.add(subLabel, BorderLayout.SOUTH);
mainLayer.add(subLabel, 2);
frame.pack();
frame.setSize(320, 240);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
代码示例来源:origin: stackoverflow.com
JPanel nPanel2 = getNode(20, 20, 20, 20, Color.yellow, 2);
JPanel nPanel3 = getNode(30, 30, 20, 20, Color.green, 3);
JLayeredPane pane = new JLayeredPane();
pane.add(nPanel, new Integer(1));
pane.add(nPanel2, new Integer(2));
pane.add(nPanel3, new Integer(3));
setContentPane(pane);
getContentPane().setBackground(Color.BLACK);
nodePanel.setBackground(color);
nodePanel.setBounds(i, i1, j, j1);
nodePanel.setOpaque(true);
nodePanel.setLayout(null);
return nodePanel;
public void run() {
JPanelParent jpp = new JPanelParent();
jpp.setVisible(true);
jpp.setSize(300, 300);
jpp.setBackground(Color.black);
代码示例来源:origin: stackoverflow.com
this.layeredPane = new JLayeredPane();
layeredPane.setPreferredSize(new Dimension(300, 300));
layeredPane.add(imageContainer, new Integer(50));
layeredPane.add(info, new Integer(100));
this.add(layeredPane);
imageContainer.setBounds( 0, 0,
image.getIconWidth(),
image.getIconHeight() );
info.setBounds( 200, 00, 50, 40 );
JFrame frame = new JFrame();
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.add( new MyClass( new ImageIcon("logo.png") ) );
frame.pack();
frame.setVisible( true );
代码示例来源:origin: stackoverflow.com
layers = new JLayeredPane();
down.setBackground(Color.GREEN);
down.setBounds(100, 100, 200, 200);
layers.add(down, new Integer(1));
up.setBackground(Color.RED);
up.setBounds(150, 150, 200, 200);
layers.add(up, new Integer(2));
getContentPane().add(layers, BorderLayout.CENTER);
toggleOpaque.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
up.setOpaque(!up.isOpaque());
layers.repaint();
buttonPanel.add(toggleOpaque);
getContentPane().add(buttonPanel, BorderLayout.EAST);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(500, 500);
f.setLocationRelativeTo(null);
f.setVisible(true);
代码示例来源:origin: stackoverflow.com
window = new JFrame("Foo");
window.setLayout(new BorderLayout());
layeredPane = new JLayeredPane();
layeredPane.setPreferredSize(new Dimension(dimesionsX, dimesionsY));
window.add(layeredPane, BorderLayout.CENTER);
myGraphic.setSize(layeredPane.getPreferredSize());
myGraphic.setLocation(0, 0);
layeredPane.add(myGraphic, JLayeredPane.DEFAULT_LAYER);
window.pack();
window.setVisible(true);
repaint();
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame();
frame.add(jLabelOnJButton());
frame.setSize(300, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
JLayeredPane layers = new JLayeredPane();
label.setBounds(40, 20, 100, 50);
button.setBounds(20, 20, 150, 75);
layers.add(label, new Integer(2));
layers.add(button, new Integer(1));
代码示例来源:origin: stackoverflow.com
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JComponent pane = new JLayeredPane();
pane.setPreferredSize(new Dimension(800, 600));
frame.setContentPane(pane);
panel1.setBackground(Color.BLUE);
panel1.setBounds(0, 0, 800, 600); // <<<---- Set Bounds
panel2.setBackground(Color.RED);
panel2.setBounds(50, 0, 700, 500); // <<---- Set Bounds
pane.add(panel1, new Integer(1));
pane.add(panel2, new Integer(2));
frame.pack();
frame.setVisible(true);
内容来源于网络,如有侵权,请联系作者删除!