本文整理匯總了Java中javax.swing.JPanel.setLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java JPanel.setLocation方法的具體用法?Java JPanel.setLocation怎麽用?Java JPanel.setLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JPanel
的用法示例。
在下文中一共展示了JPanel.setLocation方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createPanel
import javax.swing.JPanel; //導入方法依賴的package包/類
private static JPanel createPanel(Point location, boolean enabled) {
final JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setEnabled(enabled);
panel.setSize(new Dimension(200, 200));
panel.setLocation(location);
panel.setBorder(BorderFactory.createTitledBorder(
enabled ? "Enabled" : "Disabled"));
panel.setCursor(Cursor.getPredefinedCursor(
enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
return panel;
}
示例2: init
import javax.swing.JPanel; //導入方法依賴的package包/類
private static void init(JLayeredPane pane, int layer, int x, int y, int w, int h, Color color) {
JPanel panel = new JPanel();
panel.setBackground(color);
panel.setLocation(x, y);
panel.setSize(w, h);
pane.add(panel, new Integer(layer));
}
示例3: add
import javax.swing.JPanel; //導入方法依賴的package包/類
/**
* Adds a panel to show information
*
* @param panel The panel to add.
* @param internalTop The top position.
* @param internalHeight The enclosing height.
*/
private void add(JPanel panel, int internalTop, int internalHeight) {
panel.setVisible(false);
panel.setLocation((getWidth() - panel.getWidth()) / 2, internalTop
+ (internalHeight - panel.getHeight()) / 2);
add(panel);
}