List of usage examples for javax.swing JButton setMargin
@BeanProperty(visualUpdate = true, description = "The space between the button's border and the label.") public void setMargin(Insets m)
From source file:au.org.ala.delta.intkey.Intkey.java
@Override public void addToolbarButton(boolean advancedModeOnly, boolean normalModeOnly, boolean inactiveUnlessUsedCharacters, String imageFileName, List<String> commands, String shortHelp, String fullHelp) {/* w w w . j av a 2 s. c om*/ Icon icon = null; // Is the image file an absolute file? File iconFile = new File(imageFileName); if (iconFile.exists() && iconFile.isAbsolute()) { try { icon = readImageIconFromFile(iconFile); } catch (IOException ex) { displayErrorMessage(UIUtils.getResourceString("ErrorReadingIconImageFromFile.error", iconFile.getAbsolutePath())); } } // Is the image file relative to the dataset directory? if (icon == null) { File relativeIconFile = new File(_context.getDatasetDirectory(), imageFileName); if (relativeIconFile.exists() && relativeIconFile.isAbsolute()) { try { icon = readImageIconFromFile(relativeIconFile); } catch (IOException ex) { displayErrorMessage(UIUtils.getResourceString("ErrorReadingIconImageFromFile.error", iconFile.getAbsolutePath())); } } } // try getting an icon with the exact image name from the icon resources if (icon == null) { try { icon = IconHelper.createImageIconFromAbsolutePath(INTKEY_ICON_PATH + "/" + imageFileName); } catch (Exception ex) { // do nothing } } if (icon == null && imageFileName.toLowerCase().endsWith(".bmp")) { // try substituting ".bmp" for ".png" and reading from the icon // resources. All the default // icons that come with Intkey have been convert to png format. String modifiedImageFileName = imageFileName.replaceFirst(".bmp$", ".png"); try { icon = IconHelper.createImageIconFromAbsolutePath(INTKEY_ICON_PATH + "/" + modifiedImageFileName); } catch (Exception ex) { // do nothing } } if (icon == null) { displayErrorMessage(UIUtils.getResourceString("CouldNotFromImage.error", imageFileName)); return; } JButton button = new JButton(icon); button.setToolTipText(shortHelp); button.setMargin(new Insets(0, 0, 0, 0)); _pnlDynamicButtons.add(button); final List<String> commandsCopy = new ArrayList<String>(commands); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (String command : commandsCopy) { _context.parseAndExecuteDirective(command); } } }); if (advancedModeOnly && !normalModeOnly) { _advancedModeOnlyDynamicButtons.add(button); } if (normalModeOnly && !advancedModeOnly) { _normalModeOnlyDynamicButtons.add(button); } if (inactiveUnlessUsedCharacters) { _activeOnlyWhenCharactersUsedButtons.add(button); } _dynamicButtonsFullHelp.put(button, fullHelp); updateDynamicButtons(); }
From source file:com.lynk.hrm.ui.dialog.InfoEmployee.java
private void initComponents() { addWindowListener(new WindowAdapter() { @Override/*from w w w. j a v a 2 s.c o m*/ public void windowClosing(WindowEvent e) { thisWindowClosing(e); } }); setSize(836, 674); setTitle(""); setIconImage( Toolkit.getDefaultToolkit().getImage(InfoEmployee.class.getResource("/resource/image/icon.png"))); setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); getContentPane().setLayout(new BorderLayout(0, 0)); { JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); getContentPane().add(toolBar, BorderLayout.NORTH); { JButton uiSave = new JButton("?"); uiSave.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiSaveActionPerformed(true); } }); uiSave.setFocusable(false); uiSave.setIcon(new ImageIcon(InfoEmployee.class.getResource("/resource/image/emp_save.png"))); uiSave.setFont(APP_FONT); toolBar.add(uiSave); } toolBar.addSeparator(); { JButton uiReadIdCard = new JButton("??"); uiReadIdCard.setFont(APP_FONT); uiReadIdCard.setIcon( new ImageIcon(InfoEmployee.class.getResource("/resource/image/manager_teacher.png"))); uiReadIdCard.setFocusable(false); uiReadIdCard.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiReadIdCardActionPerformed(e); } }); toolBar.add(uiReadIdCard); } toolBar.addSeparator(); { JButton uiInputFinger = new JButton(""); uiInputFinger.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiInputFingerActionPerformed(e); } }); uiInputFinger.setIcon(new ImageIcon(InfoEmployee.class.getResource("/resource/image/finger.png"))); uiInputFinger.setFont(APP_FONT); uiInputFinger.setFocusable(false); toolBar.add(uiInputFinger); } toolBar.addSeparator(); { JButton uiSetSuspend = new JButton("??"); uiSetSuspend.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiSetSuspendActionPerformed(e); } }); uiSetSuspend .setIcon(new ImageIcon(InfoEmployee.class.getResource("/resource/image/emp_retire.png"))); uiSetSuspend.setFont(APP_FONT); uiSetSuspend.setFocusable(false); toolBar.add(uiSetSuspend); } } { JPanel panel = new JPanel(); getContentPane().add(panel); panel.setLayout(new MigLayout("", "[]5[grow]25[]5[grow]25[]5[grow]5[102]", "[][][][]")); { JLabel label = new JLabel("?"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); panel.add(label, "cell 0 0"); } { uiId = new LynkTextField(); uiId.setEditable(false); uiId.setForeground(Color.BLUE); panel.add(uiId, "cell 1 0,growx"); } { JLabel label = new JLabel("??"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); panel.add(label, "cell 2 0"); } { uiName = new LynkTextField(); uiName.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { uiNameFocusLost(e); } }); panel.add(uiName, "cell 3 0,growx"); } { JLabel label = new JLabel("?"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); panel.add(label, "cell 4 0"); } { uiNamePy = new LynkTextField(); panel.add(uiNamePy, "cell 5 0,growx"); } { JLabel label = new JLabel("?"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); panel.add(label, "cell 0 1"); } { uiState = new JComboBox<String>(); uiState.setForeground(Color.BLUE); uiState.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiStateActionPerformed(e); } }); uiState.setModel(new DefaultComboBoxModel<String>(new String[] { "", Employee.STATE_PROBATION, Employee.STATE_CONTRACT, Employee.STATE_SUSPEND, Employee.STATE_LEAVE, Employee.STATE_RETIRE, Employee.STATE_DELETE })); uiState.setFont(APP_FONT); panel.add(uiState, "cell 1 1,growx"); } { uiInfoTab = new JideTabbedPane(JTabbedPane.TOP); uiInfoTab.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { uiInfoTabStateChanged(e); } }); uiInfoTab.setColorTheme(JideTabbedPane.COLOR_THEME_DEFAULT); uiInfoTab.setFont(APP_FONT); panel.add(uiInfoTab, "cell 0 3 7 1"); { JPanel uiInfoBasic = new JPanel(); uiInfoBasic.setLayout(new MigLayout("", "[473px,grow][307px,grow]", "[grow][289px][149px]")); uiInfoTab.addTab("?", uiInfoBasic); { JPanel uiIdCardPane = new JPanel(); uiIdCardPane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); uiIdCardPane.setLayout(new MigLayout("", "[]5[grow]10[]", "[][][][][40px:40px:40px,grow]")); uiInfoBasic.add(uiIdCardPane, "cell 0 0,grow"); { JLabel label = new JLabel("??"); uiIdCardPane.add(label, "cell 0 0"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiIdCard = new LynkTextField(); uiIdCardPane.add(uiIdCard, "cell 1 0,growx"); } { JPanel pane = new JPanel(); uiIdCardPane.add(pane, "cell 2 0 1 5,grow"); pane.setLayout(new MigLayout("insets 0", "[102px:102px:102px]", "[126px:126px:126px]")); { uiPhoto = new ImagePane(); pane.add(uiPhoto, "cell 0 0,grow"); } } // { // JPanel photoPane = new JPanel(); // photoPane.setLayout(new MigLayout("insets 0", "[grow]", "[grow][]")); // uiIdCardPane.add(photoPane, "cell 2 0 2 4,grow"); // { // uiPhoto = new ImagePane(); // photoPane.add(uiPhoto, "cell 0 0,grow"); // } // { // JButton uiReadIdCardDirect = new JButton("??"); // uiReadIdCardDirect.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) { // uiReadIdCardDirectActionPerformed(e); // } // }); // uiReadIdCardDirect.setFont(APP_FONT); // uiReadIdCardDirect.setFocusable(false); // photoPane.add(uiReadIdCardDirect, "cell 0 1,grow"); // } // } { JLabel label = new JLabel(""); uiIdCardPane.add(label, "cell 0 1"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiBirthday = new LynkTextField(); uiIdCardPane.add(uiBirthday, "cell 1 1,growx"); } { JLabel label = new JLabel(""); uiIdCardPane.add(label, "cell 0 2"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiAge = new LynkTextField(); uiIdCardPane.add(uiAge, "cell 1 2,growx"); } { JLabel label = new JLabel(""); uiIdCardPane.add(label, "cell 0 3,aligny top"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiGender = new LynkTextField(); uiIdCardPane.add(uiGender, "cell 1 3,growx,aligny top"); } { JLabel label = new JLabel("??"); label.setFont(APP_FONT); label.setHorizontalAlignment(SwingConstants.RIGHT); uiIdCardPane.add(label, "cell 0 4"); } { JScrollPane scrollPane = new JScrollPane(); uiIdCardPane.add(scrollPane, "cell 1 4,grow"); { uiCensusAddress = new JTextArea(); uiCensusAddress.setWrapStyleWord(true); uiCensusAddress.setLineWrap(true); scrollPane.setViewportView(uiCensusAddress); uiCensusAddress.setFont(APP_FONT); } } } { JPanel uiIdCardPane = new JPanel(); uiIdCardPane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); uiIdCardPane .setLayout(new MigLayout("", "[]5[grow]25[]5[grow]", "[][][40px:40px:40px,grow]")); uiInfoBasic.add(uiIdCardPane, "cell 0 1,grow"); { JLabel label = new JLabel(""); uiIdCardPane.add(label, "cell 0 0"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiMarital = new JComboBox<String>(); uiIdCardPane.add(uiMarital, "cell 1 0,growx"); uiMarital.setModel(new DefaultComboBoxModel<String>( new String[] { Employee.MARITAL_YES, Employee.MARITAL_NO })); uiMarital.setFont(APP_FONT); } { JLabel label = new JLabel("?"); uiIdCardPane.add(label, "cell 2 0"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiContact = new LynkTextField(); uiIdCardPane.add(uiContact, "cell 3 0,growx"); } { JLabel label = new JLabel("?"); uiIdCardPane.add(label, "cell 0 1"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiCensus = new JComboBox<String>(); uiIdCardPane.add(uiCensus, "cell 1 1,growx"); uiCensus.setModel(new DefaultComboBoxModel<String>( new String[] { Employee.CENSUS_A, Employee.CENSUS_B, Employee.CENSUS_C, Employee.CENSUS_D, Employee.CENSUS_E, Employee.CENSUS_F })); uiCensus.setFont(APP_FONT); } { JLabel label = new JLabel("??"); uiIdCardPane.add(label, "cell 2 1"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiResidencePermit = new JComboBox<String>(); uiIdCardPane.add(uiResidencePermit, "cell 3 1,growx"); uiResidencePermit .setModel(new DefaultComboBoxModel<String>(new String[] { "", "", "" })); uiResidencePermit.setFont(APP_FONT); } { JLabel label = new JLabel(""); uiIdCardPane.add(label, "cell 0 2"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { JScrollPane scrollPane = new JScrollPane(); uiIdCardPane.add(scrollPane, "cell 1 2 3 1,grow"); { uiAddress = new JTextArea(); uiAddress.setWrapStyleWord(true); uiAddress.setLineWrap(true); scrollPane.setViewportView(uiAddress); uiAddress.setFont(APP_FONT); } } } { JPanel uiCompanyPanel = new JPanel(); uiCompanyPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); uiCompanyPanel.setLayout(new MigLayout("", "[]5[grow][]25[]5[grow][]", "[][][][][][][][]")); uiInfoBasic.add(uiCompanyPanel, "cell 0 2,growx,aligny top"); { JLabel label = new JLabel(Employee.SUSPEND_NOTE); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); uiCompanyPanel.add(label, "cell 0 0"); } { uiFactory = new JComboBox<String>(new DefaultComboBoxModel<String>( new String[] { Employee.FACROTY_TC, Employee.FACTORY_SX })); uiFactory.setFont(APP_FONT); uiCompanyPanel.add(uiFactory, "cell 1 0 2 1,growx"); } { JLabel label = new JLabel(""); uiCompanyPanel.add(label, "cell 3 0"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiDept = new LynkTextField(); uiDept.setEditable(false); uiCompanyPanel.add(uiDept, "cell 4 0,growx"); } { JButton uiChooseDept = new JButton(); uiChooseDept.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiChooseDeptActionPerformed(e); } }); uiChooseDept.setIcon(new ImageIcon( InfoEmployee.class.getResource("/resource/image/choose_more.png"))); uiChooseDept.setMargin(new Insets(1, 1, 1, 1)); uiCompanyPanel.add(uiChooseDept, "cell 5 0,growx"); } { JLabel label = new JLabel("?"); uiCompanyPanel.add(label, "cell 0 1"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiJob = new LynkTextField(); uiJob.setEditable(false); uiCompanyPanel.add(uiJob, "cell 1 1,growx"); } { JButton uiChooseJob = new JButton(); uiChooseJob.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiChooseJobActionPerformed(e); } }); uiChooseJob.setIcon(new ImageIcon( InfoEmployee.class.getResource("/resource/image/choose_more.png"))); uiChooseJob.setMargin(new Insets(1, 1, 1, 1)); uiCompanyPanel.add(uiChooseJob, "cell 2 1,growx"); } { JLabel label = new JLabel(Employee.SUSPEND_START); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); uiCompanyPanel.add(label, "cell 3 1"); } { uiDdg = new JComboBox<String>( new DefaultComboBoxModel<>(new String[] { Employee.DDG_N, Employee.DDG_Y })); uiDdg.setFont(APP_FONT); uiCompanyPanel.add(uiDdg, "cell 4 1 2 1,growx"); } { JLabel label = new JLabel(""); uiCompanyPanel.add(label, "cell 0 2"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiEntryDate = new JDateChooser(); uiCompanyPanel.add(uiEntryDate, "cell 1 2 2 1,growx"); uiEntryDate.setDateFormatString("yyyy-MM-dd"); uiEntryDate.setFont(APP_FONT); uiEntryDate.getJCalendar().setTodayButtonVisible(true); uiEntryDate.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if ("date".equals(evt.getPropertyName())) { setWorkAge(); } } }); } { JLabel label = new JLabel(""); uiCompanyPanel.add(label, "cell 3 2"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiWorkAge = new LynkTextField("0"); uiCompanyPanel.add(uiWorkAge, "cell 4 2 2 1,growx"); uiWorkAge.setEditable(false); } { JLabel label = new JLabel("?"); uiCompanyPanel.add(label, "cell 0 3"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiProbation = new JDateChooser(); uiCompanyPanel.add(uiProbation, "cell 1 3 2 1,growx"); uiProbation.setDateFormatString("yyyy-MM-dd"); uiProbation.setFont(APP_FONT); uiProbation.getJCalendar().setTodayButtonVisible(true); } { JLabel label = new JLabel("??"); uiCompanyPanel.add(label, "cell 3 3"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiExpiration = new JDateChooser(); uiCompanyPanel.add(uiExpiration, "cell 4 3 2 1,growx"); uiExpiration.setDateFormatString("yyyy-MM-dd"); uiExpiration.setFont(APP_FONT); uiExpiration.getJCalendar().setLeftButtonText(Employee.EXPIRATION_NO); uiExpiration.getJCalendar().setLeftButtonVisible(true); uiExpiration.getJCalendar().setRightButtonText(Employee.EXPIRATION_LONG); uiExpiration.getJCalendar().setRightButtonVisible(true); } { JLabel label = new JLabel(""); uiCompanyPanel.add(label, "cell 0 4"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiSchool = new LynkTextField(); uiCompanyPanel.add(uiSchool, "cell 1 4 2 1,growx"); } { JLabel label = new JLabel(""); uiCompanyPanel.add(label, "cell 3 4"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiDegree = new JComboBox<String>(); uiCompanyPanel.add(uiDegree, "cell 4 4 2 1,growx"); uiDegree.setMaximumRowCount(12); uiDegree.setModel(new DefaultComboBoxModel<String>(new String[] { "", Employee.DEGREE_A, Employee.DEGREE_B, Employee.DEGREE_C, Employee.DEGREE_D, Employee.DEGREE_E, Employee.DEGREE_F, Employee.DEGREE_G, Employee.DEGREE_H, Employee.DEGREE_I, Employee.DEGREE_J })); uiDegree.setFont(APP_FONT); } { JLabel label = new JLabel(""); uiCompanyPanel.add(label, "cell 0 5"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); } { uiMajor = new LynkTextField(); uiCompanyPanel.add(uiMajor, "cell 1 5 2 1,growx"); } { JLabel label = new JLabel(""); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); uiCompanyPanel.add(label, "cell 3 5"); } { uiGuide = new LynkTextField(); uiCompanyPanel.add(uiGuide, "cell 4 5 2 1,growx"); } { JLabel label = new JLabel("?"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT_BLOD); uiCompanyPanel.add(label, "cell 0 6"); } { uiPhoneShort = new LynkTextField(); uiPhoneShort.setFont(APP_FONT_BLOD); uiCompanyPanel.add(uiPhoneShort, "cell 1 6 2 1,growx"); } { JLabel label = new JLabel("?"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); uiCompanyPanel.add(label, "cell 3 6"); } { uiPerformance = new LynkTextField(); uiCompanyPanel.add(uiPerformance, "cell 4 6 2 1,growx"); } // { // JLabel label = new JLabel("??"); // label.setHorizontalAlignment(SwingConstants.RIGHT); // label.setFont(APP_FONT); // uiCompanyPanel.add(label, "cell 0 7"); // } // { // uiSuspendEnd = new LynkTextField(); // uiCompanyPanel.add(uiSuspendEnd, "cell 1 7 5 1,growx"); // } } { JPanel panel4 = new JPanel(); panel4.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); panel4.setLayout(new MigLayout("", "[]5[grow]", "[][][][grow][grow]")); uiInfoBasic.add(panel4, "cell 1 0 1 3,grow"); { JLabel label = new JLabel("???"); panel4.add(label, "cell 0 0,grow"); label.setFont(APP_FONT); } { uiSocialCard = new LynkTextField(); panel4.add(uiSocialCard, "cell 1 0,grow"); } { JLabel label = new JLabel("?"); panel4.add(label, "cell 0 1,grow"); label.setFont(APP_FONT); } { uiHousingCard = new LynkTextField(); panel4.add(uiHousingCard, "cell 1 1,grow"); } { JLabel label = new JLabel("??"); panel4.add(label, "cell 0 2,grow"); label.setFont(APP_FONT); } { uiBankCard = new LynkTextField(); panel4.add(uiBankCard, "cell 1 2,grow"); } { JLabel label = new JLabel("?"); panel4.add(label, "cell 0 3,growx,aligny top"); label.setFont(APP_FONT); } { JScrollPane scrollPane = new JScrollPane(); panel4.add(scrollPane, "cell 1 3,grow"); uiWorkExperience = new JTextArea(); uiWorkExperience.setFont(APP_FONT); scrollPane.setViewportView(uiWorkExperience); } { JLabel label = new JLabel(""); panel4.add(label, "cell 0 4,growx,aligny top"); label.setFont(APP_FONT); } { JScrollPane scrollPane = new JScrollPane(); panel4.add(scrollPane, "cell 1 4,grow"); { uiNote = new JTextArea(); uiNote.setFont(APP_FONT); scrollPane.setViewportView(uiNote); } } } } { JPanel uiInfoLeave = new JPanel(); uiInfoLeave.setLayout(new MigLayout("", "[]5[150px]25[]5[150px]", "[][][][grow][]")); uiInfoTab.addTab("??", uiInfoLeave); { uiLabelLeaveDate = new JLabel("?"); uiLabelLeaveDate.setFont(APP_FONT); uiInfoLeave.add(uiLabelLeaveDate, "cell 0 0,grow"); } { uiLeaveDate = new JDateChooser(); uiLeaveDate.setDateFormatString("yyyy-MM-dd"); uiLeaveDate.setFont(APP_FONT); uiLeaveDate.getJCalendar().setTodayButtonVisible(true); uiLeaveDate.getJCalendar().setNullDateButtonVisible(true); uiInfoLeave.add(uiLeaveDate, "cell 1 0,growx,aligny top"); } { uiLabelSocialEnd = new JLabel("??"); uiLabelSocialEnd.setFont(APP_FONT); uiInfoLeave.add(uiLabelSocialEnd, "cell 0 1,grow"); } { uiLabelHousingEnd = new JLabel("?"); uiLabelHousingEnd.setFont(APP_FONT); uiInfoLeave.add(uiLabelHousingEnd, "cell 2 1,grow"); } { uiHousingEndDate = new JDateChooser(); uiHousingEndDate.setDateFormatString("yyyy-MM-dd"); uiHousingEndDate.setFont(APP_FONT); uiHousingEndDate.getJCalendar().setLeftButtonText(""); uiHousingEndDate.getJCalendar().setLeftButtonVisible(true); uiHousingEndDate.getJCalendar().setTodayButtonVisible(true); uiHousingEndDate.getJCalendar().setNullDateButtonVisible(true); uiInfoLeave.add(uiHousingEndDate, "cell 3 1,growx,aligny top"); } { uiLabelLeaveType = new JLabel("?"); uiLabelLeaveType.setFont(APP_FONT); uiInfoLeave.add(uiLabelLeaveType, "cell 0 2,grow"); } { uiSocialEndDate = new JDateChooser(); uiSocialEndDate.setDateFormatString("yyyy-MM-dd"); uiSocialEndDate.setFont(APP_FONT); uiSocialEndDate.getJCalendar().setLeftButtonText(""); uiSocialEndDate.getJCalendar().setLeftButtonVisible(true); uiSocialEndDate.getJCalendar().setTodayButtonVisible(true); uiSocialEndDate.getJCalendar().setNullDateButtonVisible(true); uiInfoLeave.add(uiSocialEndDate, "cell 1 1,growx,aligny top"); } { uiLeaveType = new JComboBox<String>(new DefaultComboBoxModel<String>( new String[] { "", Employee.LEAVE_TYPE_A, Employee.LEAVE_TYPE_B, Employee.LEAVE_TYPE_C, Employee.LEAVE_TYPE_D, Employee.LEAVE_TYPE_E, Employee.LEAVE_TYPE_F, Employee.LEAVE_TYPE_G, Employee.LEAVE_TYPE_H })); uiLeaveType.setMaximumRowCount(10); uiLeaveType.setFont(APP_FONT); uiInfoLeave.add(uiLeaveType, "cell 1 2 3 1,grow"); } { uiLabelLeaveReason = new JLabel("?"); uiLabelLeaveReason.setFont(APP_FONT); uiInfoLeave.add(uiLabelLeaveReason, "cell 0 3,growx,aligny top"); } { JScrollPane scrollPane_2 = new JScrollPane(); uiInfoLeave.add(scrollPane_2, "cell 1 3 3 1,grow"); { uiLeaveReason = new JTextArea(); scrollPane_2.setViewportView(uiLeaveReason); uiLeaveReason.setFont(APP_FONT); } } { JLabel label = new JLabel("??"); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setFont(APP_FONT); uiInfoLeave.add(label, "cell 0 4"); } { uiTimeCardLeaveCertify = new LynkTextField(); uiTimeCardLeaveCertify.setEditable(false); uiInfoLeave.add(uiTimeCardLeaveCertify, "cell 1 4 2 1,growx"); } { JButton uiPrintLeaveCertify = new JButton("???"); uiPrintLeaveCertify.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiPrintLeaveCertifyActionPerformed(e); } }); uiPrintLeaveCertify.setToolTipText("???!"); uiPrintLeaveCertify.setFont(APP_FONT); uiPrintLeaveCertify.setFocusable(false); uiInfoLeave.add(uiPrintLeaveCertify, "cell 3 4,alignx right"); } } { JPanel uiInfoSuspendHistory = new JPanel(); uiInfoSuspendHistory.setLayout(new BorderLayout(0, 0)); uiInfoTab.addTab("???", uiInfoSuspendHistory); { JScrollPane scrollPane = new JScrollPane(); uiInfoSuspendHistory.add(scrollPane, BorderLayout.CENTER); { suspendModel = new EmployeeSuspendModel(); uiEmpSuspend = new LynkTable(suspendModel); uiEmpSuspend.addHighlighter(UtilsClient.createAlignHighlighter()); uiEmpSuspend.setAutoResizeMode(LynkTable.AUTO_RESIZE_ALL_COLUMNS); scrollPane.setRowHeaderView(new TableRowHead(uiEmpSuspend)); scrollPane.setViewportView(uiEmpSuspend); } } } { JPanel uiInfoEmpHistory = new JPanel(); uiInfoEmpHistory.setLayout(new BorderLayout(0, 0)); uiInfoTab.addTab("?", uiInfoEmpHistory); { JPanel pane = new JPanel(); pane.setLayout(new MigLayout("", "[][][][100px:100px:100px][]", "[]")); uiInfoEmpHistory.add(pane, BorderLayout.NORTH); { JLabel label = new JLabel(""); label.setFont(APP_FONT); pane.add(label, "cell 0 0"); } { uiHistoryType = new JComboBox<String>(new DefaultComboBoxModel<>( new String[] { "", PraisePunish.TYPE_A, PraisePunish.TYPE_B, PraisePunish.TYPE_C, PraisePunish.TYPE_D, PraisePunish.TYPE_E, PraisePunish.TYPE_F, PraisePunish.TYPE_G, PraisePunish.TYPE_H })); uiHistoryType.setFont(APP_FONT); pane.add(uiHistoryType, "cell 1 0"); } { JLabel label = new JLabel("?"); label.setFont(APP_FONT); pane.add(label, "cell 2 0"); } { uiHistoryOperator = new LynkTextField(); pane.add(uiHistoryOperator, "cell 3 0,growx"); } { JButton uiRefresh = new JButton(""); uiRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiRefreshActionPerformed(e); } }); uiRefresh.setIcon( new ImageIcon(InfoEmployee.class.getResource("/resource/image/refresh.png"))); uiRefresh.setFont(APP_FONT); uiRefresh.setFocusable(false); pane.add(uiRefresh, "cell 4 0"); } } { JScrollPane scrollPane = new JScrollPane(); uiInfoEmpHistory.add(scrollPane, BorderLayout.CENTER); { historyModel = new EmployeeHistoryModel(); uiEmployeeHistory = new LynkTable(historyModel); uiEmployeeHistory.setColumnSize(70, 540, 50, 130, 90); scrollPane.setViewportView(uiEmployeeHistory); scrollPane.setRowHeaderView(new TableRowHead(uiEmployeeHistory)); } } } { JPanel uiInfoJobAdjustment = new JPanel(); uiInfoJobAdjustment.setLayout(new BorderLayout(0, 0)); uiInfoTab.addTab("?", uiInfoJobAdjustment); { JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); uiInfoJobAdjustment.add(toolBar, BorderLayout.NORTH); { { JButton uiAddJobAdjust = new JButton("?"); uiAddJobAdjust.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiAddJobAdjustActionPerformed(e); } }); uiAddJobAdjust.setIcon( new ImageIcon(InfoEmployee.class.getResource("/resource/image/add.png"))); uiAddJobAdjust.setFont(APP_FONT); toolBar.add(uiAddJobAdjust); } } } { JScrollPane scrollPane = new JScrollPane(); uiInfoJobAdjustment.add(scrollPane, BorderLayout.CENTER); { jobAdjustmentModel = new JobAdjustmentModel(); uiJobAdjustment = new LynkTable(jobAdjustmentModel); uiJobAdjustment.setColumnSize(50, 100, 100, 100, 100, 100, 80, 100, 150); scrollPane.setRowHeaderView(new TableRowHead(uiJobAdjustment)); scrollPane.setViewportView(uiJobAdjustment); } } } { JPanel uiInfoPraisePunish = new JPanel(); uiInfoTab.addTab("", uiInfoPraisePunish); uiInfoPraisePunish.setLayout( new MigLayout("", "[]10[grow]30[]10[120]5[]5[120]20[]20[][grow]", "[][grow]")); { uiPraisePunishDateStart = new JDateChooser(); uiPraisePunishDateStart.setFont(APP_FONT); uiPraisePunishDateStart.setDateFormatString("yyyy-MM-dd"); uiInfoPraisePunish.add(uiPraisePunishDateStart, "cell 3 0,growx"); } { uiPraisePunishDateEnd = new JDateChooser(); uiPraisePunishDateEnd.setFont(APP_FONT); uiPraisePunishDateEnd.setDateFormatString("yyyy-MM-dd"); uiInfoPraisePunish.add(uiPraisePunishDateEnd, "cell 5 0,growx"); } JButton uiAddPraisePunish = new JButton(""); uiAddPraisePunish.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiAddPraisePunishActionPerformed(e); } }); { JButton uiFindPraisePunish = new JButton(""); uiFindPraisePunish.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiFindPraisePunishActionPerformed(e); } }); { JLabel label = new JLabel(""); label.setFont(APP_FONT); uiInfoPraisePunish.add(label, "cell 0 0,alignx trailing"); } { uiPraisePunishType = new JComboBox<String>( new DefaultComboBoxModel<String>(new String[] { "", PraisePunish.TYPE_A, PraisePunish.TYPE_B, PraisePunish.TYPE_C, PraisePunish.TYPE_D, PraisePunish.TYPE_E, PraisePunish.TYPE_F, PraisePunish.TYPE_G })); uiPraisePunishType.setEditable(true); uiPraisePunishType.setFont(APP_FONT); uiInfoPraisePunish.add(uiPraisePunishType, "cell 1 0,growx"); } { JLabel label = new JLabel(""); label.setFont(APP_FONT); uiInfoPraisePunish.add(label, "cell 2 0"); } { JLabel label = new JLabel(""); label.setFont(APP_FONT); uiInfoPraisePunish.add(label, "cell 4 0"); } uiFindPraisePunish.setFocusable(false); uiFindPraisePunish.setIcon( new ImageIcon(InfoEmployee.class.getResource("/resource/image/refresh.png"))); uiFindPraisePunish.setFont(APP_FONT); uiInfoPraisePunish.add(uiFindPraisePunish, "cell 6 0"); } uiAddPraisePunish .setIcon(new ImageIcon(InfoEmployee.class.getResource("/resource/image/add.png"))); uiAddPraisePunish.setFont(APP_FONT); uiAddPraisePunish.setFocusable(false); uiInfoPraisePunish.add(uiAddPraisePunish, "cell 7 0"); JScrollPane scrollPane = new JScrollPane(); uiInfoPraisePunish.add(scrollPane, "cell 0 1 9 1,grow"); { praisePunishModel = new PraisePunishModel( new String[] { PraisePunish.COLUMN_TYPE, PraisePunish.COLUMN_ACTION, PraisePunish.COLUMN_ACTION_DATE, PraisePunish.COLUMN_DEAL, PraisePunish.COLUMN_DEAL_DATE, PraisePunish.COLUMN_NOTE }); uiPraisePunish = new LynkTable(praisePunishModel); uiPraisePunish.setColumnVisible( new String[] { PraisePunish.COLUMN_TYPE, PraisePunish.COLUMN_ACTION, PraisePunish.COLUMN_ACTION_DATE, PraisePunish.COLUMN_DEAL, PraisePunish.COLUMN_DEAL_DATE, PraisePunish.COLUMN_NOTE }); uiPraisePunish.setDefaultRenderer(Object.class, new PraisePunishColorRenderer()); uiPraisePunish.setMouseDoubleClick(new MouseDoubleClick() { @Override public void doubleClick(int index) { if (index != -1) { index = uiPraisePunish.convertRowIndexToModel(index); PraisePunish pp = praisePunishModel.getPp(index); pp = InfoPraisePunish.showdialog(InfoEmployee.this, pp, null); if (pp != null) { praisePunishModel.updatePp(pp); } } } }); scrollPane.setViewportView(uiPraisePunish); scrollPane.setRowHeaderView(new TableRowHead(uiPraisePunish)); } } { JPanel uiPanelVacation = new JPanel(); uiPanelVacation.setLayout(new BorderLayout()); uiInfoTab.addTab("?", uiPanelVacation); { JToolBar uiVacationToolBar = new JToolBar(); uiVacationToolBar.setFloatable(false); uiPanelVacation.add(uiVacationToolBar, BorderLayout.NORTH); { JButton uiVacationRefresh = new JButton(""); uiVacationRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiVacationRefreshActionPerformed(e); } }); uiVacationRefresh.setIcon( new ImageIcon(InfoEmployee.class.getResource("/resource/image/refresh.png"))); uiVacationRefresh.setFocusable(false); uiVacationRefresh.setFont(APP_FONT); uiVacationToolBar.add(uiVacationRefresh); } uiVacationToolBar.addSeparator(); { uiVacationHistoryAdd = new JButton(""); uiVacationHistoryAdd.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiVacationAddActionPerformed(e); } }); uiVacationHistoryAdd.setIcon( new ImageIcon(InfoEmployee.class.getResource("/resource/image/add.png"))); uiVacationHistoryAdd.setFocusable(false); uiVacationHistoryAdd.setFont(APP_FONT); uiVacationToolBar.add(uiVacationHistoryAdd); } uiVacationToolBar.addSeparator(); { JButton uiEndLastLeft = new JButton(""); uiEndLastLeft.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { uiEndLastLeftActionPerformed(e); } }); uiEndLastLeft.setIcon( new ImageIcon(InfoEmployee.class.getResource("/resource/image/add.png"))); uiEndLastLeft.setFocusable(false); uiEndLastLeft.setFont(APP_FONT); uiVacationToolBar.add(uiEndLastLeft); } } { JPanel uiPanelVacationInfo = new JPanel(); uiPanelVacation.add(uiPanelVacationInfo, BorderLayout.CENTER); uiPanelVacationInfo.setLayout(new MigLayout("", "[grow]", "[][grow]")); JPanel paneAv = new JPanel(); uiPanelVacationInfo.add(paneAv, "cell 0 0,grow"); paneAv.setLayout(new MigLayout("", "[][grow]50[][grow]", "[][][]")); { uiVacationStartEnd = new JLabel("Time"); uiVacationStartEnd.setHorizontalAlignment(SwingConstants.CENTER); paneAv.add(uiVacationStartEnd, "cell 0 0 4 1,growx"); uiVacationStartEnd.setForeground(Color.BLUE); uiVacationStartEnd.setFont(APP_FONT.deriveFont(16f)); } { JLabel labe = new JLabel(":"); paneAv.add(labe, "cell 0 1"); labe.setFont(APP_FONT.deriveFont(16f)); } { uiLastTotal = new JLabel(""); paneAv.add(uiLastTotal, "cell 1 1,alignx left"); uiLastTotal.setForeground(Color.BLUE); uiLastTotal.setFont(APP_FONT.deriveFont(16f)); } { JLabel labe = new JLabel(":"); paneAv.add(labe, "cell 2 1"); labe.setFont(APP_FONT.deriveFont(16f)); } { uiLastLeft = new JLabel(""); paneAv.add(uiLastLeft, "cell 3 1,alignx left"); uiLastLeft.setForeground(Color.BLUE); uiLastLeft.setFont(APP_FONT.deriveFont(16f)); } { JLabel labe = new JLabel(":"); paneAv.add(labe, "cell 0 2"); labe.setFont(APP_FONT.deriveFont(16f)); } { uiCurrentTotal = new JLabel(""); paneAv.add(uiCurrentTotal, "cell 1 2,alignx left"); uiCurrentTotal.setForeground(Color.BLUE); uiCurrentTotal.setFont(APP_FONT.deriveFont(16f)); } { JLabel labe = new JLabel("?:"); paneAv.add(labe, "cell 2 2"); labe.setFont(APP_FONT.deriveFont(16f)); } { uiLeftHours = new JLabel(""); paneAv.add(uiLeftHours, "cell 3 2,alignx left"); uiLeftHours.setForeground(Color.BLUE); uiLeftHours.setFont(APP_FONT.deriveFont(16f)); } JScrollPane scrollPane = new JScrollPane(); uiPanelVacationInfo.add(scrollPane, "cell 0 1,grow"); { attendanceVacationModel = new AttendanceVacationHistoryModel(); uiAttendanceVacationHistory = new LynkTable(attendanceVacationModel); uiAttendanceVacationHistory.setAutoResizeMode(LynkTable.AUTO_RESIZE_ALL_COLUMNS); scrollPane.setViewportView(uiAttendanceVacationHistory); scrollPane.setRowHeaderView(new TableRowHead(uiAttendanceVacationHistory)); } } } } } }
From source file:edu.ku.brc.ui.UIHelper.java
/** * Creates an icon button with tooltip and action listener. * @param iconName the name of the icon (use default size) * @param toolTipTextKey the tooltip text resource bundle key * @param al the action listener//from w ww. j a v a2s. c o m * @param withEmptyBorder set an empyt border * @return the JButton icon button */ public static JButton createIconBtn(final String iconName, final IconManager.IconSize size, final String toolTipTextKey, final boolean withEmptyBorder, final Action action) { JButton btn = new JButton(action) { @Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); setBorder(emptyBorder); } }; btn.setOpaque(false); if (!withEmptyBorder) { btn.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { if (((JButton) e.getSource()).isEnabled()) { ((JButton) e.getSource()).setBorder(focusBorder); } super.mouseEntered(e); } @Override public void mouseExited(MouseEvent e) { if (((JButton) e.getSource()).isEnabled()) { ((JButton) e.getSource()).setBorder(emptyBorder); } super.mouseExited(e); } }); btn.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { if (((JButton) e.getSource()).isEnabled()) { ((JButton) e.getSource()).setBorder(focusBorder); } } public void focusLost(FocusEvent e) { if (((JButton) e.getSource()).isEnabled()) { ((JButton) e.getSource()).setBorder(emptyBorder); } } }); btn.setBorder(emptyBorder); } btn.setIcon(size != null ? IconManager.getIcon(iconName, size) : IconManager.getIcon(iconName)); btn.setText(null); if (StringUtils.isNotEmpty(toolTipTextKey)) { btn.setToolTipText(getResourceString(toolTipTextKey)); } btn.setEnabled(false); btn.setFocusable(true); btn.setMargin(new Insets(0, 0, 0, 0)); setControlSize(btn); return btn; }
From source file:edu.ku.brc.af.ui.forms.FormViewObj.java
/** * Creates the JButton that displays the current state of the forms validation * @param window//from w w w. ja v a2 s.c om * @param validator * @return */ public static JButton createValidationIndicator(final Component comp, final FormValidator validator) { if (validator != null) { JButton validationInfoBtn = new JButton(IconManager.getIcon("ValidationValid")); validationInfoBtn.setOpaque(false); validationInfoBtn.setToolTipText(getResourceString("SHOW_VALIDATION_INFO_TT")); validationInfoBtn.setMargin(new Insets(1, 1, 1, 1)); validationInfoBtn.setBorder(BorderFactory.createEmptyBorder()); validationInfoBtn.setFocusable(false); validationInfoBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { showValidationInfo(comp instanceof Window ? (Window) comp : UIHelper.getWindow(comp), validator); } }); validator.setValidationBtn(validationInfoBtn); return validationInfoBtn; } // else return null; }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * Add a button with an icon in it//from www. ja v a2 s .c om * * @param container - parent container * @param label - button label * @param image - button image * @param width - button width * @param height - button height * @param mnemonic - button mnemonic * @param tooltip - tool tip for button * @param placement - TableLayout placement in parent container * @param debug - turn on/off red debug borders * @return JButton with image */ public static JButton addIconButton(Container container, String label, String image, Integer width, Integer height, Integer mnemonic, String tooltip, String placement, boolean debug) { JButton button = null; if (image == null) { button = new JButton(label); } else { java.net.URL imgURL = GuiImporter.class.getResource(image); if (imgURL != null && label.length() > 0) { button = new JButton(label, new ImageIcon(imgURL)); } else if (imgURL != null) { button = new JButton(null, new ImageIcon(imgURL)); } else { button = new JButton(label); log.error("Couldn't find icon: " + image); } } if (width != null && height != null && width > 0 && height > 0) { button.setMaximumSize(new Dimension(width, height)); button.setPreferredSize(new Dimension(width, height)); button.setMinimumSize(new Dimension(width, height)); button.setSize(new Dimension(width, height)); } if (mnemonic != null) button.setMnemonic(mnemonic); button.setOpaque(!getIsMac()); button.setToolTipText(tooltip); container.add(button, placement); if (isMotif() == true) { Border b = BorderFactory.createLineBorder(Color.gray); button.setMargin(new Insets(0, 0, 0, 0)); button.setBorder(b); } if (debug == true) button.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), button.getBorder())); return button; }
From source file:org.eobjects.datacleaner.panels.OpenAnalysisJobPanel.java
public OpenAnalysisJobPanel(final FileObject file, final AnalyzerBeansConfiguration configuration, final OpenAnalysisJobActionListener openAnalysisJobActionListener) { super(WidgetUtils.BG_COLOR_LESS_BRIGHT, WidgetUtils.BG_COLOR_LESS_BRIGHT); _file = file;/* w w w . j av a 2s . com*/ _openAnalysisJobActionListener = openAnalysisJobActionListener; setLayout(new BorderLayout()); setBorder(WidgetUtils.BORDER_LIST_ITEM); final AnalysisJobMetadata metadata = getMetadata(configuration); final String jobName = metadata.getJobName(); final String jobDescription = metadata.getJobDescription(); final String datastoreName = metadata.getDatastoreName(); final boolean isDemoJob = isDemoJob(metadata); final DCPanel labelListPanel = new DCPanel(); labelListPanel.setLayout(new VerticalLayout(4)); labelListPanel.setBorder(new EmptyBorder(4, 4, 4, 0)); final String title; final String filename = file.getName().getBaseName(); if (Strings.isNullOrEmpty(jobName)) { final String extension = FileFilters.ANALYSIS_XML.getExtension(); if (filename.toLowerCase().endsWith(extension)) { title = filename.substring(0, filename.length() - extension.length()); } else { title = filename; } } else { title = jobName; } final JButton titleButton = new JButton(title); titleButton.setFont(WidgetUtils.FONT_HEADER1); titleButton.setForeground(WidgetUtils.BG_COLOR_BLUE_MEDIUM); titleButton.setHorizontalAlignment(SwingConstants.LEFT); titleButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, WidgetUtils.BG_COLOR_MEDIUM)); titleButton.setToolTipText("Open job"); titleButton.setOpaque(false); titleButton.setMargin(new Insets(0, 0, 0, 0)); titleButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); titleButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (isDemoDatastoreConfigured(datastoreName, configuration)) { _openAnalysisJobActionListener.openFile(_file); } } }); final JButton executeButton = new JButton(executeIcon); executeButton.setOpaque(false); executeButton.setToolTipText("Execute job directly"); executeButton.setMargin(new Insets(0, 0, 0, 0)); executeButton.setBorderPainted(false); executeButton.setHorizontalAlignment(SwingConstants.RIGHT); executeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (isDemoDatastoreConfigured(datastoreName, configuration)) { final ImageIcon executeIconLarge = ImageManager.get().getImageIcon(IconUtils.ACTION_EXECUTE); final String question = "Are you sure you want to execute the job\n'" + title + "'?"; final int choice = JOptionPane.showConfirmDialog(null, question, "Execute job?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, executeIconLarge); if (choice == JOptionPane.YES_OPTION) { final Injector injector = _openAnalysisJobActionListener.openAnalysisJob(_file); if (injector != null) { final ResultWindow resultWindow = injector.getInstance(ResultWindow.class); resultWindow.open(); resultWindow.startAnalysis(); } } } } }); final DCPanel titlePanel = new DCPanel(); titlePanel.setLayout(new BorderLayout()); titlePanel.add(DCPanel.around(titleButton), BorderLayout.CENTER); titlePanel.add(executeButton, BorderLayout.EAST); labelListPanel.add(titlePanel); if (!Strings.isNullOrEmpty(jobDescription)) { String desc = StringUtils.replaceWhitespaces(jobDescription, " "); desc = StringUtils.replaceAll(desc, " ", " "); final JLabel label = new JLabel(desc); label.setFont(WidgetUtils.FONT_SMALL); labelListPanel.add(label); } final Icon icon; { if (!StringUtils.isNullOrEmpty(datastoreName)) { final JLabel label = new JLabel(" " + datastoreName); label.setFont(WidgetUtils.FONT_SMALL); labelListPanel.add(label); final Datastore datastore = configuration.getDatastoreCatalog().getDatastore(datastoreName); if (isDemoJob) { icon = demoBadgeIcon; } else { icon = IconUtils.getDatastoreSpecificAnalysisJobIcon(datastore); } } else { icon = ImageManager.get().getImageIcon(IconUtils.MODEL_JOB, IconUtils.ICON_SIZE_LARGE); } } final JLabel iconLabel = new JLabel(icon); iconLabel.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight())); add(iconLabel, BorderLayout.WEST); add(labelListPanel, BorderLayout.CENTER); }
From source file:org.eobjects.datacleaner.panels.WelcomePanel.java
private DCPanel createNewDatastorePanel() { final DCPanel panel = new DCPanel(); panel.setBorder(WidgetUtils.BORDER_LIST_ITEM); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); panel.add(createNewDatastoreButton("CSV file", "Comma-separated values (CSV) file (or file with other separators)", IconUtils.CSV_IMAGEPATH, CsvDatastore.class, CsvDatastoreDialog.class)); panel.add(createNewDatastoreButton("Excel spreadsheet", "Microsoft Excel spreadsheet. Either .xls (97-2003) or .xlsx (2007+) format.", IconUtils.EXCEL_IMAGEPATH, ExcelDatastore.class, ExcelDatastoreDialog.class)); panel.add(createNewDatastoreButton("Access database", "Microsoft Access database file (.mdb).", IconUtils.ACCESS_IMAGEPATH, AccessDatastore.class, AccessDatastoreDialog.class)); panel.add(createNewDatastoreButton("SAS library", "A directory of SAS library files (.sas7bdat).", IconUtils.SAS_IMAGEPATH, SasDatastore.class, SasDatastoreDialog.class)); panel.add(createNewDatastoreButton("DBase database", "DBase database file (.dbf)", IconUtils.DBASE_IMAGEPATH, DbaseDatastore.class, DbaseDatastoreDialog.class)); panel.add(createNewDatastoreButton("Fixed width file", "Text file with fixed width values. Each value spans a fixed amount of text characters.", IconUtils.FIXEDWIDTH_IMAGEPATH, FixedWidthDatastore.class, FixedWidthDatastoreDialog.class)); panel.add(createNewDatastoreButton("XML file", "Extensible Markup Language file (.xml)", IconUtils.XML_IMAGEPATH, XmlDatastore.class, XmlDatastoreDialog.class)); panel.add(createNewDatastoreButton("JSON file", "JavaScript Object NOtation file (.json).", IconUtils.JSON_IMAGEPATH, JsonDatastore.class, JsonDatastoreDialog.class)); panel.add(/*from w w w . j a va2 s. co m*/ createNewDatastoreButton("OpenOffice.org Base database", "OpenOffice.org Base database file (.odb)", IconUtils.ODB_IMAGEPATH, OdbDatastore.class, OdbDatastoreDialog.class)); panel.add(Box.createHorizontalStrut(10)); panel.add(createNewDatastoreButton("Salesforce.com", "Connect to a Salesforce.com account", IconUtils.SALESFORCE_IMAGEPATH, SalesforceDatastore.class, SalesforceDatastoreDialog.class)); panel.add(createNewDatastoreButton("SugarCRM", "Connect to a SugarCRM system", IconUtils.SUGAR_CRM_IMAGEPATH, SugarCrmDatastore.class, SugarCrmDatastoreDialog.class)); panel.add(Box.createHorizontalStrut(10)); panel.add(createNewDatastoreButton("MongoDB database", "Connect to a MongoDB database", IconUtils.MONGODB_IMAGEPATH, MongoDbDatastore.class, MongoDbDatastoreDialog.class)); panel.add(createNewDatastoreButton("CouchDB database", "Connect to an Apache CouchDB database", IconUtils.COUCHDB_IMAGEPATH, CouchDbDatastore.class, CouchDbDatastoreDialog.class)); panel.add(createNewDatastoreButton("HBase database", "Connect to an Apache HBase database", IconUtils.HBASE_IMAGEPATH, HBaseDatastore.class, HBaseDatastoreDialog.class)); // set of databases that are displayed directly on panel final Set<String> databaseNames = new HashSet<String>(); createDefaultDatabaseButtons(panel, databaseNames); final JButton moreDatastoreTypesButton = new JButton("More", imageManager.getImageIcon(IconUtils.FILE_FOLDER, IconUtils.ICON_SIZE_SMALL)); moreDatastoreTypesButton.setMargin(new Insets(1, 1, 1, 4)); moreDatastoreTypesButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JPopupMenu popup = new JPopupMenu(); // installed databases final List<DatabaseDriverDescriptor> databaseDrivers = _databaseDriverCatalog .getInstalledWorkingDatabaseDrivers(); for (DatabaseDriverDescriptor databaseDriver : databaseDrivers) { final String databaseName = databaseDriver.getDisplayName(); if (!databaseNames.contains(databaseName)) { final String imagePath = databaseDriver.getIconImagePath(); final ImageIcon icon = imageManager.getImageIcon(imagePath, IconUtils.ICON_SIZE_SMALL); final JMenuItem menuItem = WidgetFactory.createMenuItem(databaseName, icon); menuItem.addActionListener(createJdbcActionListener(databaseName)); popup.add(menuItem); } } // custom/other jdbc connection { final ImageIcon icon = imageManager.getImageIcon(IconUtils.GENERIC_DATASTORE_IMAGEPATH, IconUtils.ICON_SIZE_SMALL); final JMenuItem menuItem = WidgetFactory.createMenuItem("Other database", icon); menuItem.addActionListener(createJdbcActionListener(null)); popup.add(menuItem); } // composite datastore final JMenuItem compositeMenuItem = WidgetFactory.createMenuItem("Composite datastore", imageManager.getImageIcon(IconUtils.COMPOSITE_IMAGEPATH, IconUtils.ICON_SIZE_SMALL)); compositeMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new CompositeDatastoreDialog(_datastoreCatalog, _analysisJobBuilderWindow.getWindowContext()).setVisible(true); } }); final JMenuItem databaseDriversMenuItem = WidgetFactory.createMenuItem("Manage database drivers...", imageManager.getImageIcon(IconUtils.MENU_OPTIONS, IconUtils.ICON_SIZE_SMALL)); databaseDriversMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OptionsDialog dialog = _optionsDialogProvider.get(); dialog.selectDatabaseDriversTab(); dialog.setVisible(true); } }); popup.add(databaseDriversMenuItem); popup.add(new JSeparator(JSeparator.HORIZONTAL)); popup.add(compositeMenuItem); popup.setBorder(WidgetUtils.BORDER_THIN); popup.show(moreDatastoreTypesButton, 0, moreDatastoreTypesButton.getHeight()); } }); panel.add(Box.createHorizontalStrut(10)); panel.add(moreDatastoreTypesButton); return panel; }
From source file:org.micromanager.asidispim.AcquisitionPanel.java
public AcquisitionPanel(ScriptInterface gui, Devices devices, Properties props, Cameras cameras, Prefs prefs, StagePositionUpdater posUpdater, Positions positions, ControllerUtils controller, AutofocusUtils autofocus) {//ww w . java 2 s. c o m super(MyStrings.PanelNames.ACQUSITION.toString(), new MigLayout("", "[center]0[center]0[center]", "0[top]0")); gui_ = gui; devices_ = devices; props_ = props; cameras_ = cameras; prefs_ = prefs; posUpdater_ = posUpdater; positions_ = positions; controller_ = controller; autofocus_ = autofocus; core_ = gui_.getMMCore(); numTimePointsDone_ = 0; sliceTiming_ = new SliceTiming(); lastAcquisitionPath_ = ""; lastAcquisitionName_ = ""; acq_ = null; channelNames_ = null; resetXaxisSpeed_ = true; acquisitionPanel_ = this; PanelUtils pu = new PanelUtils(prefs_, props_, devices_); // added to spinner controls where we should re-calculate the displayed // slice period, volume duration, and time lapse duration ChangeListener recalculateTimingDisplayCL = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (advancedSliceTimingCB_.isSelected()) { // need to update sliceTiming_ from property values sliceTiming_ = getTimingFromAdvancedSettings(); } updateDurationLabels(); } }; // added to combobox controls where we should re-calculate the displayed // slice period, volume duration, and time lapse duration ActionListener recalculateTimingDisplayAL = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateDurationLabels(); } }; // start volume sub-panel volPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "4[]8[]")); volPanel_.setBorder(PanelUtils.makeTitledBorder("Volume Settings")); if (!ASIdiSPIM.oSPIM) { } else { props_.setPropValue(Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_NUM_SIDES, "1"); } volPanel_.add(new JLabel("Number of sides:")); String[] str12 = { "1", "2" }; numSides_ = pu.makeDropDownBox(str12, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_NUM_SIDES, str12[1]); numSides_.addActionListener(recalculateTimingDisplayAL); if (!ASIdiSPIM.oSPIM) { } else { numSides_.setEnabled(false); } volPanel_.add(numSides_, "wrap"); volPanel_.add(new JLabel("First side:")); String[] ab = { Devices.Sides.A.toString(), Devices.Sides.B.toString() }; if (!ASIdiSPIM.oSPIM) { } else { props_.setPropValue(Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_FIRST_SIDE, Devices.Sides.A.toString()); } firstSide_ = pu.makeDropDownBox(ab, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_FIRST_SIDE, Devices.Sides.A.toString()); firstSide_.addActionListener(recalculateTimingDisplayAL); if (!ASIdiSPIM.oSPIM) { } else { firstSide_.setEnabled(false); } volPanel_.add(firstSide_, "wrap"); volPanel_.add(new JLabel("Delay before side [ms]:")); // used to read/write directly to galvo/micro-mirror firmware, but want different stage scan behavior delaySide_ = pu.makeSpinnerFloat(0, 10000, 0.25, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_DELAY_BEFORE_SIDE, 50); pu.addListenerLast(delaySide_, recalculateTimingDisplayCL); volPanel_.add(delaySide_, "wrap"); volPanel_.add(new JLabel("Slices per side:")); numSlices_ = pu.makeSpinnerInteger(1, 65000, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_NUM_SLICES, 20); pu.addListenerLast(numSlices_, recalculateTimingDisplayCL); volPanel_.add(numSlices_, "wrap"); volPanel_.add(new JLabel("Slice step size [\u00B5m]:")); stepSize_ = pu.makeSpinnerFloat(0, 100, 0.1, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_SLICE_STEP_SIZE, 1.0); pu.addListenerLast(stepSize_, recalculateTimingDisplayCL); // needed only for stage scanning b/c acceleration time related to speed volPanel_.add(stepSize_, "wrap"); // end volume sub-panel // start slice timing controls, have 2 options with advanced timing checkbox shared slicePanel_ = new JPanel(new MigLayout("", "[right]10[center]", "0[]0[]")); slicePanel_.setBorder(PanelUtils.makeTitledBorder("Slice Settings")); // start light sheet controls lightSheetPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "4[]8")); lightSheetPanel_.add(new JLabel("Scan reset time [ms]:")); JSpinner lsScanReset = pu.makeSpinnerFloat(1, 100, 0.25, // practical lower limit of 1ms Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_LS_SCAN_RESET, 3); lsScanReset.addChangeListener(PanelUtils.coerceToQuarterIntegers(lsScanReset)); pu.addListenerLast(lsScanReset, recalculateTimingDisplayCL); lightSheetPanel_.add(lsScanReset, "wrap"); lightSheetPanel_.add(new JLabel("Scan settle time [ms]:")); JSpinner lsScanSettle = pu.makeSpinnerFloat(0.25, 100, 0.25, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_LS_SCAN_SETTLE, 1); lsScanSettle.addChangeListener(PanelUtils.coerceToQuarterIntegers(lsScanSettle)); pu.addListenerLast(lsScanSettle, recalculateTimingDisplayCL); lightSheetPanel_.add(lsScanSettle, "wrap"); lightSheetPanel_.add(new JLabel("Shutter width [\u00B5m]:")); JSpinner lsShutterWidth = pu.makeSpinnerFloat(0.1, 100, 1, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_LS_SHUTTER_WIDTH, 5); pu.addListenerLast(lsShutterWidth, recalculateTimingDisplayCL); lightSheetPanel_.add(lsShutterWidth); // lightSheetPanel_.add(new JLabel("1 / (shutter speed):")); // JSpinner lsShutterSpeed = pu.makeSpinnerInteger(1, 10, // Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_LS_SHUTTER_SPEED, 1); // lightSheetPanel_.add(lsShutterSpeed, "wrap"); // end light sheet controls // start "normal" (not light sheet) controls normalPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "4[]8")); // out of order so we can reference it desiredSlicePeriod_ = pu.makeSpinnerFloat(1, 1000, 0.25, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_DESIRED_SLICE_PERIOD, 30); minSlicePeriodCB_ = pu.makeCheckBox("Minimize slice period", Properties.Keys.PREFS_MINIMIZE_SLICE_PERIOD, panelName_, false); minSlicePeriodCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean doMin = minSlicePeriodCB_.isSelected(); desiredSlicePeriod_.setEnabled(!doMin); desiredSlicePeriodLabel_.setEnabled(!doMin); recalculateSliceTiming(false); } }); normalPanel_.add(minSlicePeriodCB_, "span 2, wrap"); // special field that is enabled/disabled depending on whether advanced timing is enabled desiredSlicePeriodLabel_ = new JLabel("Slice period [ms]:"); normalPanel_.add(desiredSlicePeriodLabel_); normalPanel_.add(desiredSlicePeriod_, "wrap"); desiredSlicePeriod_.addChangeListener(PanelUtils.coerceToQuarterIntegers(desiredSlicePeriod_)); desiredSlicePeriod_.addChangeListener(recalculateTimingDisplayCL); // special field that is enabled/disabled depending on whether advanced timing is enabled desiredLightExposureLabel_ = new JLabel("Sample exposure [ms]:"); normalPanel_.add(desiredLightExposureLabel_); desiredLightExposure_ = pu.makeSpinnerFloat(1.0, 1000, 0.25, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_DESIRED_EXPOSURE, 8.5); desiredLightExposure_.addChangeListener(PanelUtils.coerceToQuarterIntegers(desiredLightExposure_)); desiredLightExposure_.addChangeListener(recalculateTimingDisplayCL); normalPanel_.add(desiredLightExposure_); // end normal simple slice timing controls slicePanelContainer_ = new JPanel(new MigLayout("", "0[center]0", "0[]0")); slicePanelContainer_.add( getSPIMCameraMode() == CameraModes.Keys.LIGHT_SHEET ? lightSheetPanel_ : normalPanel_, "growx"); slicePanel_.add(slicePanelContainer_, "span 2, center, wrap"); // special checkbox to use the advanced timing settings // action handler added below after defining components it enables/disables advancedSliceTimingCB_ = pu.makeCheckBox("Use advanced timing settings", Properties.Keys.PREFS_ADVANCED_SLICE_TIMING, panelName_, false); slicePanel_.add(advancedSliceTimingCB_, "span 2, left"); // end slice sub-panel // start advanced slice timing frame // visibility of this frame is controlled from advancedTiming checkbox // this frame is separate from main plugin window sliceFrameAdvanced_ = new MMFrame(); sliceFrameAdvanced_.setTitle("Advanced timing"); sliceFrameAdvanced_.loadPosition(100, 100); sliceAdvancedPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "[]8[]")); sliceFrameAdvanced_.add(sliceAdvancedPanel_); class SliceFrameAdapter extends WindowAdapter { @Override public void windowClosing(WindowEvent e) { advancedSliceTimingCB_.setSelected(false); sliceFrameAdvanced_.savePosition(); } } sliceFrameAdvanced_.addWindowListener(new SliceFrameAdapter()); JLabel scanDelayLabel = new JLabel("Delay before scan [ms]:"); sliceAdvancedPanel_.add(scanDelayLabel); delayScan_ = pu.makeSpinnerFloat(0, 10000, 0.25, new Devices.Keys[] { Devices.Keys.GALVOA, Devices.Keys.GALVOB }, Properties.Keys.SPIM_DELAY_SCAN, 0); delayScan_.addChangeListener(PanelUtils.coerceToQuarterIntegers(delayScan_)); delayScan_.addChangeListener(recalculateTimingDisplayCL); sliceAdvancedPanel_.add(delayScan_, "wrap"); JLabel lineScanLabel = new JLabel("Lines scans per slice:"); sliceAdvancedPanel_.add(lineScanLabel); numScansPerSlice_ = pu.makeSpinnerInteger(1, 1000, new Devices.Keys[] { Devices.Keys.GALVOA, Devices.Keys.GALVOB }, Properties.Keys.SPIM_NUM_SCANSPERSLICE, 1); numScansPerSlice_.addChangeListener(recalculateTimingDisplayCL); sliceAdvancedPanel_.add(numScansPerSlice_, "wrap"); JLabel lineScanPeriodLabel = new JLabel("Line scan duration [ms]:"); sliceAdvancedPanel_.add(lineScanPeriodLabel); lineScanDuration_ = pu.makeSpinnerFloat(1, 10000, 0.25, new Devices.Keys[] { Devices.Keys.GALVOA, Devices.Keys.GALVOB }, Properties.Keys.SPIM_DURATION_SCAN, 10); lineScanDuration_.addChangeListener(PanelUtils.coerceToQuarterIntegers(lineScanDuration_)); lineScanDuration_.addChangeListener(recalculateTimingDisplayCL); sliceAdvancedPanel_.add(lineScanDuration_, "wrap"); JLabel delayLaserLabel = new JLabel("Delay before laser [ms]:"); sliceAdvancedPanel_.add(delayLaserLabel); delayLaser_ = pu.makeSpinnerFloat(0, 10000, 0.25, new Devices.Keys[] { Devices.Keys.GALVOA, Devices.Keys.GALVOB }, Properties.Keys.SPIM_DELAY_LASER, 0); delayLaser_.addChangeListener(PanelUtils.coerceToQuarterIntegers(delayLaser_)); delayLaser_.addChangeListener(recalculateTimingDisplayCL); sliceAdvancedPanel_.add(delayLaser_, "wrap"); JLabel durationLabel = new JLabel("Laser trig duration [ms]:"); sliceAdvancedPanel_.add(durationLabel); durationLaser_ = pu.makeSpinnerFloat(0, 10000, 0.25, new Devices.Keys[] { Devices.Keys.GALVOA, Devices.Keys.GALVOB }, Properties.Keys.SPIM_DURATION_LASER, 1); durationLaser_.addChangeListener(PanelUtils.coerceToQuarterIntegers(durationLaser_)); durationLaser_.addChangeListener(recalculateTimingDisplayCL); sliceAdvancedPanel_.add(durationLaser_, "span 2, wrap"); JLabel delayLabel = new JLabel("Delay before camera [ms]:"); sliceAdvancedPanel_.add(delayLabel); delayCamera_ = pu.makeSpinnerFloat(0, 10000, 0.25, new Devices.Keys[] { Devices.Keys.GALVOA, Devices.Keys.GALVOB }, Properties.Keys.SPIM_DELAY_CAMERA, 0); delayCamera_.addChangeListener(PanelUtils.coerceToQuarterIntegers(delayCamera_)); delayCamera_.addChangeListener(recalculateTimingDisplayCL); sliceAdvancedPanel_.add(delayCamera_, "wrap"); JLabel cameraLabel = new JLabel("Camera trig duration [ms]:"); sliceAdvancedPanel_.add(cameraLabel); durationCamera_ = pu.makeSpinnerFloat(0, 1000, 0.25, new Devices.Keys[] { Devices.Keys.GALVOA, Devices.Keys.GALVOB }, Properties.Keys.SPIM_DURATION_CAMERA, 0); durationCamera_.addChangeListener(PanelUtils.coerceToQuarterIntegers(durationCamera_)); durationCamera_.addChangeListener(recalculateTimingDisplayCL); sliceAdvancedPanel_.add(durationCamera_, "wrap"); JLabel exposureLabel = new JLabel("Camera exposure [ms]:"); sliceAdvancedPanel_.add(exposureLabel); exposureCamera_ = pu.makeSpinnerFloat(0, 1000, 0.25, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_ADVANCED_CAMERA_EXPOSURE, 10f); exposureCamera_.addChangeListener(recalculateTimingDisplayCL); sliceAdvancedPanel_.add(exposureCamera_, "wrap"); alternateBeamScanCB_ = pu.makeCheckBox("Alternate scan direction", Properties.Keys.PREFS_SCAN_OPPOSITE_DIRECTIONS, panelName_, false); sliceAdvancedPanel_.add(alternateBeamScanCB_, "center, span 2, wrap"); simpleTimingComponents_ = new JComponent[] { desiredLightExposure_, minSlicePeriodCB_, desiredSlicePeriodLabel_, desiredLightExposureLabel_ }; final JComponent[] advancedTimingComponents = { delayScan_, numScansPerSlice_, lineScanDuration_, delayLaser_, durationLaser_, delayCamera_, durationCamera_, exposureCamera_, alternateBeamScanCB_ }; PanelUtils.componentsSetEnabled(advancedTimingComponents, advancedSliceTimingCB_.isSelected()); PanelUtils.componentsSetEnabled(simpleTimingComponents_, !advancedSliceTimingCB_.isSelected()); // this action listener takes care of enabling/disabling inputs // of the advanced slice timing window // we call this to get GUI looking right ItemListener sliceTimingDisableGUIInputs = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { boolean enabled = advancedSliceTimingCB_.isSelected(); // set other components in this advanced timing frame PanelUtils.componentsSetEnabled(advancedTimingComponents, enabled); // also control some components in main volume settings sub-panel PanelUtils.componentsSetEnabled(simpleTimingComponents_, !enabled); desiredSlicePeriod_.setEnabled(!enabled && !minSlicePeriodCB_.isSelected()); desiredSlicePeriodLabel_.setEnabled(!enabled && !minSlicePeriodCB_.isSelected()); updateDurationLabels(); } }; // this action listener shows/hides the advanced timing frame ActionListener showAdvancedTimingFrame = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean enabled = advancedSliceTimingCB_.isSelected(); if (enabled) { sliceFrameAdvanced_.setVisible(enabled); } } }; sliceFrameAdvanced_.pack(); sliceFrameAdvanced_.setResizable(false); // end slice Frame // start repeat (time lapse) sub-panel timepointPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "[]8[]")); useTimepointsCB_ = pu.makeCheckBox("Time points", Properties.Keys.PREFS_USE_TIMEPOINTS, panelName_, false); useTimepointsCB_.setToolTipText("Perform a time-lapse acquisition"); useTimepointsCB_.setEnabled(true); useTimepointsCB_.setFocusPainted(false); ComponentTitledBorder componentBorder = new ComponentTitledBorder(useTimepointsCB_, timepointPanel_, BorderFactory.createLineBorder(ASIdiSPIM.borderColor)); timepointPanel_.setBorder(componentBorder); ChangeListener recalculateTimeLapseDisplay = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { updateActualTimeLapseDurationLabel(); } }; useTimepointsCB_.addChangeListener(recalculateTimeLapseDisplay); timepointPanel_.add(new JLabel("Number:")); numTimepoints_ = pu.makeSpinnerInteger(1, 100000, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_NUM_ACQUISITIONS, 1); numTimepoints_.addChangeListener(recalculateTimeLapseDisplay); numTimepoints_.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { // update nrRepeats_ variable so the acquisition can be extended or shortened // as long as we have separate timepoints if (acquisitionRunning_.get() && getSavingSeparateFile()) { nrRepeats_ = getNumTimepoints(); } } }); timepointPanel_.add(numTimepoints_, "wrap"); timepointPanel_.add(new JLabel("Interval [s]:")); acquisitionInterval_ = pu.makeSpinnerFloat(0.1, 32000, 0.1, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_ACQUISITION_INTERVAL, 60); acquisitionInterval_.addChangeListener(recalculateTimeLapseDisplay); timepointPanel_.add(acquisitionInterval_, "wrap"); // enable/disable panel elements depending on checkbox state useTimepointsCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PanelUtils.componentsSetEnabled(timepointPanel_, useTimepointsCB_.isSelected()); } }); PanelUtils.componentsSetEnabled(timepointPanel_, useTimepointsCB_.isSelected()); // initialize // end repeat sub-panel // start savePanel // TODO for now these settings aren't part of acquisition settings // TODO consider whether that should be changed final int textFieldWidth = 16; savePanel_ = new JPanel(new MigLayout("", "[right]10[center]8[left]", "[]4[]")); savePanel_.setBorder(PanelUtils.makeTitledBorder("Data Saving Settings")); separateTimePointsCB_ = pu.makeCheckBox("Separate viewer / file for each time point", Properties.Keys.PREFS_SEPARATE_VIEWERS_FOR_TIMEPOINTS, panelName_, false); saveCB_ = pu.makeCheckBox("Save while acquiring", Properties.Keys.PREFS_SAVE_WHILE_ACQUIRING, panelName_, false); // make sure that when separate viewer is enabled then saving gets enabled too separateTimePointsCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (separateTimePointsCB_.isSelected() && !saveCB_.isSelected()) { saveCB_.doClick(); // setSelected() won't work because need to call its listener } } }); savePanel_.add(separateTimePointsCB_, "span 3, left, wrap"); savePanel_.add(saveCB_, "skip 1, span 2, center, wrap"); JLabel dirRootLabel = new JLabel("Directory root:"); savePanel_.add(dirRootLabel); DefaultFormatter formatter = new DefaultFormatter(); formatter.setOverwriteMode(false); rootField_ = new JFormattedTextField(formatter); rootField_.setText(prefs_.getString(panelName_, Properties.Keys.PLUGIN_DIRECTORY_ROOT, "")); rootField_.addPropertyChangeListener(new PropertyChangeListener() { // will respond to commitEdit() as well as GUI edit on commit @Override public void propertyChange(PropertyChangeEvent evt) { prefs_.putString(panelName_, Properties.Keys.PLUGIN_DIRECTORY_ROOT, rootField_.getText()); } }); rootField_.setColumns(textFieldWidth); savePanel_.add(rootField_, "span 2"); JButton browseRootButton = new JButton(); browseRootButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { setRootDirectory(rootField_); prefs_.putString(panelName_, Properties.Keys.PLUGIN_DIRECTORY_ROOT, rootField_.getText()); } }); browseRootButton.setMargin(new Insets(2, 5, 2, 5)); browseRootButton.setText("..."); savePanel_.add(browseRootButton, "wrap"); JLabel namePrefixLabel = new JLabel(); namePrefixLabel.setText("Name prefix:"); savePanel_.add(namePrefixLabel); prefixField_ = new JFormattedTextField(formatter); prefixField_.setText(prefs_.getString(panelName_, Properties.Keys.PLUGIN_NAME_PREFIX, "acq")); prefixField_.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { prefs_.putString(panelName_, Properties.Keys.PLUGIN_NAME_PREFIX, prefixField_.getText()); } }); prefixField_.setColumns(textFieldWidth); savePanel_.add(prefixField_, "span 2, wrap"); // since we use the name field even for acquisitions in RAM, // we only need to gray out the directory-related components final JComponent[] saveComponents = { browseRootButton, rootField_, dirRootLabel }; PanelUtils.componentsSetEnabled(saveComponents, saveCB_.isSelected()); saveCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PanelUtils.componentsSetEnabled(saveComponents, saveCB_.isSelected()); } }); // end save panel // start duration report panel durationPanel_ = new JPanel(new MigLayout("", "[right]6[left, 40%!]", "[]5[]")); durationPanel_.setBorder(PanelUtils.makeTitledBorder("Durations")); durationPanel_.setPreferredSize(new Dimension(125, 0)); // fix width so it doesn't constantly change depending on text durationPanel_.add(new JLabel("Slice:")); actualSlicePeriodLabel_ = new JLabel(); durationPanel_.add(actualSlicePeriodLabel_, "wrap"); durationPanel_.add(new JLabel("Volume:")); actualVolumeDurationLabel_ = new JLabel(); durationPanel_.add(actualVolumeDurationLabel_, "wrap"); durationPanel_.add(new JLabel("Total:")); actualTimeLapseDurationLabel_ = new JLabel(); durationPanel_.add(actualTimeLapseDurationLabel_, "wrap"); // end duration report panel buttonTestAcq_ = new JButton("Test Acquisition"); buttonTestAcq_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { runTestAcquisition(Devices.Sides.NONE); } }); buttonStart_ = new JToggleButton(); buttonStart_.setIconTextGap(6); buttonStart_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (isAcquisitionRequested()) { stopAcquisition(); } else { runAcquisition(); } } }); updateStartButton(); // call once to initialize, isSelected() will be false // make the size of the test button match the start button (easier on the eye) Dimension sizeStart = buttonStart_.getPreferredSize(); Dimension sizeTest = buttonTestAcq_.getPreferredSize(); sizeTest.height = sizeStart.height; buttonTestAcq_.setPreferredSize(sizeTest); acquisitionStatusLabel_ = new JLabel(""); acquisitionStatusLabel_.setBackground(prefixField_.getBackground()); acquisitionStatusLabel_.setOpaque(true); updateAcquisitionStatus(AcquisitionStatus.NONE); // Channel Panel (separate file for code) multiChannelPanel_ = new MultiChannelSubPanel(gui, devices_, props_, prefs_); multiChannelPanel_.addDurationLabelListener(this); // Position Panel final JPanel positionPanel = new JPanel(); positionPanel.setLayout(new MigLayout("flowx, fillx", "[right]10[left][10][]", "[]8[]")); usePositionsCB_ = pu.makeCheckBox("Multiple positions (XY)", Properties.Keys.PREFS_USE_MULTIPOSITION, panelName_, false); usePositionsCB_.setToolTipText("Acquire datasest at multiple postions"); usePositionsCB_.setEnabled(true); usePositionsCB_.setFocusPainted(false); componentBorder = new ComponentTitledBorder(usePositionsCB_, positionPanel, BorderFactory.createLineBorder(ASIdiSPIM.borderColor)); positionPanel.setBorder(componentBorder); usePositionsCB_.addChangeListener(recalculateTimingDisplayCL); final JButton editPositionListButton = new JButton("Edit position list..."); editPositionListButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { gui_.showXYPositionList(); } }); positionPanel.add(editPositionListButton); gridButton_ = new JButton("XYZ grid..."); positionPanel.add(gridButton_, "wrap"); // start XYZ grid frame // visibility of this frame is controlled from XYZ grid button // this frame is separate from main plugin window gridXPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "[]8[]")); useXGridCB_ = pu.makeCheckBox("Slices from stage coordinates", Properties.Keys.PREFS_USE_X_GRID, panelName_, true); useXGridCB_.setEnabled(true); useXGridCB_.setFocusPainted(false); componentBorder = new ComponentTitledBorder(useXGridCB_, gridXPanel_, BorderFactory.createLineBorder(ASIdiSPIM.borderColor)); gridXPanel_.setBorder(componentBorder); // enable/disable panel elements depending on checkbox state useXGridCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PanelUtils.componentsSetEnabled(gridXPanel_, useXGridCB_.isSelected()); } }); gridXPanel_.add(new JLabel("X start [um]:")); gridXStartField_ = pu.makeFloatEntryField(panelName_, "Grid_X_Start", -400, 5); gridXStartField_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { updateGridXCount(); } }); gridXPanel_.add(gridXStartField_); JButton tmp_but = new JButton("Set"); tmp_but.setBackground(Color.red); tmp_but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { gridXStartField_.setValue(positions_.getUpdatedPosition(Devices.Keys.XYSTAGE, Directions.X)); updateGridXCount(); } }); gridXPanel_.add(tmp_but, "wrap"); gridXPanel_.add(new JLabel("X stop [um]:")); gridXStopField_ = pu.makeFloatEntryField(panelName_, "Grid_X_Stop", 400, 5); gridXStopField_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { updateGridXCount(); } }); gridXPanel_.add(gridXStopField_); tmp_but = new JButton("Set"); tmp_but.setBackground(Color.red); tmp_but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { gridXStopField_.setValue(positions_.getUpdatedPosition(Devices.Keys.XYSTAGE, Directions.X)); updateGridXCount(); } }); gridXPanel_.add(tmp_but, "wrap"); gridXPanel_.add(new JLabel("X delta [um]:")); gridXDeltaField_ = pu.makeFloatEntryField(panelName_, "Grid_X_Delta", 3, 5); gridXDeltaField_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { updateGridXCount(); } }); gridXPanel_.add(gridXDeltaField_, "wrap"); // tmp_but = new JButton("Set"); // tmp_but.setBackground(Color.red); // tmp_but.addActionListener(new ActionListener() { // @Override // public void actionPerformed(ActionEvent arg0) { // // TODO figure out spacing, maybe to make reslicing trivial // updateGridXCount(); // } // }); // gridPanel_.add(tmp_but, "wrap"); gridXPanel_.add(new JLabel("Slice count:")); gridXCount_ = new JLabel(""); gridXPanel_.add(gridXCount_, "wrap"); updateGridXCount(); PanelUtils.componentsSetEnabled(gridXPanel_, useXGridCB_.isSelected()); // initialize gridYPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "[]8[]")); useYGridCB_ = pu.makeCheckBox("Grid in Y", Properties.Keys.PREFS_USE_Y_GRID, panelName_, true); useYGridCB_.setEnabled(true); useYGridCB_.setFocusPainted(false); componentBorder = new ComponentTitledBorder(useYGridCB_, gridYPanel_, BorderFactory.createLineBorder(ASIdiSPIM.borderColor)); gridYPanel_.setBorder(componentBorder); // enable/disable panel elements depending on checkbox state useYGridCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PanelUtils.componentsSetEnabled(gridYPanel_, useYGridCB_.isSelected()); } }); gridYPanel_.add(new JLabel("Y start [um]:")); gridYStartField_ = pu.makeFloatEntryField(panelName_, "Grid_Y_Start", -1200, 5); gridYStartField_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { updateGridYCount(); } }); gridYPanel_.add(gridYStartField_); tmp_but = new JButton("Set"); tmp_but.setBackground(Color.red); tmp_but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { gridYStartField_.setValue(positions_.getUpdatedPosition(Devices.Keys.XYSTAGE, Directions.Y)); updateGridYCount(); } }); gridYPanel_.add(tmp_but, "wrap"); gridYPanel_.add(new JLabel("Y stop [um]:")); gridYStopField_ = pu.makeFloatEntryField(panelName_, "Grid_Y_Stop", 1200, 5); gridYStopField_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { updateGridYCount(); } }); gridYPanel_.add(gridYStopField_); tmp_but = new JButton("Set"); tmp_but.setBackground(Color.red); tmp_but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { gridYStopField_.setValue(positions_.getUpdatedPosition(Devices.Keys.XYSTAGE, Directions.Y)); updateGridYCount(); } }); gridYPanel_.add(tmp_but, "wrap"); gridYPanel_.add(new JLabel("Y delta [um]:")); gridYDeltaField_ = pu.makeFloatEntryField(panelName_, "Grid_Y_Delta", 700, 5); gridYDeltaField_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { updateGridYCount(); } }); gridYPanel_.add(gridYDeltaField_); tmp_but = new JButton("Set"); tmp_but.setBackground(Color.red); tmp_but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Devices.Keys camKey = isFirstSideA() ? Devices.Keys.CAMERAA : Devices.Keys.CAMERAB; int height; try { height = core_.getROI(devices_.getMMDevice(camKey)).height; } catch (Exception e) { height = 1; } float pixelSize = (float) core_.getPixelSizeUm(); double delta = height * pixelSize; double overlap = props_.getPropValueFloat(Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_GRID_OVERLAP_PERCENT); delta *= (1 - overlap / 100); // sanity checks, would be better handled with exceptions or more formal checks if (height > 4100 || height < 4 || pixelSize < 1e-6) { return; } gridYDeltaField_.setValue(Math.round(delta)); updateGridYCount(); } }); gridYPanel_.add(tmp_but, "wrap"); gridYPanel_.add(new JLabel("Y count:")); gridYCount_ = new JLabel(""); gridYPanel_.add(gridYCount_, "wrap"); updateGridYCount(); PanelUtils.componentsSetEnabled(gridYPanel_, useYGridCB_.isSelected()); // initialize gridZPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "[]8[]")); useZGridCB_ = pu.makeCheckBox("Grid in Z", Properties.Keys.PREFS_USE_Z_GRID, panelName_, true); useZGridCB_.setEnabled(true); useZGridCB_.setFocusPainted(false); componentBorder = new ComponentTitledBorder(useZGridCB_, gridZPanel_, BorderFactory.createLineBorder(ASIdiSPIM.borderColor)); gridZPanel_.setBorder(componentBorder); // enable/disable panel elements depending on checkbox state useZGridCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PanelUtils.componentsSetEnabled(gridZPanel_, useZGridCB_.isSelected()); } }); gridZPanel_.add(new JLabel("Z start [um]:")); gridZStartField_ = pu.makeFloatEntryField(panelName_, "Grid_Z_Start", 0, 5); gridZStartField_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { updateGridZCount(); } }); gridZPanel_.add(gridZStartField_); tmp_but = new JButton("Set"); tmp_but.setBackground(Color.red); tmp_but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { gridZStartField_.setValue(positions_.getUpdatedPosition(Devices.Keys.UPPERZDRIVE)); updateGridZCount(); } }); gridZPanel_.add(tmp_but, "wrap"); gridZPanel_.add(new JLabel("Z stop [um]:")); gridZStopField_ = pu.makeFloatEntryField(panelName_, "Grid_Z_Stop", -800, 5); gridZStopField_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { updateGridZCount(); } }); gridZPanel_.add(gridZStopField_); tmp_but = new JButton("Set"); tmp_but.setBackground(Color.red); tmp_but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { gridZStopField_.setValue(positions_.getUpdatedPosition(Devices.Keys.UPPERZDRIVE)); updateGridZCount(); } }); gridZPanel_.add(tmp_but, "wrap"); gridZPanel_.add(new JLabel("Z delta [um]:")); gridZDeltaField_ = pu.makeFloatEntryField(panelName_, "Grid_Z_Delta", 400, 5); gridZDeltaField_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { updateGridZCount(); } }); gridZPanel_.add(gridZDeltaField_); tmp_but = new JButton("Set"); tmp_but.setBackground(Color.red); tmp_but.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Devices.Keys camKey = isFirstSideA() ? Devices.Keys.CAMERAA : Devices.Keys.CAMERAB; int width; try { width = core_.getROI(devices_.getMMDevice(camKey)).width; } catch (Exception e) { width = 1; } float pixelSize = (float) core_.getPixelSizeUm(); // sanity checks, would be better handled with exceptions or more formal checks if (width > 4100 || width < 4 || pixelSize < 1e-6) { return; } double delta = width * pixelSize / Math.sqrt(2); double overlap = props_.getPropValueFloat(Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_GRID_OVERLAP_PERCENT); delta *= (1 - overlap / 100); gridZDeltaField_.setValue(Math.round(delta)); updateGridZCount(); } }); gridZPanel_.add(tmp_but, "wrap"); gridZPanel_.add(new JLabel("Z count:")); gridZCount_ = new JLabel(""); gridZPanel_.add(gridZCount_, "wrap"); updateGridZCount(); PanelUtils.componentsSetEnabled(gridZPanel_, useZGridCB_.isSelected()); // initialize gridSettingsPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "[]8[]")); gridSettingsPanel_.setBorder(PanelUtils.makeTitledBorder("Grid settings")); gridSettingsPanel_.add(new JLabel("Overlap (Y and Z) [%]:")); JSpinner tileOverlapPercent = pu.makeSpinnerFloat(0, 100, 1, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_GRID_OVERLAP_PERCENT, 10); gridSettingsPanel_.add(tileOverlapPercent, "wrap"); clearYZGridCB_ = pu.makeCheckBox("Clear position list if YZ unused", Properties.Keys.PREFS_CLEAR_YZ_GRID, panelName_, true); gridSettingsPanel_.add(clearYZGridCB_, "span 2"); computeGridButton_ = new JButton("Compute grid"); computeGridButton_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { final boolean useX = useXGridCB_.isSelected(); final boolean useY = useYGridCB_.isSelected(); final boolean useZ = useZGridCB_.isSelected(); final int numX = useX ? updateGridXCount() : 1; final int numY = useY ? updateGridYCount() : 1; final int numZ = useZ ? updateGridZCount() : 1; double centerX = (((Double) gridXStartField_.getValue()) + ((Double) gridXStopField_.getValue())) / 2; double centerY = (((Double) gridYStartField_.getValue()) + ((Double) gridYStopField_.getValue())) / 2; double centerZ = (((Double) gridZStartField_.getValue()) + ((Double) gridZStopField_.getValue())) / 2; double deltaX = (Double) gridXDeltaField_.getValue(); double deltaY = (Double) gridYDeltaField_.getValue(); double deltaZ = (Double) gridZDeltaField_.getValue(); double startY = centerY - deltaY * (numY - 1) / 2; double startZ = centerZ - deltaZ * (numZ - 1) / 2; String xy_device = devices_.getMMDevice(Devices.Keys.XYSTAGE); String z_device = devices_.getMMDevice(Devices.Keys.UPPERZDRIVE); if (useX) { try { setVolumeSliceStepSize(Math.abs(deltaX) / Math.sqrt(2)); setVolumeSlicesPerVolume(numX); if (!useY && !useZ) { // move to X center if we aren't generating position list with it positions_.setPosition(Devices.Keys.XYSTAGE, Directions.X, centerX); } } catch (Exception ex) { // not sure what to do in case of error so ignore } } else { // use current X value as center; this was original behavior centerX = positions_.getUpdatedPosition(Devices.Keys.XYSTAGE, Directions.X); } // if we aren't using one axis, use the current position instead of GUI position if (useY && !useZ) { startZ = positions_.getUpdatedPosition(Devices.Keys.UPPERZDRIVE); } if (useZ && !useY) { startY = positions_.getUpdatedPosition(Devices.Keys.XYSTAGE, Directions.Y); } if (!useY && !useZ && !clearYZGridCB_.isSelected()) { return; } PositionList pl; try { pl = gui_.getPositionList(); } catch (MMScriptException e) { pl = new PositionList(); } boolean isPositionListEmpty = pl.getNumberOfPositions() == 0; if (!isPositionListEmpty) { boolean overwrite = MyDialogUtils.getConfirmDialogResult( "Do you really want to overwrite the existing position list?", JOptionPane.YES_NO_OPTION); if (!overwrite) { return; // nothing to do } } pl = new PositionList(); if (useY || useZ) { for (int iZ = 0; iZ < numZ; ++iZ) { for (int iY = 0; iY < numY; ++iY) { MultiStagePosition msp = new MultiStagePosition(); StagePosition s = new StagePosition(); s.stageName = xy_device; s.numAxes = 2; s.x = centerX; s.y = startY + iY * deltaY; msp.add(s); StagePosition s2 = new StagePosition(); s2.stageName = z_device; s2.x = startZ + iZ * deltaZ; msp.add(s2); msp.setLabel("Pos_" + iZ + "_" + iY); pl.addPosition(msp); } } } try { gui_.setPositionList(pl); } catch (MMScriptException ex) { MyDialogUtils.showError(ex, "Couldn't overwrite position list with generated YZ grid"); } } }); gridFrame_ = new MMFrame(); gridFrame_.setTitle("XYZ Grid"); gridFrame_.loadPosition(100, 100); gridPanel_ = new JPanel(new MigLayout("", "[right]10[center]", "[]8[]")); gridFrame_.add(gridPanel_); class GridFrameAdapter extends WindowAdapter { @Override public void windowClosing(WindowEvent e) { gridButton_.setSelected(false); gridFrame_.savePosition(); } } gridFrame_.addWindowListener(new GridFrameAdapter()); gridButton_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { gridFrame_.setVisible(true); } }); gridPanel_.add(gridYPanel_); gridPanel_.add(gridZPanel_, "wrap"); gridPanel_.add(gridXPanel_, "spany 2"); gridPanel_.add(gridSettingsPanel_, "growx, wrap"); gridPanel_.add(computeGridButton_, "growx, growy"); gridFrame_.pack(); gridFrame_.setResizable(false); // end YZ grid frame positionPanel.add(new JLabel("Post-move delay [ms]:")); positionDelay_ = pu.makeSpinnerFloat(0.0, 10000.0, 100.0, Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_POSITION_DELAY, 0.0); positionPanel.add(positionDelay_, "wrap"); // enable/disable panel elements depending on checkbox state usePositionsCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PanelUtils.componentsSetEnabled(positionPanel, usePositionsCB_.isSelected()); gridButton_.setEnabled(true); // leave this always enabled } }); PanelUtils.componentsSetEnabled(positionPanel, usePositionsCB_.isSelected()); // initialize gridButton_.setEnabled(true); // leave this always enabled // end of Position panel // checkbox to use navigation joystick settings or not // an "orphan" UI element navigationJoysticksCB_ = new JCheckBox("Use Navigation joystick settings"); navigationJoysticksCB_ .setSelected(prefs_.getBoolean(panelName_, Properties.Keys.PLUGIN_USE_NAVIGATION_JOYSTICKS, false)); navigationJoysticksCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateJoysticks(); prefs_.putBoolean(panelName_, Properties.Keys.PLUGIN_USE_NAVIGATION_JOYSTICKS, navigationJoysticksCB_.isSelected()); } }); // checkbox to signal that autofocus should be used during acquisition // another orphan UI element useAutofocusCB_ = new JCheckBox("Autofocus periodically"); useAutofocusCB_ .setSelected(prefs_.getBoolean(panelName_, Properties.Keys.PLUGIN_ACQUSITION_USE_AUTOFOCUS, false)); useAutofocusCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { prefs_.putBoolean(panelName_, Properties.Keys.PLUGIN_ACQUSITION_USE_AUTOFOCUS, useAutofocusCB_.isSelected()); } }); // checkbox to signal that movement should be corrected during acquisition // Yet another orphan UI element useMovementCorrectionCB_ = new JCheckBox("Motion correction"); useMovementCorrectionCB_.setSelected( prefs_.getBoolean(panelName_, Properties.Keys.PLUGIN_ACQUSITION_USE_MOVEMENT_CORRECTION, false)); useMovementCorrectionCB_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { prefs_.putBoolean(panelName_, Properties.Keys.PLUGIN_ACQUSITION_USE_MOVEMENT_CORRECTION, useMovementCorrectionCB_.isSelected()); } }); // set up tabbed panels for GUI // make 3 columns as own JPanels to get vertical space right // in each column without dependencies on other columns leftColumnPanel_ = new JPanel(new MigLayout("", "[]", "[]6[]10[]10[]")); leftColumnPanel_.add(durationPanel_, "split 2"); leftColumnPanel_.add(timepointPanel_, "wrap, growx"); leftColumnPanel_.add(savePanel_, "wrap"); leftColumnPanel_.add(new JLabel("Acquisition mode: "), "split 2, right"); AcquisitionModes acqModes = new AcquisitionModes(devices_, prefs_); spimMode_ = acqModes.getComboBox(); spimMode_.addActionListener(recalculateTimingDisplayAL); leftColumnPanel_.add(spimMode_, "left, wrap"); leftColumnPanel_.add(buttonStart_, "split 3, left"); leftColumnPanel_.add(new JLabel(" ")); leftColumnPanel_.add(buttonTestAcq_, "wrap"); leftColumnPanel_.add(new JLabel("Status:"), "split 2, left"); leftColumnPanel_.add(acquisitionStatusLabel_); centerColumnPanel_ = new JPanel(new MigLayout("", "[]", "[]")); centerColumnPanel_.add(positionPanel, "growx, wrap"); centerColumnPanel_.add(multiChannelPanel_, "wrap"); centerColumnPanel_.add(navigationJoysticksCB_, "wrap"); centerColumnPanel_.add(useAutofocusCB_, "split 2"); centerColumnPanel_.add(useMovementCorrectionCB_); rightColumnPanel_ = new JPanel(new MigLayout("", "[center]0", "[]0[]")); rightColumnPanel_.add(volPanel_, "growx, wrap"); rightColumnPanel_.add(slicePanel_, "growx"); // add the column panels to the main panel super.add(leftColumnPanel_); super.add(centerColumnPanel_); super.add(rightColumnPanel_); // properly initialize the advanced slice timing advancedSliceTimingCB_.addItemListener(sliceTimingDisableGUIInputs); sliceTimingDisableGUIInputs.itemStateChanged(null); advancedSliceTimingCB_.addActionListener(showAdvancedTimingFrame); // included is calculating slice timing updateDurationLabels(); // update local variables zStepUm_ = PanelUtils.getSpinnerFloatValue(stepSize_); refreshXYZPositions(); }
From source file:org.optaplanner.examples.cloudbalancing.swingui.CloudBalancingPanel.java
public JButton createButton(CloudProcess process) { JButton button = new JButton(new CloudProcessAction(process)); button.setMargin(new Insets(0, 0, 0, 0)); return button; }
From source file:org.orbisgis.core.ui.plugins.views.geocatalog.Catalog.java
private JButton getTagManagementButton(ImageIcon icon, String actionCommand) { JButton ret = new JButton(icon); ret.addActionListener(new ActionListener() { @Override/*from www. j a va 2 s . co m*/ public void actionPerformed(ActionEvent e) { if (AC_BTN_ADD_TAG.equals(e.getActionCommand())) { AskValue av = new AskValue( I18N.getString("orbisgis.org.orbisgis.core.ui.plugins.views.geocatalog.newTag"), I18N.getString("orbisgis.org.orbisgis.core.ui.message.askValue.sql"), I18N.getString("orbisgis.org.orbisgis.core.ui.message.askValue.error")); if (UIFactory.showDialog(av)) { String tagText = av.getValue(); addTag(tagText); } } else if (AC_BTN_DEL_TAG.equals(e.getActionCommand())) { tagSources.remove(lstTags.getSelectedValue()); refreshTagModel(); } } }); ret.setActionCommand(actionCommand); ret.setMargin(new Insets(0, 0, 0, 0)); return ret; }