本文整理汇总了Python中javax.swing.JButton.setPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:Python JButton.setPreferredSize方法的具体用法?Python JButton.setPreferredSize怎么用?Python JButton.setPreferredSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JButton
的用法示例。
在下文中一共展示了JButton.setPreferredSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getScreenPanel
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import setPreferredSize [as 别名]
def getScreenPanel():
global mainScreen
global scrPanel
if not scrPanel:
mainScreen = JButton()
cursorImg = BufferedImage(16,16,BufferedImage.TYPE_INT_ARGB)
blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, Point(0,0), "blank cursor")
mainScreen.setCursor(blankCursor)
mainScreen.setPreferredSize(
Dimension(700, 700))
image = BufferedImage(700, 700, BufferedImage.TYPE_INT_ARGB)
g = image.createGraphics()
g.setColor(Color.BLACK)
g.fillRect(0, 0, 700, 700)
g.setColor(Color.WHITE)
g.setFont(Font("Serif", Font.BOLD, 20))
g.drawString("Move your mouse here to controlfocused device.", 50, 30)
mainScreenImg = image
mainScreen.setIcon(swing.ImageIcon(image))
mouseListener = ScrMouseListener()
mainScreen.addMouseListener(mouseListener)
mainScreen.addMouseMotionListener(mouseListener)
mainScreen.addMouseWheelListener(mouseListener)
mainScreen.setFocusable(True)
keyListener = ScrKeyListener()
mainScreen.addKeyListener(keyListener)
scrPanel = JPanel()
scrPanel.setLayout(BoxLayout(scrPanel, BoxLayout.Y_AXIS))
scrPanel.add(mainScreen)
scrPanel.setFocusable(True)
return scrPanel
示例2: NewZoneDialog
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import setPreferredSize [as 别名]
#.........这里部分代码省略.........
self.optionalTagTextField.setToolTipText("key=value")
boundaryTagsPanel.add(self.optionalTagTextField)
downloadBoundariesPane = JPanel()
downloadBoundariesPane.setAlignmentX(Component.LEFT_ALIGNMENT)
downloadBoundariesBtn = JButton(self.app.strings.getString("download_boundary"),
actionPerformed=self.on_downloadBoundariesBtn_clicked)
downloadBoundariesBtn.setToolTipText(self.app.strings.getString("download_boundary_tooltip"))
downloadBoundariesPane.add(downloadBoundariesBtn)
self.boundaryPanel.add(boundaryInfo)
self.boundaryPanel.add(Box.createRigidArea(Dimension(0, 15)))
self.boundaryPanel.add(boundaryTagsPanel)
self.boundaryPanel.add(Box.createRigidArea(Dimension(0, 10)))
self.boundaryPanel.add(downloadBoundariesPane)
self.editingPanels = {"rectangle": self.rectPanel,
"polygon": self.polygonPanel,
"boundary": self.boundaryPanel}
#Main buttons
self.okBtn = JButton(self.app.strings.getString("OK"),
ImageProvider.get("ok"),
actionPerformed=self.on_okBtn_clicked)
self.cancelBtn = JButton(self.app.strings.getString("cancel"),
ImageProvider.get("cancel"),
actionPerformed=self.close_dialog)
self.previewBtn = JButton(self.app.strings.getString("Preview_zone"),
actionPerformed=self.on_previewBtn_clicked)
self.previewBtn.setToolTipText(self.app.strings.getString("preview_zone_tooltip"))
okBtnSize = self.okBtn.getPreferredSize()
viewBtnSize = self.previewBtn.getPreferredSize()
viewBtnSize.height = okBtnSize.height
self.previewBtn.setPreferredSize(viewBtnSize)
#layout
self.add(info)
self.add(Box.createRigidArea(Dimension(0, 15)))
namePanel.setAlignmentX(Component.LEFT_ALIGNMENT)
self.add(namePanel)
self.add(Box.createRigidArea(Dimension(0, 15)))
countryPanel.setAlignmentX(Component.LEFT_ALIGNMENT)
self.add(countryPanel)
self.add(Box.createRigidArea(Dimension(0, 15)))
modeLbl.setAlignmentX(Component.LEFT_ALIGNMENT)
self.add(modeLbl)
self.add(Box.createRigidArea(Dimension(0, 5)))
self.add(self.modesComboBox)
self.modesComboBox.setAlignmentX(Component.LEFT_ALIGNMENT)
self.add(Box.createRigidArea(Dimension(0, 15)))
self.configPanel = JPanel(CardLayout())
self.configPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5))
self.configPanel.add(self.rectPanel, RECTPANEL)
self.configPanel.add(self.polygonPanel, POLYGONPANEL)
self.configPanel.add(self.boundaryPanel, BOUNDARYPANEL)
self.configPanel.setAlignmentX(Component.LEFT_ALIGNMENT)
self.add(self.configPanel)
buttonsPanel = JPanel()
buttonsPanel.add(self.okBtn)
buttonsPanel.add(self.cancelBtn)
buttonsPanel.add(self.previewBtn)