本文整理汇总了Python中javax.swing.JTable.setVisible方法的典型用法代码示例。如果您正苦于以下问题:Python JTable.setVisible方法的具体用法?Python JTable.setVisible怎么用?Python JTable.setVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.setVisible方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EmployeeDetails
# 需要导入模块: from javax.swing import JTable [as 别名]
# 或者: from javax.swing.JTable import setVisible [as 别名]
class EmployeeDetails(JPanel):
def __init__(self, employees, dateprovider):
JPanel.__init__(self, preferredSize=(400, 200))
layout = BoxLayout(self, BoxLayout.Y_AXIS)
self.setLayout(layout)
self._employees = employees
self._dateprovider = dateprovider
employees.add_change_listener(self)
self._create_status_label()
self._create_name_editor()
self._create_start_date_editor()
self._create_save_button()
self._create_vacation_display()
self._adding_employee = False
def _create_status_label(self):
self._status_label = JLabel(name="status_label", font=Font(Font.SANS_SERIF, Font.PLAIN, 11))
self.add(self._status_label)
self._add_with_padding(self._status_label, 5)
def _create_name_editor(self):
self.add(JLabel(text="Employee Name:"))
self._name_editor = FixedHeightTextField("name_input")
self._add_with_padding(self._name_editor, 5)
def _create_start_date_editor(self):
self.add(JLabel(text="Start Date (yyyy-mm-dd):"))
self._start_date_editor = FixedHeightTextField("start_input")
self._add_with_padding(self._start_date_editor, 5)
def _create_save_button(self):
self._save_button = JButton("Save", name="save_button", visible=False)
self._save_button.addActionListener(ListenerFactory(ActionListener, self._save_button_pushed))
self._add_with_padding(self._save_button, 5)
def _create_vacation_display(self):
self._display = JTable(name="vacation_display")
self._header = self._display.getTableHeader()
self.add(self._header)
self.add(self._display)
def _add_with_padding(self, component, padding):
self.add(component)
self.add(Box.createRigidArea(Dimension(0, padding)))
def show_employee(self, employee):
self._name_editor.setText(employee.name)
self._start_date_editor.setText(str(employee.startdate))
self._name_editor.setEditable(False)
self._start_date_editor.setEditable(False)
self._save_button.setVisible(False)
if self._adding_employee:
self._adding_employee = False
else:
self._status_label.setText("")
self._display.setVisible(True)
self._display.setModel(VacationTableModel(employee, self._dateprovider))
self._header.setVisible(True)
def edit_new_employee(self):
self._name_editor.setText("")
self._start_date_editor.setText("")
self._name_editor.setEditable(True)
self._start_date_editor.setEditable(True)
self._save_button.setVisible(True)
self._display.setVisible(False)
self._header.setVisible(False)
self._adding_employee = True
def _save_button_pushed(self, event):
self._employees.add(self._name_editor.getText(), self._start_date_editor.getText())
def employee_added(self, employee):
self._status_label.setForeground(Color.BLACK)
self._status_label.setText("Employee '%s' was added successfully." % employee.name)
self._save_button.setVisible(False)
def adding_employee_failed(self, reason):
self._status_label.setForeground(Color.RED)
self._status_label.setText(reason)