List of usage examples for com.jgoodies.forms.layout CellConstraints xy
public CellConstraints xy(int col, int row)
Examples:
cc.xy(1, 1); cc.xy(1, 3);
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/* w w w. j ava 2 s . c o m*/ 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 w w w .j a v a 2s . c om*/ 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 ww . jav a 2 s . 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();/* ww w .j a v a 2s.co m*/ 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 w w w. j a va 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); } }
From source file:ca.phon.csv2phon.wizard.DirectoryStep.java
License:Open Source License
private void init() { setLayout(new BorderLayout()); header = new DialogHeader("CSV Import", "Select folder containing csv files."); add(header, BorderLayout.NORTH); JPanel centerPanel = new JPanel(); centerPanel.setBorder(BorderFactory.createTitledBorder("Folder")); FormLayout layout = new FormLayout("right:pref, 3dlu, fill:pref:grow, pref", "pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref"); CellConstraints cc = new CellConstraints(); centerPanel.setLayout(layout);/*from www . ja v a 2 s . co m*/ String lblTxt = "<html><body><p>Please select the folder containing the csv files for import." + " <font color='red'>All csv files should have the same column structure and encoding</font>.</p></body></html>"; infoLbl = new JLabel(lblTxt); centerPanel.add(infoLbl, cc.xyw(1, 1, 3)); csvDirField = new FileSelectionField(); csvDirField.setMode(SelectionMode.FOLDERS); csvDirField.getTextField().setEditable(false); // setup charset chooser SortedMap<String, Charset> availableCharset = Charset.availableCharsets(); charsetBox = new JComboBox(availableCharset.keySet().toArray(new String[0])); charsetBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { charsetName = charsetBox.getSelectedItem().toString(); } } }); charsetBox.setSelectedItem("UTF-8"); textDelimField = new JTextField(); textDelimField.setDocument(new SingleCharDocument()); textDelimField.setText(textDelim + ""); fieldDelimField = new JTextField(); fieldDelimField.setDocument(new SingleCharDocument()); fieldDelimField.setText(fieldDelim + ""); centerPanel.add(new JLabel("Folder:"), cc.xy(1, 3)); centerPanel.add(csvDirField, cc.xyw(3, 3, 2)); centerPanel.add(new JLabel("File encoding:"), cc.xy(1, 5)); centerPanel.add(charsetBox, cc.xy(3, 5)); centerPanel.add(new JLabel("Field delimiter:"), cc.xy(1, 7)); centerPanel.add(fieldDelimField, cc.xy(3, 7)); centerPanel.add(new JLabel("Text delimiter:"), cc.xy(1, 9)); centerPanel.add(textDelimField, cc.xy(3, 9)); add(centerPanel, BorderLayout.CENTER); }
From source file:ca.phon.csv2phon.wizard.ParticipantsStep.java
License:Open Source License
private void init() { setLayout(new BorderLayout()); header = new DialogHeader("CSV Import", "Set up participants."); add(header, BorderLayout.NORTH); FormLayout participantLayout = new FormLayout("fill:pref:grow, 1dlu, pref", "pref, 3dlu, pref, 3dlu, pref, fill:pref:grow"); CellConstraints cc = new CellConstraints(); JPanel participantPanel = new JPanel(participantLayout); participantPanel.setBorder(BorderFactory.createTitledBorder("Participants")); JLabel infoLabel = new JLabel( "<html><body><p>(Optional) Set up participants which will be added to each imported session.</p></body></html>"); participantTable = new JXTable(); ImageIcon addIcon = IconManager.getInstance().getIcon("actions/list-add", IconSize.XSMALL); addParticipantButton = new JButton(addIcon); addParticipantButton.setFocusable(false); addParticipantButton.setToolTipText("Add participant"); addParticipantButton.addActionListener(new ActionListener() { @Override/*from ww w.j a v a 2 s.c o m*/ public void actionPerformed(ActionEvent e) { newParticipant(); } }); ImageIcon editIcon = IconManager.getInstance().getIcon("actions/edit", IconSize.XSMALL); editParticipantButton = new JButton(editIcon); editParticipantButton.setFocusable(false); editParticipantButton.setToolTipText("Edit participant"); editParticipantButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editParticipant(); } }); Action deleteParticipantAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { deleteParticipant(); } }; ActionMap participantActionMap = participantTable.getActionMap(); participantActionMap.put("DELETE_PARTICIPANT", deleteParticipantAction); InputMap participantInputMap = participantTable.getInputMap(); participantInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "DELETE_PARTICIPANT"); participantInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DELETE_PARTICIPANT"); participantTable.setActionMap(participantActionMap); participantTable.setInputMap(JComponent.WHEN_FOCUSED, participantInputMap); participantPanel.add(infoLabel, cc.xy(1, 1)); participantPanel.add(new JScrollPane(participantTable), cc.xywh(1, 3, 1, 4)); participantPanel.add(addParticipantButton, cc.xy(3, 3)); participantPanel.add(editParticipantButton, cc.xy(3, 5)); add(participantPanel, BorderLayout.CENTER); }
From source file:ca.phon.ipamap.IpaMap.java
License:Open Source License
/** * Create the context menu based on source component *///w w w . j a v a 2 s.c om public void setupContextMenu(JPopupMenu menu, JComponent comp) { final CommonModuleFrame parentFrame = (CommonModuleFrame) SwingUtilities .getAncestorOfClass(CommonModuleFrame.class, comp); if (parentFrame != null) { final PhonUIAction toggleAlwaysOnTopAct = new PhonUIAction(parentFrame, "setAlwaysOnTop", !parentFrame.isAlwaysOnTop()); toggleAlwaysOnTopAct.putValue(PhonUIAction.NAME, "Always on top"); toggleAlwaysOnTopAct.putValue(PhonUIAction.SELECTED_KEY, parentFrame.isAlwaysOnTop()); final JCheckBoxMenuItem toggleAlwaysOnTopItem = new JCheckBoxMenuItem(toggleAlwaysOnTopAct); menu.add(toggleAlwaysOnTopItem); } // button options first if (comp instanceof CellButton) { CellButton btn = (CellButton) comp; Cell cell = btn.cell; // copy to clipboard options String cellData = cell.getText().replaceAll("" + (char) 0x25cc, ""); PhonUIAction copyToClipboardAct = new PhonUIAction(this, "onCopyToClipboard", cellData); copyToClipboardAct.putValue(PhonUIAction.NAME, "Copy character (" + cell.getText() + ")"); JMenuItem copyToClipboardItem = new JMenuItem(copyToClipboardAct); menu.add(copyToClipboardItem); String htmlVal = new String(); for (Character c : cellData.toCharArray()) { htmlVal += "&#" + (int) c + ";"; } PhonUIAction copyHTMLToClipboardAct = new PhonUIAction(this, "onCopyToClipboard", htmlVal); copyHTMLToClipboardAct.putValue(PhonUIAction.NAME, "Copy as HTML (" + htmlVal + ")"); JMenuItem copyHTMLToClipboardItem = new JMenuItem(copyHTMLToClipboardAct); menu.add(copyHTMLToClipboardItem); String hexVal = new String(); for (Character c : cellData.toCharArray()) { hexVal += (hexVal.length() > 0 ? " " : "") + Integer.toHexString((int) c); } hexVal = hexVal.toUpperCase(); PhonUIAction copyHEXToClipboardAct = new PhonUIAction(this, "onCopyToClipboard", hexVal); copyHEXToClipboardAct.putValue(PhonUIAction.NAME, "Copy as Unicode HEX (" + hexVal + ")"); JMenuItem copyHEXToClipboardItem = new JMenuItem(copyHEXToClipboardAct); menu.add(copyHEXToClipboardItem); menu.addSeparator(); if (isInFavorites(cell)) { PhonUIAction removeFromFavAct = new PhonUIAction(this, "onRemoveCellFromFavorites", cell); removeFromFavAct.putValue(Action.NAME, "Remove from favorites"); removeFromFavAct.putValue(Action.SHORT_DESCRIPTION, "Remove button from list of favorites"); JMenuItem removeFromFavItem = new JMenuItem(removeFromFavAct); menu.add(removeFromFavItem); } else { PhonUIAction addToFavAct = new PhonUIAction(this, "onAddCellToFavorites", cell); addToFavAct.putValue(Action.NAME, "Add to favorites"); addToFavAct.putValue(Action.SHORT_DESCRIPTION, "Add button to list of favorites"); JMenuItem addToFavItem = new JMenuItem(addToFavAct); menu.add(addToFavItem); } menu.addSeparator(); } // section scroll-tos JMenuItem gotoTitleItem = new JMenuItem("Scroll to:"); gotoTitleItem.setEnabled(false); menu.add(gotoTitleItem); for (JXButton toggleBtn : toggleButtons) { PhonUIAction gotoAct = new PhonUIAction(this, "onGoto", toggleBtn); gotoAct.putValue(Action.NAME, toggleBtn.getText()); gotoAct.putValue(Action.SHORT_DESCRIPTION, "Scroll to " + toggleBtn.getText()); JMenuItem gotoItem = new JMenuItem(gotoAct); menu.add(gotoItem); } menu.addSeparator(); // setup font scaler final JLabel smallLbl = new JLabel("A"); smallLbl.setFont(getFont().deriveFont(12.0f)); smallLbl.setHorizontalAlignment(SwingConstants.CENTER); JLabel largeLbl = new JLabel("A"); largeLbl.setFont(getFont().deriveFont(24.0f)); largeLbl.setHorizontalAlignment(SwingConstants.CENTER); final JSlider scaleSlider = new JSlider(1, 101); scaleSlider.setValue((int) (scale * 100)); scaleSlider.setMajorTickSpacing(20); scaleSlider.setMinorTickSpacing(10); scaleSlider.setSnapToTicks(true); scaleSlider.setPaintTicks(true); scaleSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { int sliderVal = scaleSlider.getValue(); float scale = (float) sliderVal / (float) 100; _cFont = null; setSavedScale(scale); setScale(scale); } }); FormLayout scaleLayout = new FormLayout("3dlu, center:pref, fill:pref:grow, center:pref, 3dlu", "pref"); CellConstraints cc = new CellConstraints(); JPanel scalePanel = new JPanel(scaleLayout) { @Override public Insets getInsets() { Insets retVal = super.getInsets(); retVal.left += UIManager.getIcon("Tree.collapsedIcon").getIconWidth(); return retVal; } }; scalePanel.add(smallLbl, cc.xy(2, 1)); scalePanel.add(scaleSlider, cc.xy(3, 1)); scalePanel.add(largeLbl, cc.xy(4, 1)); JMenuItem scaleItem = new JMenuItem("Font size"); scaleItem.setEnabled(false); menu.add(scaleItem); menu.add(scalePanel); menu.addSeparator(); // highlighting PhonUIAction onToggleHighlightAct = new PhonUIAction(this, "onToggleHighlightRecent"); onToggleHighlightAct.putValue(PhonUIAction.NAME, "Highlight recently used"); onToggleHighlightAct.putValue(PhonUIAction.SELECTED_KEY, isHighlightRecent()); JCheckBoxMenuItem onToggleHighlightItm = new JCheckBoxMenuItem(onToggleHighlightAct); menu.add(onToggleHighlightItm); }
From source file:ca.phon.media.export.MediaExportPanel.java
License:Open Source License
private void init() { final FileFilter fileFilter = FileFilter.mediaFilter; inputFileField = new FileSelectionField(); inputFileField.setFileFilter(fileFilter); inputFileField.getTextField().setPrompt("Input file"); if (exporter.getInputFile() != null) inputFileField.setFile(exporter.getInputFile()); outputFileField = new FileSelectionField(); outputFileField.setFileFilter(fileFilter); outputFileField.getTextField().setPrompt("Output file"); if (exporter.getOutputFile() != null) outputFileField.setFile(exporter.getOutputFile()); final Formatter<Float> timeFormatter = new Formatter<Float>() { @Override//from w w w . j a v a 2 s. c o m public Float parse(String text) throws ParseException { Float retVal = new Float(0.0f); try { retVal = Float.parseFloat(text); } catch (NullPointerException | NumberFormatException e) { throw new ParseException(text, 0); } return retVal; } @Override public String format(Float obj) { final NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(3); return format.format(obj); } }; startTimeField = new FormatterTextField<>(timeFormatter); startTimeField.setPrompt("Enter start time in seconds, leave empty to start at beginning of media"); if (exporter.getMediaStartTime() > 0) startTimeField.setValue(exporter.getMediaStartTime()); stopTimeField = new FormatterTextField<>(timeFormatter); stopTimeField.setPrompt("Enter stop time in seconds, leave empty to stop at end of media"); if (exporter.getMediaStopTime() > 0) stopTimeField.setValue(exporter.getMediaStopTime()); duplicateButton = new JRadioButton("Keep original media encoding"); transcodeButton = new JRadioButton("Transcode media"); final ButtonGroup btnGroup = new ButtonGroup(); btnGroup.add(duplicateButton); btnGroup.add(transcodeButton); duplicateButton.setSelected(true); presetBox = new JComboBox<>(VLCMediaExporter.Preset.values()); advancedPanel = new JXCollapsiblePane(Direction.DOWN); advancedPanel.setLayout(new VerticalLayout()); optionsPane = new JTextPane(); advancedPanel.add(optionsPane); final JPanel btmPanel = new JPanel(new VerticalLayout()); final Action toggleAction = advancedPanel.getActionMap().get(JXCollapsiblePane.TOGGLE_ACTION); toggleAction.putValue(Action.NAME, "Advanced"); toggleAction.putValue(JXCollapsiblePane.COLLAPSE_ICON, UIManager.getIcon("Tree.expandedIcon")); toggleAction.putValue(JXCollapsiblePane.EXPAND_ICON, UIManager.getIcon("Tree.collapsedIcon")); final JButton toggleBtn = new JButton(toggleAction); btmPanel.add(toggleBtn); btmPanel.add(advancedPanel); // file selection panel final FormLayout fileSelectionLayout = new FormLayout("pref, 3dlu, fill:pref:grow", "pref, pref"); final CellConstraints cc = new CellConstraints(); final JPanel fileSelectionPanel = new JPanel(fileSelectionLayout); fileSelectionPanel.setBorder(BorderFactory.createTitledBorder("File Selection")); fileSelectionPanel.add(new JLabel("Input file"), cc.xy(1, 1)); fileSelectionPanel.add(inputFileField, cc.xy(3, 1)); fileSelectionPanel.add(new JLabel("Output file"), cc.xy(1, 2)); fileSelectionPanel.add(outputFileField, cc.xy(3, 2)); // time selection panel }