@Override public void doLayout() { // Position transform and show source buttons buttonPanel.setLocation(cardXOffset, cardYOffset); buttonPanel.setSize(cardWidth, cardHeight); int x = cardWidth / 20; int y = cardHeight / 10; if (dayNightButton != null) { dayNightButton.setLocation(x, y); y += 25; y += 5; } if (showCopySourceButton != null) { showCopySourceButton.setLocation(x, y); } }
private JPanel clicked; @Override public void mouseClicked(MouseEvent e) { if (clicked != null) { clicked.setLocation(e.getX(), e.getY()); clicked = null; } else { // Figure out if any panel was clicked and assign // a reference to clicked } }
iconPanel.setLocation(realCardSize.x, realCardSize.y); iconPanel.setSize(realCardSize.width, realCardSize.height); counterPanel.setLocation(realCardSize.x, realCardSize.y); counterPanel.setSize(realCardSize.width, realCardSize.height); int size = cardWidth > WIDTH_LIMIT ? 40 : 20;
JPanel p = new JPanel(); p.setLayout(new GridLayout(2, 1)); p.add(new JLabel("Health : 90%")); p.add(new JLabel("Carrying weight : 4 Kg")); this.add(p); //JFrame p.setSize(100, 50); p.setLocation(100, 100); p.setVisible(true);
JPanel game = new JPanel(){ @Override public void paintComponent(Graphics g){ super.paintComponent(g); //custom painting here } }; //game.setLayout(null); don't use null layout game.setLocation(0,0); game.setSize(500,700); game.setBackground(Color.WHITE); game.setBorder(BorderFactory.createLineBorder(Color.black));
public void handleDrag(JPanel panel){ final JPanel p = panel; panel.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent me) { me.translatePoint(me.getComponent().getLocation().x, me.getComponent().getLocation().y); p.setLocation(me.getX(), me.getY()); } }); }
@Override public void layoutContainer(Container parent) { super.layoutContainer(parent); innerPanel.setLocation(0, (int) (parent.getHeight() - separator.getPreferredSize().getHeight()) / 2); } });
private void addComponents() { axesPanel = new GraphAxes(); curvePanel = new GraphCurve(); eventPanel = new JPanel(); curvePanel.setLocation(x_offset_left + 1, y_offset_top); eventPanel.setLocation(x_offset_left + 1, 0); eventPanel.setLayout(null); add(axesPanel); axesPanel.add(curvePanel); axesPanel.add(eventPanel); }
@ScriptFunction @Override public void setLeft(int aValue) { if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) { MarginLayout.ajustLeft(this, aValue); } super.setLocation(aValue, getTop()); }
@ScriptFunction @Override public void setLeft(int aValue) { if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) { MarginLayout.ajustLeft(this, aValue); } super.setLocation(aValue, getTop()); }
@ScriptFunction @Override public void setLeft(int aValue) { if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) { MarginLayout.ajustLeft(this, aValue); } super.setLocation(aValue, getTop()); }
@ScriptFunction @Override public void setTop(int aValue) { if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) { MarginLayout.ajustTop(this, aValue); } super.setLocation(getLeft(), aValue); }
@ScriptFunction @Override public void setTop(int aValue) { if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) { MarginLayout.ajustTop(this, aValue); } super.setLocation(getLeft(), aValue); }
@ScriptFunction @Override public void setLeft(int aValue) { if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) { MarginLayout.ajustLeft(this, aValue); } super.setLocation(aValue, getTop()); }
@ScriptFunction @Override public void setLeft(int aValue) { if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) { MarginLayout.ajustLeft(this, aValue); } super.setLocation(aValue, getTop()); }
@ScriptFunction @Override public void setTop(int aValue) { if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) { MarginLayout.ajustTop(this, aValue); } super.setLocation(getLeft(), aValue); }
@ScriptFunction @Override public void setTop(int aValue) { if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) { MarginLayout.ajustTop(this, aValue); } super.setLocation(getLeft(), aValue); }
@ScriptFunction @Override public void setTop(int aValue) { if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) { MarginLayout.ajustTop(this, aValue); } super.setLocation(getLeft(), aValue); }
@ScriptFunction @Override public void setLeft(int aValue) { if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) { MarginLayout.ajustLeft(this, aValue); } super.setLocation(aValue, getTop()); }
private void show() { frame.getLayeredPane().add(backgroundPanel, JLayeredPane.PALETTE_LAYER); imagePanel.setLocation(((frame.getLayeredPane().getWidth() - imagePanel.getWidth()) / 2), (frame.getLayeredPane().getHeight() - imagePanel.getHeight()) / 2); frame.getLayeredPane().add(imagePanel, JLayeredPane.POPUP_LAYER); }