List of usage examples for com.jgoodies.forms.layout CellConstraints CellConstraints
public CellConstraints()
From source file:ca.phon.app.session.editor.view.session_information.SessionInfoEditorView.java
License:Open Source License
private void init() { setLayout(new BorderLayout()); contentPanel = new TierDataLayoutPanel(); dateField = createDateField();/*from w ww. j a v a 2 s. c o m*/ dateField.getTextField().setColumns(10); dateField.setBackground(Color.white); mediaLocationField = new MediaSelectionField(getEditor().getProject()); mediaLocationField.setEditor(getEditor()); mediaLocationField.getTextField().setColumns(10); mediaLocationField.addPropertyChangeListener(FileSelectionField.FILE_PROP, mediaLocationListener); participantTable = new JXTable(); participantTable.setVisibleRowCount(3); ComponentInputMap participantTableInputMap = new ComponentInputMap(participantTable); ActionMap participantTableActionMap = new ActionMap(); ImageIcon deleteIcon = IconManager.getInstance().getIcon("actions/delete_user", IconSize.SMALL); final PhonUIAction deleteAction = new PhonUIAction(this, "deleteParticipant"); deleteAction.putValue(PhonUIAction.SHORT_DESCRIPTION, "Delete selected participant"); deleteAction.putValue(PhonUIAction.SMALL_ICON, deleteIcon); participantTableActionMap.put("DELETE_PARTICIPANT", deleteAction); participantTableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DELETE_PARTICIPANT"); participantTableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "DELETE_PARTICIPANT"); removeParticipantButton = new JButton(deleteAction); participantTable.setInputMap(WHEN_FOCUSED, participantTableInputMap); participantTable.setActionMap(participantTableActionMap); addParticipantButton = new JButton(new NewParticipantAction(getEditor(), this)); addParticipantButton.setFocusable(false); ImageIcon editIcon = IconManager.getInstance().getIcon("actions/edit_user", IconSize.SMALL); final PhonUIAction editParticipantAct = new PhonUIAction(this, "editParticipant"); editParticipantAct.putValue(PhonUIAction.NAME, "Edit participant..."); editParticipantAct.putValue(PhonUIAction.SHORT_DESCRIPTION, "Edit selected participant..."); editParticipantAct.putValue(PhonUIAction.SMALL_ICON, editIcon); editParticipantButton = new JButton(editParticipantAct); editParticipantButton.setFocusable(false); final CellConstraints cc = new CellConstraints(); FormLayout participantLayout = new FormLayout("fill:pref:grow, pref, pref, pref", "pref, pref, pref:grow"); JPanel participantPanel = new JPanel(participantLayout); participantPanel.setBackground(Color.white); participantPanel.add(new JScrollPane(participantTable), cc.xywh(1, 2, 3, 2)); participantPanel.add(addParticipantButton, cc.xy(2, 1)); participantPanel.add(editParticipantButton, cc.xy(3, 1)); participantPanel.add(removeParticipantButton, cc.xy(4, 2)); participantTable.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent arg0) { if (arg0.getClickCount() == 2 && arg0.getButton() == MouseEvent.BUTTON1) { editParticipantAct.actionPerformed(new ActionEvent(arg0.getSource(), arg0.getID(), "edit")); } } }); languageField = new LanguageField(); languageField.getDocument().addDocumentListener(languageFieldListener); int rowIdx = 0; final JLabel dateLbl = new JLabel("Session Date"); dateLbl.setHorizontalAlignment(SwingConstants.RIGHT); contentPanel.add(dateLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx)); contentPanel.add(dateField, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++)); final JLabel mediaLbl = new JLabel("Media"); mediaLbl.setHorizontalAlignment(SwingConstants.RIGHT); contentPanel.add(mediaLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx)); contentPanel.add(mediaLocationField, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++)); final JLabel partLbl = new JLabel("Participants"); partLbl.setHorizontalAlignment(SwingConstants.RIGHT); contentPanel.add(partLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx)); contentPanel.add(participantPanel, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++)); final JLabel langLbl = new JLabel("Language"); langLbl.setHorizontalAlignment(SwingConstants.RIGHT); contentPanel.add(langLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx)); contentPanel.add(languageField, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++)); add(new JScrollPane(contentPanel), BorderLayout.CENTER); update(); }
From source file:ca.phon.app.session.editor.view.syllabification_and_alignment.SyllabificationAlignmentEditorView.java
License:Open Source License
private void init() { // tier content contentPane = new TierDataLayoutPanel(); // top panel//from ww w .j av a 2s .c om final FormLayout topLayout = new FormLayout("pref, pref, pref, pref, pref, fill:pref:grow, right:pref", "pref"); topPanel = new JPanel(topLayout); final SyllabificationSettingsCommand settingsAct = new SyllabificationSettingsCommand(getEditor(), this); settingsBtn = new JButton(settingsAct); final PhonUIAction toggleTargetAct = new PhonUIAction(this, "toggleCheckbox"); toggleTargetAct.putValue(PhonUIAction.NAME, SystemTierType.TargetSyllables.getName()); toggleTargetAct.putValue(PhonUIAction.SHORT_DESCRIPTION, "Toggle target syllables"); toggleTargetAct.putValue(PhonUIAction.SELECTED_KEY, Boolean.TRUE); targetIPABox = new JCheckBox(toggleTargetAct); final PhonUIAction toggleActualAct = new PhonUIAction(this, "toggleCheckbox"); toggleActualAct.putValue(PhonUIAction.NAME, SystemTierType.ActualSyllables.getName()); toggleActualAct.putValue(PhonUIAction.SHORT_DESCRIPTION, "Toggle actual syllables"); toggleActualAct.putValue(PhonUIAction.SELECTED_KEY, Boolean.TRUE); actualIPABox = new JCheckBox(toggleActualAct); final PhonUIAction toggleAlignmentAct = new PhonUIAction(this, "toggleCheckbox"); toggleAlignmentAct.putValue(PhonUIAction.NAME, SystemTierType.SyllableAlignment.getName()); toggleAlignmentAct.putValue(PhonUIAction.SHORT_DESCRIPTION, "Toggle alignment"); toggleAlignmentAct.putValue(PhonUIAction.SELECTED_KEY, Boolean.TRUE); alignmentBox = new JCheckBox(toggleAlignmentAct); final PhonUIAction toggleAlignmentColorAct = new PhonUIAction(this, "toggleCheckbox"); toggleAlignmentColorAct.putValue(PhonUIAction.NAME, "Color in alignment"); toggleAlignmentColorAct.putValue(PhonUIAction.SHORT_DESCRIPTION, "Toggle color in alignment"); toggleAlignmentColorAct.putValue(PhonUIAction.SELECTED_KEY, Boolean.FALSE); colorInAlignmentBox = new JCheckBox(toggleAlignmentColorAct); final TierDataLayoutButtons tdlb = new TierDataLayoutButtons(contentPane, (TierDataLayout) contentPane.getLayout()); final CellConstraints cc = new CellConstraints(); topPanel.add(settingsBtn, cc.xy(1, 1)); topPanel.add(targetIPABox, cc.xy(2, 1)); topPanel.add(actualIPABox, cc.xy(3, 1)); topPanel.add(alignmentBox, cc.xy(4, 1)); topPanel.add(colorInAlignmentBox, cc.xy(5, 1)); topPanel.add(tdlb, cc.xy(7, 1)); setLayout(new BorderLayout()); scroller = new JScrollPane(contentPane); scroller.setBackground(Color.white); scroller.setOpaque(true); add(topPanel, BorderLayout.NORTH); add(scroller, BorderLayout.CENTER); update(); }
From source file:ca.phon.app.session.editor.view.syllabification_and_alignment.SyllabificationSettingsPanel.java
License:Open Source License
private void init() { final FormLayout layout = new FormLayout("right:pref, fill:pref:grow", "5dlu, pref, 3dlu, pref, 5dlu"); setLayout(layout);//from w w w.ja v a 2s.co m final CellConstraints cc = new CellConstraints(); final SyllabifierLibrary library = SyllabifierLibrary.getInstance(); final Iterator<Syllabifier> syllabifiers = library.availableSyllabifiers(); final List<Syllabifier> syllabifierList = new ArrayList<Syllabifier>(); while (syllabifiers.hasNext()) syllabifierList.add(syllabifiers.next()); Collections.sort(syllabifierList, new SyllabifierComparator()); this.targetSyllabifierBox = new JComboBox(syllabifierList.toArray(new Syllabifier[0])); final Syllabifier selectedSyllabifier = library.getSyllabifierForLanguage( syllabifierInfo.getSyllabifierLanguageForTier(SystemTierType.IPATarget.getName())); this.targetSyllabifierBox.setSelectedItem(selectedSyllabifier); this.targetSyllabifierBox.setRenderer(new SyllabifierCellRenderer()); this.actualSyllabifierBox = new JComboBox(syllabifierList.toArray(new Syllabifier[0])); this.actualSyllabifierBox.setSelectedItem(library.getSyllabifierForLanguage( syllabifierInfo.getSyllabifierLanguageForTier(SystemTierType.IPAActual.getName()))); this.actualSyllabifierBox.setRenderer(new SyllabifierCellRenderer()); add(new JLabel("Target syllabifier:"), cc.xy(1, 2)); add(targetSyllabifierBox, cc.xy(2, 2)); add(new JLabel("Actual syllabifier:"), cc.xy(1, 4)); add(actualSyllabifierBox, cc.xy(2, 4)); }
From source file:ca.phon.app.session.editor.view.tier_management.TierInfoEditor.java
License:Open Source License
private void init() { FormLayout layout = new FormLayout("5dlu, pref, 3dlu, fill:pref:grow, 5dlu", "pref, 3dlu, pref, 3dlu, pref, pref"); CellConstraints cc = new CellConstraints(); setLayout(layout);//from www . j a v a 2s . c o m add(new JLabel("Tier Name"), cc.xy(2, 1)); nameField = new JTextField(); add(nameField, cc.xy(4, 1)); groupBox = new JCheckBox("Grouped (word-aligned)"); groupBox.setEnabled(!editMode); add(groupBox, cc.xy(4, 3)); final PhonUIAction defaultFontAction = new PhonUIAction(this, "useDefaultFont"); defaultFontAction.putValue(PhonUIAction.NAME, "Use default font"); defaultFontAction.putValue(PhonUIAction.SHORT_DESCRIPTION, "Use default tier font set in Preferences"); useDefaultFontButton = new JButton(defaultFontAction); fontPanel = new JFontPanel(); fontPanel.setSelectedFont(FontPreferences.getTierFont()); add(new JLabel("Font"), cc.xy(2, 5)); add(useDefaultFontButton, cc.xy(4, 5)); add(fontPanel, cc.xy(4, 6)); }
From source file:ca.phon.app.session.editor.view.tier_management.TierOrderingEditorView.java
License:Open Source License
private void init() { final SessionEditor sessionEditor = getEditor(); final Session session = sessionEditor.getSession(); final TierOrderingTableModel tableModel = new TierOrderingTableModel(session, getCurrentOrder()) { private static final long serialVersionUID = 1L; @Override/*from ww w . j av a 2s . com*/ public void setValueAt(Object aValue, int rowIndex, int columnIndex) { super.setValueAt(aValue, rowIndex, columnIndex); if (columnIndex == TierOrderingTableModel.TierOrderingTableColumn.SHOW_TIER.ordinal()) { toggleTierVisible(rowIndex); } else if (columnIndex == TierOrderingTableModel.TierOrderingTableColumn.LOCK_TIER.ordinal()) { toggleTierLocked(rowIndex); } } }; tierOrderingTable = new JXTable(tableModel); // tierOrderingTable = new JXTable(new TierOrderingTableModel(getModel().getSession(), tierOrder)); tierOrderingTable.setSortable(false); tierOrderingTable.setVisibleRowCount(5); tierOrderingTable.addMouseListener(new TierContextMenuListener()); tierOrderingTable.getColumn(TierOrderingTableModel.TierOrderingTableColumn.GROUP_TIER.ordinal()) .setCellRenderer(new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel retVal = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); Boolean val = (Boolean) value; if (val) retVal.setText("Yes"); else retVal.setText("No"); return retVal; } }); // setup tier odering table action map ActionMap tierOrderActionMap = new ActionMap(); ComponentInputMap tableInputMap = new ComponentInputMap(tierOrderingTable); final PhonUIAction deleteAction = new PhonUIAction(this, "onDeleteTier"); deleteAction.putValue(PhonUIAction.SHORT_DESCRIPTION, "Delete the currently selected tier."); deleteAction.putValue(PhonUIAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)); tierOrderActionMap.put("DELETE_TIER", deleteAction); tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DELETE_TIER"); tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "DELETE_TIER"); tierOrderingTable.setActionMap(tierOrderActionMap); tierOrderingTable.setInputMap(WHEN_FOCUSED, tableInputMap); final NewTierAction addAction = new NewTierAction(getEditor(), this); newTierButton = new JButton(addAction); newTierButton.setFocusable(false); final ImageIcon removeIcon = IconManager.getInstance().getIcon("actions/list-remove", IconSize.XSMALL); deleteAction.putValue(PhonUIAction.SMALL_ICON, removeIcon); deleteTierButton = new JButton(deleteAction); deleteTierButton.setFocusable(false); final ImageIcon upIcon = IconManager.getInstance().getIcon("actions/go-up", IconSize.SMALL); final PhonUIAction upAction = new PhonUIAction(this, "moveUp"); upAction.putValue(PhonUIAction.SHORT_DESCRIPTION, "Move tier up"); upAction.putValue(PhonUIAction.SMALL_ICON, upIcon); moveUpButton = new JButton(upAction); moveUpButton.setFocusable(false); final ImageIcon downIcon = IconManager.getInstance().getIcon("actions/go-down", IconSize.SMALL); final PhonUIAction downAction = new PhonUIAction(this, "moveDown"); downAction.putValue(PhonUIAction.SHORT_DESCRIPTION, "Move tier down"); downAction.putValue(PhonUIAction.SMALL_ICON, downIcon); moveDownButton = new JButton(downAction); moveDownButton.setFocusable(false); final ImageIcon fontIcon = IconManager.getInstance().getIcon("actions/edit", IconSize.SMALL); final PhonUIAction fontAction = new PhonUIAction(this, "onEditTier"); fontAction.putValue(PhonUIAction.NAME, "Edit tier..."); fontAction.putValue(PhonUIAction.SHORT_DESCRIPTION, "Edit tier..."); fontAction.putValue(PhonUIAction.SMALL_ICON, fontIcon); editButton = new JButton(fontAction); editButton.setFocusable(false); final ToggleLockAllTiersAction lockAllAction = new ToggleLockAllTiersAction(getEditor(), this); final JButton lockAllButton = new JButton(lockAllAction); final ToggleHideAllTiersAction hideAllAction = new ToggleHideAllTiersAction(getEditor(), this); final JButton hideAllButton = new JButton(hideAllAction); FormLayout layout = new FormLayout("pref, pref, fill:pref:grow, pref, pref, pref", "pref, pref, pref, pref, fill:pref:grow"); CellConstraints cc = new CellConstraints(); setLayout(layout); add(new JScrollPane(tierOrderingTable), cc.xywh(1, 2, 5, 4)); add(moveUpButton, cc.xy(6, 2)); add(moveDownButton, cc.xy(6, 3)); add(editButton, cc.xy(5, 1)); add(newTierButton, cc.xy(4, 1)); add(lockAllButton, cc.xy(1, 1)); add(hideAllButton, cc.xy(2, 1)); }
From source file:ca.phon.app.session.RecordFilterPanel.java
License:Open Source License
private void init() { FormLayout layout = new FormLayout("0px, fill:pref:grow", "pref, 1dlu, pref, pref, 1dlu, pref, pref, 1dlu, pref, pref"); CellConstraints cc = new CellConstraints(); setLayout(layout);/*from ww w .j a va 2 s. com*/ radioGrp = new ButtonGroup(); ButtonAction bAct = new ButtonAction(); allBtn = new JRadioButton("All records"); allBtn.setSelected(true); allBtn.addActionListener(bAct); radioGrp.add(allBtn); rangeBtn = new JRadioButton("Specific records"); rangeBtn.addActionListener(bAct); radioGrp.add(rangeBtn); speakerBtn = new JRadioButton("Records for participant(s)"); speakerBtn.addActionListener(bAct); radioGrp.add(speakerBtn); searchBtn = new JRadioButton("Records from search results"); searchBtn.addActionListener(bAct); radioGrp.add(searchBtn); rangeField = new JTextField(); rangeField.setText("1.." + t.getRecordCount()); rangeField.setInputVerifier(new RangeVerifier()); rangeField.setEnabled(false); speakerTbl = new JXTable(new ParticipantsTableModel()); speakerTbl.setVisibleRowCount(2); speakerTbl.setEnabled(false); searchTbl = new JXTable(new SearchTableModel()); searchTbl.setVisibleRowCount(4); searchTbl.setEnabled(false); searchTbl.getColumn(0).setCellRenderer(new QueryNameCellRenderer()); searchTbl.getColumn(1).setCellRenderer(new DateCellRenderer()); searchTbl.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); searchTbl.getSelectionModel().addListSelectionListener(new SearchListener()); if (searchTbl.getModel().getRowCount() > 0) { searchTbl.getSelectionModel().setSelectionInterval(0, 0); } searchTbl.setSortOrder(1, SortOrder.DESCENDING); // add components add(allBtn, cc.xyw(1, 1, 2)); add(rangeBtn, cc.xyw(1, 3, 2)); add(rangeField, cc.xy(2, 4)); add(speakerBtn, cc.xyw(1, 6, 2)); add(new JScrollPane(speakerTbl), cc.xy(2, 7)); add(searchBtn, cc.xyw(1, 9, 2)); add(new JScrollPane(searchTbl), cc.xy(2, 10)); }
From source file:ca.phon.app.workspace.ProjectButton.java
License:Open Source License
private void refreshComponents() { String colLayout = "fill:pref:grow"; for (int i = 0; i < buttonActions.size(); i++) { colLayout += ", pref" + (i == buttonActions.size() - 1 ? "" : ", 2dlu"); }//from w w w. j a v a 2s .c o m String rowLayout = "top:pref, pref"; setLayout(new FormLayout(colLayout, rowLayout)); CellConstraints cc = new CellConstraints(); updateLabels(); add(projPathLabel, cc.xy(1, 1)); add(projDetailsLabel, cc.xy(1, 2)); int colIdx = 2; for (Action act : buttonActions) { add(getActionButton(act), cc.xywh(colIdx++, 1, 1, 1)); colIdx++; } }
From source file:ca.phon.app.workspace.WorkspaceDialog.java
License:Open Source License
private void init() { setLayout(new BorderLayout()); JXPanel mainPanel = new JXPanel(new BorderLayout()); mainPanel.setBackgroundPainter(new PanelBgPainter()); DialogHeader header = new DialogHeader("Workspace", "Manage your project files."); mainPanel.add(header, BorderLayout.NORTH); newProjectButton = createNewButton(); createProjectButton = createCreateButton(); browseProjectButton = createBrowseButton(); extractProjectButton = createExtractButton(); openPrefsButton = createPrefsButton(); mediaPrefsButton = createMediaButton(); workspaceActionsContainer = new JXPanel(new FormLayout("fill:default:grow", "pref,pref")); CellConstraints cc = new CellConstraints(); workspaceActionsContainer.add(newProjectButton, cc.xy(1, 1)); workspaceActionsContainer.add(extractProjectButton, cc.xy(1, 2)); workspaceActionsContainer.setBackground(Color.white); workspaceActionsContainer.setOpaque(true); workspaceActionsContainer.setBackgroundPainter(new PanelBgPainter()); otherActionsContainer = new JXPanel(new FormLayout("fill:default:grow", "pref,pref,pref")); otherActionsContainer.add(browseProjectButton, cc.xy(1, 1)); otherActionsContainer.add(openPrefsButton, cc.xy(1, 3)); otherActionsContainer.add(mediaPrefsButton, cc.xy(1, 2)); otherActionsContainer.setBackground(Color.white); otherActionsContainer.setOpaque(true); otherActionsContainer.setBackgroundPainter(new PanelBgPainter()); JXTitledPanel actionPanel = new JXTitledPanel("Workspace Actions", workspaceActionsContainer); JXTitledPanel otherActionPanel = new JXTitledPanel("Other Actions", otherActionsContainer); // set a default size that does not change // Dimension prefSize = new Dimension(250, 0); // actionPanel.setPreferredSize(prefSize); // Dimension maxSize = new Dimension(250, Short.MAX_VALUE); // actionPanel.setMaximumSize(maxSize); // Dimension minSize = new Dimension(250, 40); // actionPanel.setMinimumSize(minSize); // actionPanel.setTitleFont(actionPanel.getTitleFont().deriveFont(Font.BOLD, 14.0f)); // tabPanel = new TabbedPanel(); workspacePanel = new WorkspaceProjectsPanel(); // ShapedGradientTheme gradientTheme = new ShapedGradientTheme(); // JTabbedPane tabbedPane = new JTabbedPane(); // tabbedPane.addTab("Workspace", workspacePanel); // TitledTab workspaceTab = new TitledTab("Workspace", null, workspacePanel, null); // workspaceTab.getProperties().addSuperObject(gradientTheme.getTitledTabProperties()); //// workspaceTab.getProp // tabPanel.addTab(workspaceTab); // tabPanel.getProperties(). // addSuperObject(gradientTheme.getTabbedPanelProperties()); // tabPanel.getProperties().setTabAreaOrientation(Direction.DOWN); JPanel leftPanel = new JPanel(new FormLayout("250", "pref,fill:pref:grow")); leftPanel.add(actionPanel, cc.xy(1, 1)); leftPanel.add(otherActionPanel, cc.xy(1, 2)); mainPanel.add(leftPanel, BorderLayout.WEST); mainPanel.add(workspacePanel, BorderLayout.CENTER); add(mainPanel, BorderLayout.CENTER); }
From source file:ca.phon.app.workspace.WorkspaceDialog.java
License:Open Source License
public void onSwapNewAndCreate(PhonActionEvent pae) { boolean swapNew = (pae.getData() == newProjectButton); CellConstraints cc = new CellConstraints(); if (swapNew) { workspaceActionsContainer.remove(newProjectButton); workspaceActionsContainer.add(createProjectButton, cc.xy(1, 1)); workspaceActionsContainer.revalidate(); createProjectButton.repaint();// w w w . j a v a 2 s . c om createProjectButton.requestFocus(); } else { workspaceActionsContainer.remove(createProjectButton); workspaceActionsContainer.add(newProjectButton, cc.xy(1, 1)); workspaceActionsContainer.revalidate(); newProjectButton.repaint(); } }
From source file:ca.phon.app.workspace.WorkspaceDialog.java
License:Open Source License
public void onExtract(PhonActionEvent pae) { FileFilter archiveFilter = FileFilter.zipFilter; FileFilter[] filters = new FileFilter[] { archiveFilter }; String selectedFile = NativeDialogs.browseForFileBlocking(CommonModuleFrame.getCurrentFrame(), null, ".phon", filters, "Open project archive"); if (selectedFile != null) { ExtractProjectArchiveTask task = new ExtractProjectArchiveTask(new File(selectedFile)); File destDir = task.getDestDir(); if (destDir == null) { NativeDialogs.showMessageDialogBlocking(CommonModuleFrame.getCurrentFrame(), null, "Not a project archive", "'" + selectedFile + "' does not contain a phon project"); return; }//from ww w . j a v a 2s . c om final PhonTaskButton taskBtn = new PhonTaskButton(task); taskBtn.setSize(extractProjectButton.getSize()); taskBtn.setPreferredSize(extractProjectButton.getPreferredSize()); CellConstraints cc = new CellConstraints(); workspaceActionsContainer.remove(extractProjectButton); workspaceActionsContainer.add(taskBtn, cc.xy(1, 2)); workspaceActionsContainer.revalidate(); workspaceActionsContainer.repaint(); task.addTaskListener(new PhonTaskListener() { @Override public void statusChanged(PhonTask task, TaskStatus oldStatus, TaskStatus newStatus) { if (newStatus == TaskStatus.FINISHED) { long startTime = task.getStartTime(); long curTime = System.currentTimeMillis(); long totalTime = curTime - startTime; if (totalTime < 500) { try { Thread.sleep(500 - totalTime); } catch (InterruptedException e) { } } // swap buttons back final Runnable onEDT = new Runnable() { public void run() { workspacePanel.refresh(); CellConstraints cc = new CellConstraints(); workspaceActionsContainer.remove(taskBtn); workspaceActionsContainer.add(extractProjectButton, cc.xy(1, 2)); workspaceActionsContainer.revalidate(); extractProjectButton.repaint(); } }; SwingUtilities.invokeLater(onEDT); } } @Override public void propertyChanged(PhonTask task, String property, Object oldValue, Object newValue) { // TODO Auto-generated method stub } }); PhonWorker.getInstance().invokeLater(task); } }