List of usage examples for java.awt.event ComponentAdapter ComponentAdapter
ComponentAdapter
From source file:com.vgi.mafscaling.ClosedLoop.java
private JTable createAfrDataTable(JPanel panel, String tableName, int gridy) { final JTable afrTable = new JTable() { private static final long serialVersionUID = 6526901361175099297L; public boolean isCellEditable(int row, int column) { return false; };//from ww w.j a v a 2 s . c o m }; DefaultTableColumnModel afrModel = new DefaultTableColumnModel(); final TableColumn afrColumn = new TableColumn(0, 250); afrColumn.setHeaderValue(tableName); afrModel.addColumn(afrColumn); JTableHeader lblAfrTableName = afrTable.getTableHeader(); lblAfrTableName.setColumnModel(afrModel); lblAfrTableName.setReorderingAllowed(false); DefaultTableCellRenderer headerRenderer = (DefaultTableCellRenderer) lblAfrTableName.getDefaultRenderer(); headerRenderer.setHorizontalAlignment(SwingConstants.LEFT); GridBagConstraints gbc_lblAfrTableName = new GridBagConstraints(); gbc_lblAfrTableName.insets = new Insets((gridy == 0 ? 0 : 5), 0, 0, 0); gbc_lblAfrTableName.anchor = GridBagConstraints.PAGE_START; gbc_lblAfrTableName.fill = GridBagConstraints.HORIZONTAL; gbc_lblAfrTableName.gridx = 0; gbc_lblAfrTableName.gridy = gridy; panel.add(lblAfrTableName, gbc_lblAfrTableName); afrTable.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { afrColumn.setWidth(afrTable.getWidth()); } }); afrTable.getTableHeader().setReorderingAllowed(false); afrTable.setColumnSelectionAllowed(true); afrTable.setCellSelectionEnabled(true); afrTable.setBorder(new LineBorder(new Color(0, 0, 0))); afrTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); afrTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); afrTable.setModel(new DefaultTableModel(AfrTableRowCount, AfrTableColumnCount)); Utils.initializeTable(afrTable, ColumnWidth); if (tableName.equals(Afr1TableName)) { Format[][] formatMatrix = { { new DecimalFormat("#"), new DecimalFormat("0.00") } }; NumberFormatRenderer renderer = (NumberFormatRenderer) afrTable.getDefaultRenderer(Object.class); renderer.setFormats(formatMatrix); } else if (tableName.equals(Afr2TableName)) { Format[][] formatMatrix = { { new DecimalFormat("#"), new DecimalFormat("0.00") }, { new DecimalFormat("#"), new DecimalFormat("#") } }; NumberFormatRenderer renderer = (NumberFormatRenderer) afrTable.getDefaultRenderer(Object.class); renderer.setFormats(formatMatrix); } GridBagConstraints gbc_afrTable = new GridBagConstraints(); gbc_afrTable.insets = new Insets(0, 0, 0, 0); gbc_afrTable.anchor = GridBagConstraints.PAGE_START; gbc_afrTable.gridx = 0; gbc_afrTable.gridy = gridy + 1; panel.add(afrTable, gbc_afrTable); excelAdapter.addTable(afrTable, true, false); return afrTable; }
From source file:de.mprengemann.intellij.plugin.androidicons.dialogs.AndroidBatchScaleImporter.java
private void initColumnSizes() { table.addComponentListener(new ComponentAdapter() { @Override/*w w w .j av a2s . c o m*/ public void componentResized(ComponentEvent componentEvent) { super.componentResized(componentEvent); Dimension tableSize = table.getSize(); final int[] columnSizes = new int[] { 20, 20, 20, 40 }; for (int i = 0; i < table.getColumnCount(); i++) { TableColumn column = table.getColumnModel().getColumn(i); column.setPreferredWidth((int) (tableSize.width * (columnSizes[i] / 100f))); } } }); }
From source file:shuffle.fwk.service.teams.EditTeamService.java
@Override protected void onLaunch() { d.addComponentListener(new ComponentAdapter() { @Override//from w w w . j a va 2 s .c om public void componentResized(ComponentEvent ev) { ConfigManager preferencesManager = getUser().getPreferencesManager(); Dimension dim = d.getSize(); preferencesManager.setEntry(EntryType.INTEGER, KEY_EDIT_TEAM_WIDTH, dim.width); preferencesManager.setEntry(EntryType.INTEGER, KEY_EDIT_TEAM_HEIGHT, dim.height); } }); }
From source file:org.zeromeaner.gui.reskin.StandaloneFrame.java
private void createCards() { introPanel = new StandaloneLicensePanel(); content.add(introPanel, CARD_INTRO); playCard = new JPanel(new BorderLayout()); content.add(playCard, CARD_PLAY);//w w w . j a va 2s . c o m JPanel confirm = new JPanel(new GridBagLayout()); JOptionPane option = new JOptionPane("A game is in open. End this game?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); option.addPropertyChangeListener(JOptionPane.VALUE_PROPERTY, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!CARD_PLAY_END.equals(currentCard)) return; if (evt.getNewValue().equals(JOptionPane.YES_OPTION)) { gamePanel.shutdown(); try { gamePanel.shutdownWait(); } catch (InterruptedException ie) { } contentCards.show(content, nextCard); currentCard = nextCard; } if (evt.getNewValue().equals(JOptionPane.NO_OPTION)) { contentCards.show(content, CARD_PLAY); currentCard = CARD_PLAY; playButton.setSelected(true); } ((JOptionPane) evt.getSource()).setValue(-1); } }); GridBagConstraints cx = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0); confirm.add(option, cx); content.add(confirm, CARD_PLAY_END); content.add(new StandaloneModeselectPanel(), CARD_MODESELECT); netplayCard = new JPanel(new BorderLayout()); netplayCard.add(netLobby, BorderLayout.SOUTH); content.add(netplayCard, CARD_NETPLAY); confirm = new JPanel(new GridBagLayout()); option = new JOptionPane("A netplay game is open. End this game and disconnect?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); option.addPropertyChangeListener(JOptionPane.VALUE_PROPERTY, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!CARD_NETPLAY_END.equals(currentCard)) return; if (evt.getNewValue().equals(JOptionPane.YES_OPTION)) { gamePanel.shutdown(); try { gamePanel.shutdownWait(); } catch (InterruptedException ie) { } netLobby.disconnect(); contentCards.show(content, nextCard); currentCard = nextCard; } if (evt.getNewValue().equals(JOptionPane.NO_OPTION)) { contentCards.show(content, CARD_NETPLAY); currentCard = CARD_NETPLAY; netplayButton.setSelected(true); } ((JOptionPane) evt.getSource()).setValue(-1); } }); cx = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0); confirm.add(option, cx); content.add(confirm, CARD_NETPLAY_END); StandaloneKeyConfig kc = new StandaloneKeyConfig(this); kc.load(0); content.add(kc, CARD_KEYS_1P); kc = new StandaloneKeyConfig(this); kc.load(1); content.add(kc, CARD_KEYS_2P); StandaloneGameTuningPanel gt = new StandaloneGameTuningPanel(); gt.load(0); content.add(gt, CARD_TUNING_1P); gt = new StandaloneGameTuningPanel(); gt.load(1); content.add(gt, CARD_TUNING_2P); StandaloneAISelectPanel ai = new StandaloneAISelectPanel(); ai.load(0); content.add(ai, CARD_AI_1P); ai = new StandaloneAISelectPanel(); ai.load(1); content.add(ai, CARD_AI_2P); StandaloneGeneralConfigPanel gc = new StandaloneGeneralConfigPanel(); gc.load(); content.add(gc, CARD_GENERAL); final JFileChooser fc = FileSystemViews.get().fileChooser("replay/"); fc.setFileFilter(new FileFilter() { @Override public String getDescription() { return "Zeromeaner Replay Files"; } @Override public boolean accept(File f) { return f.isDirectory() || f.getName().endsWith(".zrep"); } }); fc.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!e.getActionCommand().equals(JFileChooser.APPROVE_SELECTION)) return; JFileChooser fc = (JFileChooser) e.getSource(); String path = fc.getSelectedFile().getPath(); if (!path.contains("replay/")) path = "replay/" + path; startReplayGame(path); } }); fc.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { fc.rescanCurrentDirectory(); } }); content.add(fc, CARD_OPEN); content.add(new StandaloneFeedbackPanel(), CARD_FEEDBACK); }
From source file:org.interreg.docexplore.authoring.AuthoringToolFrame.java
public AuthoringToolFrame(final DocExploreDataLink link, final Startup startup) throws Exception { super("Authoring Tool"); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.startup = startup; this.displayHelp = startup.showHelp; startup.screen.setText("Initializing history"); this.historyManager = new HistoryManager(50, new File(DocExploreTool.getHomeDir(), ".at-cache")); this.historyDialog = new JDialog(this, XMLResourceBundle.getBundledString("generalHistory")); historyDialog.add(new HistoryPanel(historyManager)); historyDialog.pack();//www .j av a 2 s.c o m setJMenuBar(this.menu = new AuthoringMenu(this)); startup.screen.setText("Initializing plugins"); plugins = new Vector<MetaDataPlugin>(); List<PluginConfig> pluginConfigs = startup.filterPlugins(MetaDataPlugin.class); for (PluginConfig config : pluginConfigs) { MetaDataPlugin plugin = null; if ((plugin = (MetaDataPlugin) config.clazz.newInstance()) != null) { plugins.add(plugin); plugin.setHost(config.jarFile, config.dependencies); System.out.println( "Loaded plugin '" + plugin.getName() + "' (" + plugin.getClass().getSimpleName() + ")"); } } startup.screen.setText("Initializing filters"); //filter = new FilterPanel(link); this.importOptions = new ImportOptions(this); startup.screen.setText("Initializing styles"); this.styleManager = new StyleManager(this); startup.screen.setText("Creating explorer data link"); this.linkExplorer = new DataLinkExplorer(this, link, null); //linkExplorer.toolPanel.add(filter); //linkExplorer.setFilter(filter); startup.screen.setText("Creating explorer"); //this.fileExplorer = new FileExplorer(this); this.explorer = new JPanel(new BorderLayout()); explorer.add( new JLabel("<html><font style=\"font-size:16\">" + XMLResourceBundle.getBundledString("generalLibraryLabel") + "</font></html>"), BorderLayout.NORTH); explorer.add(linkExplorer, BorderLayout.CENTER); //explorer.addTab(XMLResourceBundle.getBundledString("generalFilesLabel"), fileExplorer); startup.screen.setText("Creating editor data link"); recovery = defaultFile.exists(); DataLink fslink = new DataLinkFS2Source(defaultFile.getAbsolutePath()).getDataLink(); fslink.setProperty("autoWrite", false); final DocExploreDataLink editorLink = new DocExploreDataLink(); final JLabel titleLabel = new JLabel(); editorLink.addListener(new DocExploreDataLink.Listener() { public void dataLinkChanged(DataLink link) { String bookName = ""; try { List<Integer> books = editorLink.getLink().getAllBookIds(); if (!books.isEmpty()) { Book book = editorLink.getBook(books.get(0)); bookName = book.getName(); MetaDataKey key = editorLink.getOrCreateKey("styles", ""); List<MetaData> mds = book.getMetaDataListForKey(key); MetaData md = null; if (mds.isEmpty()) { md = new MetaData(editorLink, key, ""); book.addMetaData(md); } else md = mds.get(0); styleManager.setMD(md); } } catch (Exception e) { e.printStackTrace(); } String linkTitle = menu.curFile == null ? null : menu.curFile.getAbsolutePath(); titleLabel.setText("<html><font style=\"font-size:14\">" + XMLResourceBundle.getBundledString("generalPresentationLabel") + " : <b>" + bookName + "</b>" + (linkTitle != null ? " (" + linkTitle + ")" : "") + "</font></html>"); setTitle(XMLResourceBundle.getBundledString("frameTitle") + " " + (linkTitle != null ? linkTitle : "")); historyManager.reset(-1); repaint(); } }); editorLink.setLink(fslink); startup.screen.setText("Creating editor"); this.editor = new DataLinkExplorer(this, editorLink, new BookImporter()); for (ExplorerView view : editor.views) if (view instanceof PageEditorView) { this.mdEditor = new MetaDataEditor(((PageEditorView) view).editor); } editor.addListener(new Explorer.Listener() { @Override public void exploringChanged(Object object) { try { boolean isRegion = object instanceof Region; int div = splitPane.getDividerLocation(); mdEditor.setDocument(null); if (isRegion) mdEditor.setDocument((Region) object); if (isRegion != regionMode) splitPane.setRightComponent(isRegion ? mdEditor : explorer); regionMode = isRegion; validate(); splitPane.setDividerLocation(div); } catch (Exception e) { ErrorHandler.defaultHandler.submit(e); } } }); final JButton editBook = new JButton(new AbstractAction("", ImageUtils.getIcon("pencil-24x24.png")) { @Override public void actionPerformed(ActionEvent e) { try { Book book = editorLink.getBook(editorLink.getLink().getAllBookIds().get(0)); String name = JOptionPane.showInputDialog(AuthoringToolFrame.this, XMLResourceBundle.getBundledString("collectionAddBookMessage"), book.getName()); if (name == null) return; book.setName(name); editorLink.notifyDataLinkChanged(); editor.refreshPath(); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } }); editBook.setToolTipText(XMLResourceBundle.getBundledString("generalToolbarEdit")); this.splitPane = new JSplitPane(); JPanel editorPanel = new JPanel(new BorderLayout()); JPanel titlePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); titlePanel.add(titleLabel); titlePanel.add(editBook); //editorPanel.add(titlePanel, BorderLayout.NORTH); editorPanel.add(editor, BorderLayout.CENTER); splitPane.setLeftComponent(editorPanel); splitPane.setRightComponent(explorer); getContentPane().setLayout(new BorderLayout()); add(titlePanel, BorderLayout.NORTH); add(splitPane, BorderLayout.CENTER); this.clipboard = new MetaDataClipboard(this, new File(DocExploreTool.getHomeDir(), ".at-clipboard")); startup.screen.setText("Initializing exporter"); this.readerExporter = new ReaderExporter(this); this.webExporter = new WebExporter(this); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { quit(); } public void windowOpened(WindowEvent e) { splitPane.setDividerLocation(getWidth() / 2); } }); this.oldSize = getWidth(); addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { splitPane.setDividerLocation(splitPane.getDividerLocation() * getWidth() / oldSize); oldSize = getWidth(); } }); }
From source file:com.android.tools.idea.uibuilder.handlers.ui.AppBarConfigurationDialog.java
public AppBarConfigurationDialog(@NotNull ViewEditor editor) { myEditor = editor;//from w w w. java 2 s . co m setTitle(DIALOG_TITLE); setContentPane(myContentPane); setModal(true); getRootPane().setDefaultButton(myButtonOK); myBackgroundImage = DEFAULT_BACKGROUND_IMAGE; myFloatingActionButtonImage = DEFAULT_FAB_IMAGE; final ActionListener updatePreviewListener = event -> { updateControls(); generatePreviews(); }; myWithTabs.addActionListener(updatePreviewListener); myTabCount.setValue(3); myCollapsing.addActionListener(updatePreviewListener); myShowBackgroundImage.addActionListener(updatePreviewListener); myFloatingActionButton.addActionListener(updatePreviewListener); myFitStatusBar.addActionListener(updatePreviewListener); myParallax.addActionListener(updatePreviewListener); myContentOverlap.addActionListener(updatePreviewListener); myContentOverlapAmount.addActionListener(updatePreviewListener); ((GridLayoutManager) myPreviewPanel.getLayout()).setRowStretch(0, 2); myTabCount.addChangeListener(event -> generatePreviews()); final ActionListener actionListener = event -> { if (event.getSource() == myBackgroundImageSelector) { String src = myEditor.displayResourceInput(EnumSet.of(ResourceType.DRAWABLE)); if (src != null) { myBackgroundImage = src; generatePreviews(); } } else if (event.getSource() == myFloatingActionButtonImageSelector) { String src = myEditor.displayResourceInput(EnumSet.of(ResourceType.DRAWABLE)); if (src != null) { myFloatingActionButtonImage = src; generatePreviews(); } } else if (event.getSource() == myButtonOK) { onOK(); } else if (event.getSource() == myButtonCancel || event.getSource() == myContentPane) { onCancel(); } }; myBackgroundImageSelector.addActionListener(actionListener); myFloatingActionButtonImageSelector.addActionListener(actionListener); myButtonOK.addActionListener(actionListener); myButtonCancel.addActionListener(actionListener); myContentPane.registerKeyboardAction(actionListener, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); myPreviewPanel.addComponentListener(new ComponentAdapter() { @Override public void componentResized(final ComponentEvent e) { updatePreviewImages(); } }); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { onCancel(); } }); }
From source file:org.omegat.gui.align.AlignPanelController.java
/** * Display the align tool. The tool is not modal, so this call will return immediately. * //from ww w . ja v a 2 s . c o m * @param parent * Parent window of the align tool */ public void show(Component parent) { frame = new AlignMenuFrame(); frame.setTitle(OStrings.getString("ALIGNER_PANEL")); frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { closeFrame(frame); } }); panel = new AlignPanel(); ActionListener comparisonListener = e -> { ComparisonMode newValue = (ComparisonMode) ((JComboBox<?>) e.getSource()).getSelectedItem(); if (newValue != aligner.comparisonMode && confirmReset(frame)) { aligner.comparisonMode = newValue; reloadBeads(); } else { panel.comparisonComboBox.setSelectedItem(aligner.comparisonMode); } }; panel.comparisonComboBox.addActionListener(comparisonListener); panel.comparisonComboBox.setRenderer(new EnumRenderer<ComparisonMode>("ALIGNER_ENUM_COMPARISON_MODE_")); ActionListener algorithmListener = e -> { AlgorithmClass newValue = (AlgorithmClass) ((JComboBox<?>) e.getSource()).getSelectedItem(); if (newValue != aligner.algorithmClass && confirmReset(frame)) { aligner.algorithmClass = newValue; reloadBeads(); } else { panel.algorithmComboBox.setSelectedItem(aligner.algorithmClass); } }; panel.algorithmComboBox.addActionListener(algorithmListener); panel.algorithmComboBox.setRenderer(new EnumRenderer<AlgorithmClass>("ALIGNER_ENUM_ALGORITHM_CLASS_")); ActionListener calculatorListener = e -> { CalculatorType newValue = (CalculatorType) ((JComboBox<?>) e.getSource()).getSelectedItem(); if (newValue != aligner.calculatorType && confirmReset(frame)) { aligner.calculatorType = newValue; reloadBeads(); } else { panel.calculatorComboBox.setSelectedItem(aligner.calculatorType); } }; panel.calculatorComboBox.addActionListener(calculatorListener); panel.calculatorComboBox.setRenderer(new EnumRenderer<CalculatorType>("ALIGNER_ENUM_CALCULATOR_TYPE_")); ActionListener counterListener = e -> { CounterType newValue = (CounterType) ((JComboBox<?>) e.getSource()).getSelectedItem(); if (newValue != aligner.counterType && confirmReset(frame)) { aligner.counterType = newValue; reloadBeads(); } else { panel.counterComboBox.setSelectedItem(aligner.counterType); } }; panel.counterComboBox.addActionListener(counterListener); panel.counterComboBox.setRenderer(new EnumRenderer<CounterType>("ALIGNER_ENUM_COUNTER_TYPE_")); ActionListener segmentingListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean newValue = ((AbstractButton) e.getSource()).isSelected(); if (newValue != aligner.segment && confirmReset(frame)) { aligner.segment = newValue; reloadBeads(); } else { panel.segmentingCheckBox.setSelected(aligner.segment); frame.segmentingItem.setSelected(aligner.segment); } } }; panel.segmentingCheckBox.addActionListener(segmentingListener); frame.segmentingItem.addActionListener(segmentingListener); ActionListener segmentingRulesListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (confirmReset(frame)) { SegmentationCustomizer customizer = new SegmentationCustomizer(false, SRX.getDefault(), Core.getSegmenter().getSRX(), null); if (customizer.show(frame)) { customizedSRX = customizer.getResult(); Core.setSegmenter(new Segmenter(customizedSRX)); reloadBeads(); } } } }; panel.segmentingRulesButton.addActionListener(segmentingRulesListener); frame.segmentingRulesItem.addActionListener(segmentingRulesListener); ActionListener filterSettingsListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (confirmReset(frame)) { FiltersCustomizer customizer = new FiltersCustomizer(false, FilterMaster.createDefaultFiltersConfig(), Core.getFilterMaster().getConfig(), null); if (customizer.show(frame)) { customizedFilters = customizer.getResult(); Core.setFilterMaster(new FilterMaster(customizedFilters)); aligner.clearLoaded(); reloadBeads(); } } } }; panel.fileFilterSettingsButton.addActionListener(filterSettingsListener); frame.fileFilterSettingsItem.addActionListener(filterSettingsListener); TableCellRenderer renderer = new MultilineCellRenderer(); panel.table.setDefaultRenderer(Object.class, renderer); panel.table.setDefaultRenderer(Boolean.class, renderer); panel.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { resizeRows(panel.table); } }); ActionListener oneAdjustListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int[] rows = panel.table.getSelectedRows(); int col = panel.table.getSelectedColumn(); boolean up = e.getSource().equals(panel.moveUpButton) || e.getSource().equals(frame.moveUpItem); BeadTableModel model = (BeadTableModel) panel.table.getModel(); if ((e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0) { int trgRow = up ? model.prevBeadFromRow(rows[0]) : model.nextBeadFromRow(rows[rows.length - 1]); moveRows(rows, col, trgRow); } else { int offset = up ? -1 : 1; slideRows(rows, col, offset); } } }; panel.moveUpButton.addActionListener(oneAdjustListener); frame.moveUpItem.addActionListener(oneAdjustListener); panel.moveDownButton.addActionListener(oneAdjustListener); frame.moveDownItem.addActionListener(oneAdjustListener); ActionListener mergeListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int[] rows = panel.table.getSelectedRows(); int col = panel.table.getSelectedColumn(); BeadTableModel model = (BeadTableModel) panel.table.getModel(); if (rows.length == 1) { rows = new int[] { rows[0], model.nextNonEmptyCell(rows[0], col) }; } int beads = model.beadsInRowSpan(rows); if (beads < 1) { // Do nothing } else if (beads == 1) { mergeRows(rows, col); } else { moveRows(rows, col, rows[0]); } } }; panel.mergeButton.addActionListener(mergeListener); frame.mergeItem.addActionListener(mergeListener); ActionListener splitListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int[] rows = panel.table.getSelectedRows(); int col = panel.table.getSelectedColumn(); BeadTableModel model = (BeadTableModel) panel.table.getModel(); int beads = model.beadsInRowSpan(rows); if (beads != 1) { // Do nothing } else if (rows.length == 1) { splitRow(rows[0], col); } else { splitBead(rows, col); } } }; panel.splitButton.addActionListener(splitListener); frame.splitItem.addActionListener(splitListener); ActionListener editListener = new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = panel.table.getSelectedRow(); int col = panel.table.getSelectedColumn(); editRow(row, col); } }; panel.editButton.addActionListener(editListener); frame.editItem.addActionListener(editListener); ListSelectionListener selectionListener = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { updateCommandAvailability(panel, frame); } }; panel.table.getColumnModel().getSelectionModel().addListSelectionListener(selectionListener); panel.table.getSelectionModel().addListSelectionListener(selectionListener); ActionListener saveListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!confirmSaveTMX(panel)) { return; } while (true) { JFileChooser chooser = new JFileChooser(); chooser.setSelectedFile(new File(defaultSaveDir, getOutFileName())); chooser.setDialogTitle(OStrings.getString("ALIGNER_PANEL_DIALOG_SAVE")); if (JFileChooser.APPROVE_OPTION == chooser.showSaveDialog(frame)) { File file = chooser.getSelectedFile(); if (file.isFile()) { if (JOptionPane.OK_OPTION != JOptionPane.showConfirmDialog(frame, StringUtil.format(OStrings.getString("ALIGNER_PANEL_DIALOG_OVERWRITE"), file.getName()), OStrings.getString("ALIGNER_DIALOG_WARNING_TITLE"), JOptionPane.WARNING_MESSAGE)) { continue; } } List<MutableBead> beads = ((BeadTableModel) panel.table.getModel()).getData(); try { aligner.writePairsToTMX(file, MutableBead.beadsToEntries(aligner.srcLang, aligner.trgLang, beads)); modified = false; } catch (Exception ex) { Log.log(ex); JOptionPane.showMessageDialog(frame, OStrings.getString("ALIGNER_PANEL_SAVE_ERROR"), OStrings.getString("ERROR_TITLE"), JOptionPane.ERROR_MESSAGE); } } break; } } }; panel.saveButton.addActionListener(saveListener); frame.saveItem.addActionListener(saveListener); ActionListener resetListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (confirmReset(frame)) { if (phase == Phase.ALIGN) { aligner.restoreDefaults(); } reloadBeads(); } } }; panel.resetButton.addActionListener(resetListener); frame.resetItem.addActionListener(resetListener); ActionListener reloadListener = e -> { if (confirmReset(frame)) { aligner.clearLoaded(); reloadBeads(); } }; frame.reloadItem.addActionListener(reloadListener); ActionListener removeTagsListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean newValue = ((AbstractButton) e.getSource()).isSelected(); if (newValue != aligner.removeTags && confirmReset(frame)) { aligner.removeTags = newValue; aligner.clearLoaded(); reloadBeads(); } else { panel.removeTagsCheckBox.setSelected(aligner.removeTags); frame.removeTagsItem.setSelected(aligner.removeTags); } } }; panel.removeTagsCheckBox.addActionListener(removeTagsListener); frame.removeTagsItem.addActionListener(removeTagsListener); panel.continueButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { phase = Phase.EDIT; updatePanel(); } }); ActionListener highlightListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doHighlight = ((AbstractButton) e.getSource()).isSelected(); updateHighlight(); } }; panel.highlightCheckBox.addActionListener(highlightListener); frame.highlightItem.addActionListener(highlightListener); ActionListener highlightPatternListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PatternPanelController patternEditor = new PatternPanelController(highlightPattern); highlightPattern = patternEditor.show(frame); Preferences.setPreference(Preferences.ALIGNER_HIGHLIGHT_PATTERN, highlightPattern.pattern()); updateHighlight(); } }; panel.highlightPatternButton.addActionListener(highlightPatternListener); frame.highlightPatternItem.addActionListener(highlightPatternListener); frame.markAcceptedItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setStatus(MutableBead.Status.ACCEPTED, panel.table.getSelectedRows()); } }); frame.markNeedsReviewItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setStatus(MutableBead.Status.NEEDS_REVIEW, panel.table.getSelectedRows()); } }); frame.clearMarkItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setStatus(MutableBead.Status.DEFAULT, panel.table.getSelectedRows()); } }); frame.toggleSelectedItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { toggleEnabled(panel.table.getSelectedRows()); } }); frame.closeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { closeFrame(frame); } }); frame.keepAllItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { toggleAllEnabled(true); } }); frame.keepNoneItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { toggleAllEnabled(false); } }); frame.realignPendingItem.addActionListener(e -> { realignPending(); }); frame.pinpointAlignStartItem.addActionListener(e -> { phase = Phase.PINPOINT; ppRow = panel.table.getSelectedRow(); ppCol = panel.table.getSelectedColumn(); panel.table.clearSelection(); updatePanel(); }); frame.pinpointAlignEndItem.addActionListener(e -> { pinpointAlign(panel.table.getSelectedRow(), panel.table.getSelectedColumn()); }); frame.pinpointAlignCancelItem.addActionListener(e -> { phase = Phase.EDIT; ppRow = -1; ppCol = -1; panel.table.repaint(); updatePanel(); }); panel.table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (phase == Phase.PINPOINT) { JTable table = (JTable) e.getSource(); int row = table.rowAtPoint(e.getPoint()); int col = table.columnAtPoint(e.getPoint()); pinpointAlign(row, col); } } }); frame.resetItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | KeyEvent.SHIFT_DOWN_MASK)); frame.realignPendingItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); frame.saveItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); frame.closeItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); // emacs-like keys for table navigation // See javax.swing.plaf.BasicTableUI.Actions for supported action names. setKeyboardShortcut(panel.table, "selectNextRow", 'n'); setKeyboardShortcut(panel.table, "selectNextRowExtendSelection", 'N'); setKeyboardShortcut(panel.table, "selectPreviousRow", 'p'); setKeyboardShortcut(panel.table, "selectPreviousRowExtendSelection", 'P'); setKeyboardShortcut(panel.table, "selectNextColumn", 'f'); setKeyboardShortcut(panel.table, "selectNextColumnExtendSelection", 'F'); setKeyboardShortcut(panel.table, "selectPreviousColumn", 'b'); setKeyboardShortcut(panel.table, "selectPreviousColumnExtendSelection", 'B'); panel.table.setTransferHandler(new AlignTransferHandler()); panel.table.addPropertyChangeListener("dropLocation", new DropLocationListener()); if (Preferences.isPreference(Preferences.PROJECT_FILES_USE_FONT)) { try { String fontName = Preferences.getPreference(Preferences.TF_SRC_FONT_NAME); int fontSize = Integer.parseInt(Preferences.getPreference(Preferences.TF_SRC_FONT_SIZE)); panel.table.setFont(new Font(fontName, Font.PLAIN, fontSize)); } catch (Exception e) { Log.log(e); } } // Set initial state updateHighlight(); updatePanel(); reloadBeads(); frame.add(panel); frame.pack(); frame.setMinimumSize(frame.getSize()); frame.setLocationRelativeTo(parent); frame.setVisible(true); }
From source file:op.care.nursingprocess.PnlSchedule.java
/** * This method is called from within the constructor to * initialize the form./*from w w w .j a v a2 s . com*/ * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the PrinterForm Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { panelMain = new JPanel(); splitRegular = new JSplitPane(); pnlTageszeit = new JPanel(); jLabel6 = new JideLabel(); jLabel1 = new JideLabel(); jLabel2 = new JideLabel(); jLabel11 = new JideLabel(); jLabel3 = new JideLabel(); jLabel4 = new JideLabel(); txtNachtMo = new JTextField(); txtMorgens = new JTextField(); txtMittags = new JTextField(); txtNachmittags = new JTextField(); txtAbends = new JTextField(); txtNachtAb = new JTextField(); btnToTime = new JButton(); pnlUhrzeit = new JPanel(); lblUhrzeit = new JideLabel(); btnToTimeOfDay = new JButton(); txtUhrzeit = new JTextField(); cmbUhrzeit = new JComboBox(); tabWdh = new JideTabbedPane(); pnlDaily = new JPanel(); label3 = new JLabel(); spinTaeglich = new JSpinner(); jLabel7 = new JLabel(); btnJedenTag = new JButton(); pnlWeekly = new JPanel(); panel3 = new JPanel(); btnJedeWoche = new JButton(); label2 = new JLabel(); spinWoche = new JSpinner(); jLabel8 = new JLabel(); lblUhrzeit2 = new JideLabel(); lblUhrzeit3 = new JideLabel(); lblUhrzeit4 = new JideLabel(); lblUhrzeit5 = new JideLabel(); lblUhrzeit6 = new JideLabel(); lblUhrzeit7 = new JideLabel(); lblUhrzeit8 = new JideLabel(); cbMon = new JCheckBox(); cbDie = new JCheckBox(); cbMit = new JCheckBox(); cbDon = new JCheckBox(); cbFre = new JCheckBox(); cbSam = new JCheckBox(); cbSon = new JCheckBox(); pnlMonthly = new JPanel(); label4 = new JLabel(); spinMonat = new JSpinner(); label6 = new JLabel(); btnJedenMonat = new JButton(); label5 = new JLabel(); spinMonatTag = new JSpinner(); cmbTag = new JComboBox<>(); panel2 = new JPanel(); jLabel13 = new JLabel(); txtLDate = new JTextField(); lblMinutes = new JLabel(); txtMinutes = new JTextField(); pnlBemerkung = new JPanel(); jScrollPane1 = new JScrollPane(); txtBemerkung = new JTextArea(); btnSave = new JButton(); //======== this ======== setLayout(new BorderLayout()); //======== panelMain ======== { panelMain.setBorder(new LineBorder(Color.black, 2, true)); panelMain.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { panelMainComponentResized(e); } }); panelMain.setLayout(new FormLayout("$rgap, $lcgap, 223dlu:grow, $lcgap, $rgap", "$rgap, $lgap, pref, $lgap, default, $lgap, pref, $lgap, default, $lgap, 72dlu:grow, 2*($lgap, default)")); //======== splitRegular ======== { splitRegular.setDividerSize(0); splitRegular.setEnabled(false); splitRegular.setDividerLocation(150); splitRegular.setDoubleBuffered(true); //======== pnlTageszeit ======== { pnlTageszeit.setFont(new Font("Arial", Font.PLAIN, 14)); pnlTageszeit.setBorder(new EtchedBorder()); pnlTageszeit.setLayout( new FormLayout("6*(28dlu, $lcgap), default", "fill:default, $lgap, fill:default")); //---- jLabel6 ---- jLabel6.setText("Nachts, fr\u00fch morgens"); jLabel6.setOrientation(1); jLabel6.setFont(new Font("Arial", Font.PLAIN, 14)); jLabel6.setClockwise(false); jLabel6.setHorizontalTextPosition(SwingConstants.LEFT); pnlTageszeit.add(jLabel6, CC.xy(1, 1)); //---- jLabel1 ---- jLabel1.setForeground(new Color(0, 0, 204)); jLabel1.setText("Morgens"); jLabel1.setOrientation(1); jLabel1.setFont(new Font("Arial", Font.PLAIN, 14)); jLabel1.setClockwise(false); jLabel1.setHorizontalTextPosition(SwingConstants.LEFT); pnlTageszeit.add(jLabel1, CC.xy(3, 1)); //---- jLabel2 ---- jLabel2.setForeground(new Color(255, 102, 0)); jLabel2.setText("Mittags"); jLabel2.setOrientation(1); jLabel2.setFont(new Font("Arial", Font.PLAIN, 14)); jLabel2.setClockwise(false); jLabel2.setHorizontalTextPosition(SwingConstants.LEFT); pnlTageszeit.add(jLabel2, CC.xy(5, 1)); //---- jLabel11 ---- jLabel11.setForeground(new Color(0, 153, 51)); jLabel11.setText("Nachmittag"); jLabel11.setOrientation(1); jLabel11.setFont(new Font("Arial", Font.PLAIN, 14)); jLabel11.setClockwise(false); jLabel11.setHorizontalTextPosition(SwingConstants.LEFT); pnlTageszeit.add(jLabel11, CC.xy(7, 1)); //---- jLabel3 ---- jLabel3.setForeground(new Color(255, 0, 51)); jLabel3.setText("Abends"); jLabel3.setOrientation(1); jLabel3.setFont(new Font("Arial", Font.PLAIN, 14)); jLabel3.setClockwise(false); jLabel3.setHorizontalTextPosition(SwingConstants.LEFT); pnlTageszeit.add(jLabel3, CC.xy(9, 1)); //---- jLabel4 ---- jLabel4.setText("Nacht, sp\u00e4t abends"); jLabel4.setOrientation(1); jLabel4.setFont(new Font("Arial", Font.PLAIN, 14)); jLabel4.setClockwise(false); jLabel4.setHorizontalTextPosition(SwingConstants.LEFT); pnlTageszeit.add(jLabel4, CC.xy(11, 1)); //---- txtNachtMo ---- txtNachtMo.setHorizontalAlignment(SwingConstants.RIGHT); txtNachtMo.setText("0.0"); txtNachtMo.setFont(new Font("Arial", Font.PLAIN, 14)); txtNachtMo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { txtNachtMoActionPerformed(e); } }); txtNachtMo.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtFocusGained(e); } @Override public void focusLost(FocusEvent e) { txtIntegerFocusLost(e); } }); pnlTageszeit.add(txtNachtMo, CC.xy(1, 3)); //---- txtMorgens ---- txtMorgens.setHorizontalAlignment(SwingConstants.RIGHT); txtMorgens.setText("1.0"); txtMorgens.setFont(new Font("Arial", Font.PLAIN, 14)); txtMorgens.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { txtMorgensActionPerformed(e); } }); txtMorgens.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtFocusGained(e); } @Override public void focusLost(FocusEvent e) { txtIntegerFocusLost(e); } }); pnlTageszeit.add(txtMorgens, CC.xy(3, 3)); //---- txtMittags ---- txtMittags.setHorizontalAlignment(SwingConstants.RIGHT); txtMittags.setText("0.0"); txtMittags.setFont(new Font("Arial", Font.PLAIN, 14)); txtMittags.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { txtMittagsActionPerformed(e); } }); txtMittags.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtFocusGained(e); } @Override public void focusLost(FocusEvent e) { txtIntegerFocusLost(e); } }); pnlTageszeit.add(txtMittags, CC.xy(5, 3)); //---- txtNachmittags ---- txtNachmittags.setHorizontalAlignment(SwingConstants.RIGHT); txtNachmittags.setText("0.0"); txtNachmittags.setFont(new Font("Arial", Font.PLAIN, 14)); txtNachmittags.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { txtNachmittagsActionPerformed(e); } }); txtNachmittags.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtFocusGained(e); } @Override public void focusLost(FocusEvent e) { txtIntegerFocusLost(e); } }); pnlTageszeit.add(txtNachmittags, CC.xy(7, 3)); //---- txtAbends ---- txtAbends.setHorizontalAlignment(SwingConstants.RIGHT); txtAbends.setText("0.0"); txtAbends.setFont(new Font("Arial", Font.PLAIN, 14)); txtAbends.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { txtAbendsActionPerformed(e); } }); txtAbends.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtFocusGained(e); } @Override public void focusLost(FocusEvent e) { txtIntegerFocusLost(e); } }); pnlTageszeit.add(txtAbends, CC.xy(9, 3)); //---- txtNachtAb ---- txtNachtAb.setHorizontalAlignment(SwingConstants.RIGHT); txtNachtAb.setText("0.0"); txtNachtAb.setFont(new Font("Arial", Font.PLAIN, 14)); txtNachtAb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { txtNachtAbActionPerformed(e); } }); txtNachtAb.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtFocusGained(e); } @Override public void focusLost(FocusEvent e) { txtIntegerFocusLost(e); } }); pnlTageszeit.add(txtNachtAb, CC.xy(11, 3)); //---- btnToTime ---- btnToTime.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/1rightarrow.png"))); btnToTime.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnToTimeActionPerformed(e); } }); pnlTageszeit.add(btnToTime, CC.xy(13, 3)); } splitRegular.setLeftComponent(pnlTageszeit); //======== pnlUhrzeit ======== { pnlUhrzeit.setBorder(new EtchedBorder()); pnlUhrzeit.setLayout( new FormLayout("default, $ugap, 75dlu, $ugap, pref", "default:grow, $rgap, default")); //---- lblUhrzeit ---- lblUhrzeit.setText("Anzahl Massnahmen"); lblUhrzeit.setOrientation(2); lblUhrzeit.setFont(new Font("Arial", Font.PLAIN, 14)); lblUhrzeit.setClockwise(false); lblUhrzeit.setHorizontalTextPosition(SwingConstants.LEFT); lblUhrzeit.setVerticalAlignment(SwingConstants.BOTTOM); pnlUhrzeit.add(lblUhrzeit, CC.xy(3, 1, CC.DEFAULT, CC.BOTTOM)); //---- btnToTimeOfDay ---- btnToTimeOfDay .setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/1leftarrow.png"))); btnToTimeOfDay.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnToTimeOfDayActionPerformed(e); } }); pnlUhrzeit.add(btnToTimeOfDay, CC.xy(1, 3)); //---- txtUhrzeit ---- txtUhrzeit.setHorizontalAlignment(SwingConstants.RIGHT); txtUhrzeit.setText("0.0"); txtUhrzeit.setFont(new Font("Arial", Font.PLAIN, 14)); txtUhrzeit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { txtUhrzeitActionPerformed(e); } }); txtUhrzeit.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtFocusGained(e); } @Override public void focusLost(FocusEvent e) { txtIntegerFocusLost(e); } }); pnlUhrzeit.add(txtUhrzeit, CC.xy(3, 3)); //---- cmbUhrzeit ---- cmbUhrzeit.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { cmbUhrzeitItemStateChanged(e); } }); pnlUhrzeit.add(cmbUhrzeit, CC.xy(5, 3)); } splitRegular.setRightComponent(pnlUhrzeit); } panelMain.add(splitRegular, CC.xy(3, 3)); //======== tabWdh ======== { //======== pnlDaily ======== { pnlDaily.setFont(new Font("Arial", Font.PLAIN, 14)); pnlDaily.setLayout(new FormLayout("2*(default), $rgap, $lcgap, 40dlu, $rgap, default", "default, $lgap, pref, $lgap, default")); //---- label3 ---- label3.setText("alle"); label3.setFont(new Font("Arial", Font.PLAIN, 14)); pnlDaily.add(label3, CC.xy(2, 3)); //---- spinTaeglich ---- spinTaeglich.setFont(new Font("Arial", Font.PLAIN, 14)); spinTaeglich.setModel(new SpinnerNumberModel(1, null, null, 1)); pnlDaily.add(spinTaeglich, CC.xy(5, 3)); //---- jLabel7 ---- jLabel7.setText("Tage"); jLabel7.setFont(new Font("Arial", Font.PLAIN, 14)); pnlDaily.add(jLabel7, CC.xy(7, 3)); //---- btnJedenTag ---- btnJedenTag.setText("Jeden Tag"); btnJedenTag.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnJedenTagActionPerformed(e); } }); pnlDaily.add(btnJedenTag, CC.xywh(2, 5, 6, 1)); } tabWdh.addTab("T\u00e4glich", pnlDaily); //======== pnlWeekly ======== { pnlWeekly.setFont(new Font("Arial", Font.PLAIN, 14)); pnlWeekly.setLayout(new FormLayout("default, 7*(13dlu), $lcgap, default:grow", "$ugap, $lgap, default, $lgap, pref, default:grow, $lgap, $rgap")); //======== panel3 ======== { panel3.setLayout( new FormLayout("default, $rgap, 40dlu, $rgap, 2*(default), $lcgap, default, $lcgap", "default:grow, $lgap, default")); //---- btnJedeWoche ---- btnJedeWoche.setText("Jede Woche"); btnJedeWoche.setFont(new Font("Arial", Font.PLAIN, 14)); btnJedeWoche.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnJedeWocheActionPerformed(e); } }); panel3.add(btnJedeWoche, CC.xywh(3, 3, 3, 1)); //---- label2 ---- label2.setText("alle"); label2.setFont(new Font("Arial", Font.PLAIN, 14)); panel3.add(label2, CC.xy(1, 1)); panel3.add(spinWoche, CC.xy(3, 1)); //---- jLabel8 ---- jLabel8.setText("Wochen am"); jLabel8.setFont(new Font("Arial", Font.PLAIN, 14)); panel3.add(jLabel8, CC.xy(5, 1)); } pnlWeekly.add(panel3, CC.xywh(2, 3, 9, 1)); //---- lblUhrzeit2 ---- lblUhrzeit2.setText("montags"); lblUhrzeit2.setOrientation(1); lblUhrzeit2.setFont(new Font("Arial", Font.PLAIN, 14)); lblUhrzeit2.setClockwise(false); lblUhrzeit2.setHorizontalTextPosition(SwingConstants.LEFT); pnlWeekly.add(lblUhrzeit2, CC.xy(2, 5, CC.CENTER, CC.BOTTOM)); //---- lblUhrzeit3 ---- lblUhrzeit3.setText("dienstags"); lblUhrzeit3.setOrientation(1); lblUhrzeit3.setFont(new Font("Arial", Font.PLAIN, 14)); lblUhrzeit3.setClockwise(false); lblUhrzeit3.setHorizontalTextPosition(SwingConstants.LEFT); pnlWeekly.add(lblUhrzeit3, CC.xy(3, 5, CC.CENTER, CC.BOTTOM)); //---- lblUhrzeit4 ---- lblUhrzeit4.setText("mittwochs"); lblUhrzeit4.setOrientation(1); lblUhrzeit4.setFont(new Font("Arial", Font.PLAIN, 14)); lblUhrzeit4.setClockwise(false); lblUhrzeit4.setHorizontalTextPosition(SwingConstants.LEFT); pnlWeekly.add(lblUhrzeit4, CC.xy(4, 5, CC.CENTER, CC.BOTTOM)); //---- lblUhrzeit5 ---- lblUhrzeit5.setText("donnerstags"); lblUhrzeit5.setOrientation(1); lblUhrzeit5.setFont(new Font("Arial", Font.PLAIN, 14)); lblUhrzeit5.setClockwise(false); lblUhrzeit5.setHorizontalTextPosition(SwingConstants.LEFT); pnlWeekly.add(lblUhrzeit5, CC.xy(5, 5, CC.CENTER, CC.BOTTOM)); //---- lblUhrzeit6 ---- lblUhrzeit6.setText("freitags"); lblUhrzeit6.setOrientation(1); lblUhrzeit6.setFont(new Font("Arial", Font.PLAIN, 14)); lblUhrzeit6.setClockwise(false); lblUhrzeit6.setHorizontalTextPosition(SwingConstants.LEFT); pnlWeekly.add(lblUhrzeit6, CC.xy(6, 5, CC.CENTER, CC.BOTTOM)); //---- lblUhrzeit7 ---- lblUhrzeit7.setText("samstags"); lblUhrzeit7.setOrientation(1); lblUhrzeit7.setFont(new Font("Arial", Font.PLAIN, 14)); lblUhrzeit7.setClockwise(false); lblUhrzeit7.setHorizontalTextPosition(SwingConstants.LEFT); pnlWeekly.add(lblUhrzeit7, CC.xy(7, 5, CC.CENTER, CC.BOTTOM)); //---- lblUhrzeit8 ---- lblUhrzeit8.setText("sonntags"); lblUhrzeit8.setOrientation(1); lblUhrzeit8.setFont(new Font("Arial", Font.PLAIN, 14)); lblUhrzeit8.setClockwise(false); lblUhrzeit8.setHorizontalTextPosition(SwingConstants.LEFT); pnlWeekly.add(lblUhrzeit8, CC.xy(8, 5, CC.CENTER, CC.BOTTOM)); //---- cbMon ---- cbMon.setBorder(BorderFactory.createEmptyBorder()); cbMon.setMargin(new Insets(0, 0, 0, 0)); cbMon.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cbMonActionPerformed(e); } }); pnlWeekly.add(cbMon, CC.xy(2, 6, CC.CENTER, CC.DEFAULT)); //---- cbDie ---- cbDie.setBorder(BorderFactory.createEmptyBorder()); cbDie.setMargin(new Insets(0, 0, 0, 0)); cbDie.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cbDieActionPerformed(e); } }); pnlWeekly.add(cbDie, CC.xy(3, 6, CC.CENTER, CC.DEFAULT)); //---- cbMit ---- cbMit.setBorder(BorderFactory.createEmptyBorder()); cbMit.setMargin(new Insets(0, 0, 0, 0)); cbMit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cbMitActionPerformed(e); } }); pnlWeekly.add(cbMit, CC.xy(4, 6, CC.CENTER, CC.DEFAULT)); //---- cbDon ---- cbDon.setBorder(BorderFactory.createEmptyBorder()); cbDon.setMargin(new Insets(0, 0, 0, 0)); cbDon.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cbDonActionPerformed(e); } }); pnlWeekly.add(cbDon, CC.xy(5, 6, CC.CENTER, CC.DEFAULT)); //---- cbFre ---- cbFre.setBorder(BorderFactory.createEmptyBorder()); cbFre.setMargin(new Insets(0, 0, 0, 0)); cbFre.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cbFreActionPerformed(e); } }); pnlWeekly.add(cbFre, CC.xy(6, 6, CC.CENTER, CC.DEFAULT)); //---- cbSam ---- cbSam.setBorder(BorderFactory.createEmptyBorder()); cbSam.setMargin(new Insets(0, 0, 0, 0)); cbSam.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cbSamActionPerformed(e); } }); pnlWeekly.add(cbSam, CC.xy(7, 6, CC.CENTER, CC.DEFAULT)); //---- cbSon ---- cbSon.setBorder(BorderFactory.createEmptyBorder()); cbSon.setMargin(new Insets(0, 0, 0, 0)); cbSon.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cbSonActionPerformed(e); } }); pnlWeekly.add(cbSon, CC.xy(8, 6, CC.CENTER, CC.DEFAULT)); } tabWdh.addTab("W\u00f6chentlich", pnlWeekly); //======== pnlMonthly ======== { pnlMonthly.setFont(new Font("Arial", Font.PLAIN, 14)); pnlMonthly.setLayout( new FormLayout("default, $lcgap, pref, $lcgap, 40dlu, $lcgap, pref, $lcgap, 61dlu", "3*(default, $lgap), default")); //---- label4 ---- label4.setText("jeden"); label4.setFont(new Font("Arial", Font.PLAIN, 14)); label4.setHorizontalAlignment(SwingConstants.TRAILING); pnlMonthly.add(label4, CC.xy(3, 3)); //---- spinMonat ---- spinMonat.setFont(new Font("Arial", Font.PLAIN, 14)); pnlMonthly.add(spinMonat, CC.xy(5, 3)); //---- label6 ---- label6.setText("Monat"); label6.setFont(new Font("Arial", Font.PLAIN, 14)); pnlMonthly.add(label6, CC.xy(7, 3)); //---- btnJedenMonat ---- btnJedenMonat.setText("Jeden Monat"); btnJedenMonat.setFont(new Font("Arial", Font.PLAIN, 14)); btnJedenMonat.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnJedenMonatActionPerformed(e); } }); pnlMonthly.add(btnJedenMonat, CC.xywh(3, 5, 5, 1)); //---- label5 ---- label5.setText("jeweils am"); label5.setFont(new Font("Arial", Font.PLAIN, 14)); label5.setHorizontalAlignment(SwingConstants.TRAILING); pnlMonthly.add(label5, CC.xy(3, 7)); //---- spinMonatTag ---- spinMonatTag.setFont(new Font("Arial", Font.PLAIN, 14)); spinMonatTag.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { spinMonatTagStateChanged(e); } }); pnlMonthly.add(spinMonatTag, CC.xy(5, 7)); //---- cmbTag ---- cmbTag.setModel(new DefaultComboBoxModel<>(new String[] { "Tag des Monats", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag" })); cmbTag.setFont(new Font("Arial", Font.PLAIN, 14)); pnlMonthly.add(cmbTag, CC.xywh(7, 7, 3, 1)); } tabWdh.addTab("Monatlich", pnlMonthly); } panelMain.add(tabWdh, CC.xy(3, 7, CC.FILL, CC.FILL)); //======== panel2 ======== { panel2.setLayout(new FormLayout( "default, $lcgap, default:grow, $ugap, default, $lcgap, default:grow", "default:grow")); //---- jLabel13 ---- jLabel13.setText("Erst einplanen ab dem"); jLabel13.setFont(new Font("Arial", Font.PLAIN, 14)); panel2.add(jLabel13, CC.xy(1, 1)); //---- txtLDate ---- txtLDate.setFont(new Font("Arial", Font.PLAIN, 14)); txtLDate.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { txtLDateFocusLost(e); } }); panel2.add(txtLDate, CC.xy(3, 1)); //---- lblMinutes ---- lblMinutes.setText("text"); lblMinutes.setFont(new Font("Arial", Font.PLAIN, 14)); panel2.add(lblMinutes, CC.xy(5, 1)); //---- txtMinutes ---- txtMinutes.setFont(new Font("Arial", Font.PLAIN, 14)); txtMinutes.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { txtMinutesFocusLost(e); } }); panel2.add(txtMinutes, CC.xy(7, 1)); } panelMain.add(panel2, CC.xy(3, 9)); //======== pnlBemerkung ======== { pnlBemerkung.setBorder(new TitledBorder(null, "Kommentar zur Anwendung (Erscheint im DFN)", TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION, new Font("Arial", Font.PLAIN, 14))); pnlBemerkung.setLayout(new BoxLayout(pnlBemerkung, BoxLayout.X_AXIS)); //======== jScrollPane1 ======== { //---- txtBemerkung ---- txtBemerkung.setColumns(20); txtBemerkung.setRows(5); jScrollPane1.setViewportView(txtBemerkung); } pnlBemerkung.add(jScrollPane1); } panelMain.add(pnlBemerkung, CC.xy(3, 11, CC.FILL, CC.FILL)); //---- btnSave ---- btnSave.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png"))); btnSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnSaveActionPerformed(e); } }); panelMain.add(btnSave, CC.xy(3, 13, CC.RIGHT, CC.DEFAULT)); } add(panelMain, BorderLayout.CENTER); }
From source file:org.squidy.designer.Designer.java
/** * //w w w. ja va 2s. c o m */ private Designer() { super("", false, new PSwingCanvas()); try { setIconImage(ImageIO.read(Designer.class.getResource("/tray-icon.png"))); } catch (Exception e1) { System.err.println("Could not find tray icon."); } views.add(this); initializeView(this); initializeSession(); // getCanvas().setZoomEventHandler(null); // Doesn't work properly! // getCanvas().addInputEventListener(new PBasicInputEventHandler() { // @Override // public void mouseWheelRotated(PInputEvent event) { // super.mouseWheelRotated(event); // // System.out.println("ROT: " + event.getWheelRotation()); // // PCamera camera = event.getCamera(); // double cameraScale = camera.getScale(); // // getCanvas().getCamera().scaleAboutPoint((double) // event.getWheelRotation() / 15 + 1, event.getPosition()); // } // // @Override // public void mouseWheelRotatedByBlock(PInputEvent event) { // super.mouseWheelRotatedByBlock(event); // // System.out.println("ROT BLOCK"); // } // }); getCanvas().setPanEventHandler(null); try { heuristics = HeuristicsHandler.getHeuristicsHandler() .load(Designer.class.getResourceAsStream("/heuristics.xml")); } catch (SquidyException e) { e.printStackTrace(); } addComponentListener(new ComponentAdapter() { /* * (non-Javadoc) * * @see * java.awt.event.ComponentAdapter#componentResized(java.awt.event * .ComponentEvent) */ @Override public void componentResized(ComponentEvent e) { super.componentResized(e); zoomToZoomedShape(data); } }); // Initiate the storage timer. initiateAutomatedStorage(); // setSize(800, 600); // Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // setLocation((int) (screenSize.getWidth() / 2) - getWidth() / 2, (int) // (screenSize.getHeight() / 2) // - getHeight() / 2); addComponentListener(new ComponentAdapter() { /* * (non-Javadoc) * * @see * java.awt.event.ComponentListener#componentResized(java.awt.event * .ComponentEvent) */ public void componentResized(ComponentEvent e) { PreferencesManager.putDimension(WINDOW_SIZE, Designer.this.getSize()); } /* * (non-Javadoc) * * @see * java.awt.event.ComponentAdapter#componentMoved(java.awt.event * .ComponentEvent) */ @Override public void componentMoved(ComponentEvent e) { PreferencesManager.putPoint(WINDOW_LOCATION, Designer.this.getLocation()); } }); initMenuBar(); Dimension size = PreferencesManager.getDimension(WINDOW_SIZE, new Dimension(1228, 768)); setSize(size); Point location = PreferencesManager.getPoint(WINDOW_LOCATION, new Point(100, 50)); setLocation(location); // Enables the tray icon behavior for the designer window. new DesignerTrayIconBehavior(this).enable(); }
From source file:shuffle.fwk.service.roster.EditRosterService.java
@SuppressWarnings("serial") private Component makeCenterPanel() { rosterEntryPanel = new JPanel(new WrapLayout()) { // Fix to make it play nice with the scroll bar. @Override//w w w . j a v a 2s . c om public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.width = (int) (d.getWidth() - 20); return d; } }; final JScrollPane ret = new JScrollPane(rosterEntryPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); ret.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { ret.revalidate(); } }); ret.getVerticalScrollBar().setUnitIncrement(27); return ret; }