本文整理汇总了Python中javax.swing.JLabel.setVerticalAlignment方法的典型用法代码示例。如果您正苦于以下问题:Python JLabel.setVerticalAlignment方法的具体用法?Python JLabel.setVerticalAlignment怎么用?Python JLabel.setVerticalAlignment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JLabel
的用法示例。
在下文中一共展示了JLabel.setVerticalAlignment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setVerticalAlignment [as 别名]
def __init__(self):
self.setAlwaysOnTop(False);
self.setSize(500, 500);
menubar = JMenuBar();
menu = JMenu("A Menu");
menu_ac = menu.getAccessibleContext();
menu_ac.setAccessibleDescription("The only menu in this program");
menuitem = JMenuItem("A Menu Item");
menu.add(menuitem);
menubar.add(menu);
self.setJMenuBar(menubar);
lbl = JLabel("A Label");
lbl.setHorizontalAlignment(JLabel.CENTER);
lbl.setVerticalAlignment(JLabel.CENTER);
self.setContentPane(lbl);
self.setVisible(True);
示例2: AlbumArt
# 需要导入模块: from javax.swing import JLabel [as 别名]
# 或者: from javax.swing.JLabel import setVerticalAlignment [as 别名]
class AlbumArt(SongContextView):
def __init__(self):
# set up the layout
self.__component = JPanel(GridBagLayout())
self.__image = JLabel()
self.__album = JLabel()
self.__artist = JLabel()
self.__application = None
self.__image.setVerticalAlignment(SwingConstants.TOP)
self.__album.setVerticalAlignment(SwingConstants.TOP)
self.__artist.setVerticalAlignment(SwingConstants.TOP)
gbc = GridBagConstraints()
gbc.fill = GridBagConstraints.VERTICAL
gbc.anchor = GridBagConstraints.NORTHWEST
gbc.gridx = 0
gbc.gridy = 0
gbc.weighty = 2
gbc.gridheight = 2
self.__component.add(self.__image, gbc)
gbc.fill = GridBagConstraints.HORIZONTAL
gbc.anchor = GridBagConstraints.NORTHWEST
gbc.gridx = 1
gbc.gridy = 0
gbc.gridheight = 1
gbc.weighty = 0
gbc.insets = Insets(0, 10, 0, 10)
self.__component.add(self.__album, gbc)
gbc.fill = GridBagConstraints.BOTH
gbc.anchor = GridBagConstraints.NORTHWEST
gbc.gridx = 1
gbc.gridy = 1
gbc.weightx = 2
gbc.weighty = 2
gbc.gridheight = 1
self.__component.add(self.__artist, gbc)
# Is called when this view should be updated.
def update(self, song):
# check for None!
if (song != None):
albumArt = song.getImage()
if (albumArt != None):
self.__image.setIcon(ImageIcon(ImageScaler.scale(albumArt, 300, 300)));
else:
self.__image.setIcon(None);
self.__album.setText("<html><font size='+3'>" + song.getAlbum() + "</font></html>");
self.__artist.setText("<html><font color='#555555' size='-1'>by " + song.getArtist() + "</font></html>");
else:
self.__image.setIcon(None);
self.__album.setText(None);
self.__artist.setText(None);
# Every SongContextView needs to be accompanied by a
# SongContextComponentShowHideAction.
# Return the action's id here.
def getShowHideActionId(self):
return "jython.albumart.showhide"
# The visual component to be shown in this view.
def getComponent(self):
return self.__component
def setApplication(self, application):
self.__application = application
def getApplication(self):
return self.__application
def getId(self):
return "jython.albumart"
def init(self):
pass
def shutdown(self):
pass