==[[Jython JFileChooser 1]]==
[[Jython Swing]] | [[Swing]] | [[Jython]] | [[Python]] |
===方針===
以下を参考に、Jythonでファイル選択を実装してみる以下を参考に、[[Jython]]でファイル選択を実装してみる
*http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html
buttonPanel.add(self.saveButton)
self.add(buttonPanel, BorderLayout.PAGE_STARTPAGE_STA[[R]]T) self.add(logScrollPane, BorderLayout.CENTERCENTE[[R]])
def createUI(self):
frame = [[JFrame]]("FileChooserDemo") frame.defaultCloseOperation = [[JFrame]].EXIT_ON_CLOSE
frame.add(self)
frame.pack()
frame.visible [[vi]]sible = True
class ButtonListener(ActionListener):
returnVal = self.target.fc.showOpenDialog(self.target)
if returnVal == JFileChooser.APPROVE_OPTIONAPP[[R]]OVE_OPTION:
file = self.target.fc.selectedFile
self.target.log.append("Opening: %s.\n" % file.name)
elif e.source is self.target.saveButton:
returnVal = self.target.fc.showSaveDialog(self.target);
if returnVal == JFileChooser.APPROVE_OPTIONAPP[[R]]OVE_OPTION:
file = self.target.fc.selectedFile
self.target.log.append("SavingSa[[vi]]ng: %s.\n" % file.getName())
else:
self.target.log.append("Save command cancelled by user.\n")
self.target.log.caretPosition = self.target.log.document.length
class Invoker(Runnable[[R]]unnable):
def run(self):
# [[Java ]] Look & Feel(Metal)のデフォルトでボールドフォントを使用しない
UIManager.put("swing.boldMetal", Boolean.FALSE)
sample = JFileChooserTest()
sample.createUI()
SwingUtilities[[Swing]]Utilities.invokeLater(Invoker())