本文整理汇总了Python中javax.swing.JFrame.setSize方法的典型用法代码示例。如果您正苦于以下问题:Python JFrame.setSize方法的具体用法?Python JFrame.setSize怎么用?Python JFrame.setSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JFrame
的用法示例。
在下文中一共展示了JFrame.setSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: desty
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setSize [as 别名]
class myAnimFrame:
"""
Supporting class for animations.
"""
def desty(self, event):
self.display.destroy()
self.frame.dispose()
def __init__(self, display, widget, width, height, title):
from javax.swing import JFrame, JPanel
from java.awt import BorderLayout, FlowLayout
self.display = display
self.panel = JPanel(BorderLayout())
self.panel2 = JPanel(FlowLayout())
self.panel2.add(widget)
self.panel.add("North", self.panel2)
self.panel.add("Center",self.display.getComponent())
self.frame = JFrame(title, windowClosing=self.desty)
self.pane = self.frame.getContentPane()
self.pane.add(self.panel)
self.frame.setSize(width,height)
self.frame.pack()
self.frame.show()
示例2: test_swing
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setSize [as 别名]
def test_swing():
frame = JFrame("Hello Jython")
button = JButton("Pulsar", actionPerformed = hello)
frame.add(button)
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
frame.setSize(200, 100)
frame.show()
示例3: tree
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setSize [as 别名]
def tree():
"""
tree(xmlfile="dsm2.xml")
creates a tree view on a given xml file of dsm2 input data
"""
tv = TreeViewer()
mp2 = JPanel()
mp2.setLayout(BorderLayout())
tf = JTextField("dsm2.inp")
pb = JButton("parse")
mp2.add(tf,BorderLayout.CENTER)
mp2.add(pb,BorderLayout.EAST)
class ParseListener(ActionListener):
def __init__(self,tf,tv,fr):
self.tf = tf
self.tv = tv
self.fr = fr
def actionPerformed(self,evt):
dsm2file = self.tf.getText()
parser = DSM2Parser(dsm2file)
self.tv.xdoc = parser.dsm2_data.toXml()
self.fr.getContentPane().add(self.tv.gui(),BorderLayout.CENTER)
self.fr.pack()
self.fr.setVisible(1)
fr = JFrame()
fr.setTitle("DSM2Tree")
fr.setLocation(100,100)
fr.setSize(600,60)
fr.getContentPane().setLayout(BorderLayout())
fr.getContentPane().add(mp2,BorderLayout.NORTH)
al = ParseListener(tf,tv,fr)
pb.addActionListener(al)
fr.pack()
fr.setVisible(1)
示例4: run_fn
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setSize [as 别名]
def run_fn(event):
log_window = JFrame('Galahad Log')
log_text_area = JTextArea()
log_text_area.editable = False
log_window.setSize(400, 500)
log_window.add(log_text_area)
log_window.show()
log_text_area.append('sdfsdfsdfsdfsd %d' % 3)
示例5: ApplicationTestCase
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setSize [as 别名]
class ApplicationTestCase(unittest.TestCase):
def setUp(self):
Robot().mouseMove(800, 600)
self.launch_app()
self.app = ApplicationTestApp()
def tearDown(self):
self.frame.setVisible(False)
self.frame.dispose()
def launch_app(self):
self.frame = JFrame("Test Window", defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
pane = self.frame.getContentPane()
layout = SpringLayout()
pane.setLayout(layout)
label = JLabel("Test Label")
pane.add(label)
layout.putConstraint(SpringLayout.WEST, label, 20, SpringLayout.WEST, pane)
layout.putConstraint(SpringLayout.NORTH, label, 20, SpringLayout.NORTH, pane)
self.frame.pack()
self.frame.setVisible(True)
self.frame.setSize(800, 600)
def test_init_window(self):
window = self.app.init_window(ApplicationTestWindow)
self.assertNotEqual(window, None)
self.assertTrue(isinstance(window, ApplicationTestWindow))
self.assertEqual((window.region.getW(), window.region.getH()), (800, 600))
def test_create_image_folders(self):
path = os.path.join('images', 'application_test_window', 'test_label')
shutil.move(os.path.join(path, 'enabled.png'), os.path.join('images', '.enabled.png.tmp'))
shutil.rmtree(os.path.join('images', 'application_test_window'))
self.app.create_image_folders()
self.assertTrue(os.path.exists(path))
shutil.move(os.path.join('images', '.enabled.png.tmp'), os.path.join(path, 'enabled.png'))
# TODO: test_capture_screenshots
# TODO: test_open
def test_find_focused_window(self):
window = self.app.find_focused_window()
self.assertNotEqual(window, None)
self.assertTrue(isinstance(window, ApplicationTestWindow))
def test_focused_window(self):
before_time = time.time()
window = self.app.focused_window(10)
after_time = time.time()
self.assertTrue(after_time >= before_time + 10)
self.assertNotEqual(window, None)
self.assertTrue(isinstance(window, ApplicationTestWindow))
示例6: show_plot_in_frame
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setSize [as 别名]
def show_plot_in_frame(mainPanel):
"""
embeds panel containing plots in a closable frame
clears the panel background to white
"""
fr=JFrame()
fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
fr.getContentPane().add(mainPanel)
fr.setSize(1100,850);
mainPanel.setSize(1100,850);
mainPanel.setBackground(Color.WHITE);
fr.show();
return fr
示例7: install
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setSize [as 别名]
def install(helper):
print('install called');
frame = JFrame("Please Input Values")
frame.setLocation(100,100)
frame.setSize(500,400)
frame.setLayout(None)
lbl1 = JLabel("Input1: ")
lbl1.setBounds(60,20,60,20)
txt1 = JTextField(100)
txt1.setBounds(130,20,200,20)
lbl2 = JLabel("Input2: ")
lbl2.setBounds(60,50,100,20)
txt2 = JTextField(100)
txt2.setBounds(130,50,200,20)
lbl3 = JLabel("Input3: ")
lbl3.setBounds(60,80,140,20)
txt3 = JTextField(100)
txt3.setBounds(130,80,200,20)
lbl4 = JLabel("Input4: ")
lbl4.setBounds(60,110,180,20)
txt4 = JTextField(100)
txt4.setBounds(130,110,200,20)
def getValues(event):
print "clicked"
ScriptVars.setGlobalVar("Input1",str(txt1.getText()))
print(ScriptVars.getGlobalVar("Input1"))
ScriptVars.setGlobalVar("Input2",str(txt2.getText()))
print(ScriptVars.getGlobalVar("Input2"))
ScriptVars.setGlobalVar("Input3",str(txt3.getText()))
print(ScriptVars.getGlobalVar("Input3"))
ScriptVars.setGlobalVar("Input4",str(txt4.getText()))
print(ScriptVars.getGlobalVar("Input4"))
btn = JButton("Submit", actionPerformed = getValues)
btn.setBounds(160,150,100,20)
frame.add(lbl1)
frame.add(txt1)
frame.add(lbl2)
frame.add(txt2)
frame.add(btn)
frame.add(lbl3)
frame.add(txt3)
frame.add(lbl4)
frame.add(txt4)
frame.setVisible(True)
示例8: __init__
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setSize [as 别名]
class ShowImageViewer:
def __init__(self):
self.frame = JFrame("Display Image")
btn = JButton("Switch",actionPerformed=self.switchPic)
#self.frame.getContentPane().add(btn)
self.switchPic('/home/jack/Desktop/mgarvin.jpg')
self.frame.setSize(500,500)
self.frame.setVisible(True)
def callSwitchPic(self,event):
self.switchPic('/home/jack/Desktop/mteam.jpg')
def switchPic(self,image):
panel = ShowImage(image)
self.frame.getContentPane().add(panel)
示例9: geom_viewer
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setSize [as 别名]
def geom_viewer(dsm2file = "dsm2.inp"):
"""
geom_viewer(dsm2file = "dsm2.inp")
starts off a dsm2 geometry viewer for dsm2 input data
Irregular xsections are plotted if available otherwise
regular xsections are plotted.
"""
dgv = DSM2GeomViewer(dsm2file)
mp = dgv.gui()
fr = JFrame()
fr.setTitle('Geom Viewer')
fr.getContentPane().add(mp)
fr.setLocation(300,100)
fr.pack()
sz = fr.getSize()
fr.setSize(250,sz.height)
fr.setVisible(1)
示例10: _open
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setSize [as 别名]
def _open():
frame = JFrame('Galahad',
defaultCloseOperation=WindowConstants.EXIT_ON_CLOSE)
panel = JPanel(GridLayout(5, 2))
frame.add(panel)
chosen_values = {}
def create_file_choice_button(name, label_text):
button = JButton('Click to select')
label = JLabel(label_text)
file_chooser = JFileChooser()
def choose_file(event):
user_did_choose_file = (file_chooser.showOpenDialog(frame) ==
JFileChooser.APPROVE_OPTION)
if user_did_choose_file:
file_ = file_chooser.getSelectedFile();
button.text = chosen_values[name] = str(file_)
button.actionPerformed = choose_file
panel.add(label)
panel.add(button)
create_file_choice_button('binary', 'Binary archive:')
create_file_choice_button('source', 'Source archive:')
create_file_choice_button('output_dir', 'Output directory:')
panel.add(JLabel(''))
panel.add(JLabel(''))
def run_fn(event):
log_window = JFrame('Galahad Log')
log_text_area = JTextArea()
log_text_area.editable = False
log_window.setSize(400, 500)
log_window.add(log_text_area)
log_window.show()
log_text_area.append('sdfsdfsdfsdfsd %d' % 3)
panel.add(JButton('Run analysis', actionPerformed=run_fn))
panel.add(JButton('Quit', actionPerformed=lambda e: sys.exit(0)))
frame.setSize(300, 160)
frame.visible = True
示例11: createAndShowGUI
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setSize [as 别名]
def createAndShowGUI():
# Create the GUI and show it. As with all GUI code, this must run
# on the event-dispatching thread.
frame = JFrame("GUI Development ")
frame.setSize(500, 600)
frame.setLayout(BorderLayout())
splitPane = JSplitPane(JSplitPane.VERTICAL_SPLIT)
#Create and set up the content pane.
psimures= ResourcePanel()
psimures.setOpaque(True)
pconfig = ConfigurationPanel()
pconfig.setOpaque(True) #content panes must be opaque
# show the GUI
splitPane.add(psimures)
splitPane.add(pconfig)
frame.add(splitPane)
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
frame.setVisible(True)
示例12: createAndShowGUI
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setSize [as 别名]
def createAndShowGUI():
# Create the GUI and show it. As with all GUI code, this must run
# on the event-dispatching thread.
frame = JFrame("MAE ")
frame.setSize(1024, 768)
panel= JPanel()
panel.setLayout(GridBagLayout())
#Create and set up the content pane.
psimures= SimoutPanel()
psimures.setOpaque(True)
c = GridBagConstraints()
c.fill = GridBagConstraints.HORIZONTAL
c.weightx = 1
c.gridx = 0
c.gridy = 0
panel.add(psimures, c);
pmeasure= MeasPanel()
pmeasure.setOpaque(True)
c = GridBagConstraints()
c.fill = GridBagConstraints.HORIZONTAL
c.weightx = 1
c.gridx = 0
c.gridy = 1
panel.add(pmeasure, c);
preport = ReportPanel()
preport.setOpaque(True)
c = GridBagConstraints()
c.fill = GridBagConstraints.VERTICAL
c.weighty = 1
c.gridx = 1
c.gridy = 0
c.gridheight= 2
panel.add(preport,c)
# show the GUI
frame.add(panel)
# frame.add(pmeasure)
# frame.add(preport)
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
frame.setVisible(True)
示例13: __init__
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setSize [as 别名]
def __init__(self):
frame = JFrame("Jython JTable Example")
frame.setSize(500, 250)
frame.setLayout(BorderLayout())
self.tableData = [
['Mouse 1', eventNames[0], eventScriptType[0]],
['Mouse 2', eventNames[1] , eventScriptType[1]],
['Mouse 3', eventNames[2], eventScriptType[2]],
['Mouse 1 Shift', eventNames[3], eventScriptType[3]],
['Mouse 2 Shift',eventNames[4], eventScriptType[4]],
['Mouse 3 Shift',eventNames[5], eventScriptType[5]],
['Mouse 1 Control',eventNames[6], eventScriptType[6]],
['Mouse 2 Control',eventNames[7], eventScriptType[7]],
['Mouse 3 Control',eventNames[8], eventScriptType[8]],
]
colNames = ('Script/Event','Name','Type')
dataModel = DefaultTableModel(self.tableData, colNames)
self.table = JTable(dataModel)
scrollPane = JScrollPane()
scrollPane.setPreferredSize(Dimension(400,200))
scrollPane.getViewport().setView((self.table))
panel = JPanel()
panel.add(scrollPane)
frame.add(panel, BorderLayout.CENTER)
self.label = JLabel('Hello from Jython')
frame.add(self.label, BorderLayout.NORTH)
button = JButton('Save Settings',actionPerformed=self.setText)
frame.add(button, BorderLayout.SOUTH)
exitButton = JButton('Exit',actionPerformed=self.myExit)
frame.add(exitButton, BorderLayout.EAST)
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
frame.setVisible(True)
示例14: main
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setSize [as 别名]
def main(args):
_WIDTH = 300
_HEIGHT = 300
fps = 20#frames per second
bgColor = Color.white
frame = JFrame("Graphics!")
frame.setBackground(bgColor);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
drawgraphics = DrawGraphics()
content = Animator(drawgraphics, _WIDTH, _HEIGHT, fps)
content.setBackground(bgColor)
content.setSize(_WIDTH, _HEIGHT)
content.setMinimumSize(Dimension(_WIDTH, _HEIGHT))
content.setPreferredSize(Dimension(_WIDTH, _HEIGHT))
frame.setSize(_WIDTH, _HEIGHT)
frame.setContentPane(content)
frame.setResizable(True)
frame.pack()
Thread(content).start()
frame.setVisible(True)
示例15: __init__
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import setSize [as 别名]
def __init__(self):
self.panel = JPanel()
self.panel.setLayout(BorderLayout())
frame = JFrame("GUI Development ")
frame.setSize(800, 600)
frame.setLayout(BorderLayout())
splitPane = JSplitPane(JSplitPane.VERTICAL_SPLIT);
self.textfield1 = JTextField('Type something here')
self.textfield1.setColumns(40);
#self.textfield1.setRows(5);
#self.textfield2 = JTextField('Dont write anythong',30)
label1 = JLabel("Command:")
panel1 = JPanel()
'''
'''
jMenuBar1 = JMenuBar()
jMenu1 = JMenu()
jMenu2 = JMenu()
jMenuItem1 = JMenuItem('Open', actionPerformed=self.onClick)
jMenuItem2 = JMenuItem()
jMenu1.setText('File')
jMenu2.setText('Simulation')
#jMenuItem1.setText('Open')
jMenuItem2.setText('Exit')
jMenu1.add(jMenuItem1)
jMenu1.add(jMenuItem2)
jMenuBar1.add(jMenu1)
jMenuItem21 = JMenuItem('Simulation Options',actionPerformed=self.writeText)
jMenuItem22 = JMenuItem('Simulate',actionPerformed=self.writeText)
jMenuItem23 = JMenuItem('Generate FMU',actionPerformed=self.writeText)
# jMenuItem21.setText('Run Project')
# jMenuItem22.setText('Generate FMU')
jMenu2.add(jMenuItem21)
jMenu2.add(jMenuItem22)
jMenu2.add(jMenuItem23)
jMenuBar1.add(jMenu2)
frame.setJMenuBar(jMenuBar1)
'''
'''
panel1.add(label1,BorderLayout.WEST)
panel1.add(self.textfield1, BorderLayout.CENTER)
copyButton = JButton('send',actionPerformed=self.copyText)
panel1.add(copyButton, BorderLayout.EAST)
#panel1.add(self.textfield2, BorderLayout.SOUTH)
splitPane.setLeftComponent(panel1);
'''
image adding in the frame
'''
#imPanel.add(imPanel,BorderLayout.WEST)
#imPanel.setBackground(Color(66, 66, 66))
imPanel1 = JPanel()
rot = ImageIcon("ballon.jpg")
rotLabel = JLabel(rot)
rotLabel.setBounds(0,0, rot.getIconWidth(), rot.getIconHeight())
imPanel1.add(rotLabel, BorderLayout.SOUTH)
frame.add(imPanel1, BorderLayout.SOUTH)
'''
panel for text area adding in split pan
'''
tabPane = JTabbedPane(JTabbedPane.TOP)
label = JLabel("<html><br>This is a tab1</html>")
panel1 = JPanel()
panel1.setBackground(Color.lightGray)
panel23 = JPanel()
panel23.setBackground(Color.black)
panel1.add(panel23,BorderLayout.SOUTH)
panel1.add(label,BorderLayout.NORTH)
'''
adding button in the panel1
'''
writeButton = JButton('write')
panel1.add(writeButton, BorderLayout.WEST)
tabPane.addTab("tab1", panel1)
#frame.add(panel1,BorderLayout.EAST)
#panel1.setBackground(Color(66, 66, 66))
# rot1 = ImageIcon("ballon.jpg",BorderLayout.SOUTH)
# rotLabel1 = JLabel(rot1)
# rotLabel1.setBounds(0,0, rot.getIconWidth(), rot.getIconHeight())
# panel1.add(rotLabel1)
label2 = JLabel("This is a tab2")
panel2 = JPanel()
panel2.setBackground(Color.lightGray)
panel2.add(label2)
#.........这里部分代码省略.........