List of usage examples for javax.swing JViewport setView
public void setView(Component view)
JViewport
's one lightweight child (view
), which can be null
. From source file:com.projity.dialog.assignment.AssignmentEntryPane.java
public void init() { if (project == null) return;//from w w w . j a va 2s. c o m ResourcePool pool = project.getResourcePool(); // if (assignmentModel==null){ pool.getResourceOutline().getHierarchy().removeHierarchyListener(this); pool.getResourceOutline().getHierarchy().addHierarchyListener(this); assignmentModel = NodeModelFactory.getInstance().replicate(pool.getResourceOutline(), new NodeFactoryTransformer()); assignmentModel.getHierarchy().setNbEndVoidNodes(0); // don't allow blank lines // } if (spreadSheet == null) { spreadSheet = new AssignmentSpreadSheet(resourceAssigner); spreadSheet.setSpreadSheetCategory(spreadsheetCategory); // for columns. Must do first spreadSheet.setActions(new String[] {}); } cache = NodeModelCacheFactory.getInstance().createDefaultCache(assignmentModel, pool, NodeModelCache.ASSIGNMENT_TYPE, "AssignmentEntry", transformerClosure); SpreadSheetFieldArray fields = getFields(); spreadSheet.setCache(cache, fields, fields.getCellStyle(), fields.getActionList()); // set widths of these columns explicitly if (!replace) { //TODO width should come from definition in xml, not hard coded here // spreadSheet.getColumnModel().getColumn(REQUEST_DEMAND_TYPE_COLUMN).setPreferredWidth(50); spreadSheet.getColumnModel().getColumn(UNITS_COLUMN).setPreferredWidth(50); } JViewport viewport = createViewport(); viewport.setView(spreadSheet); setViewport(viewport); setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); Dimension d = spreadSheet.getPreferredSize(); Dimension enclosing = new Dimension(); //big awful hack to remove GraphicConfiguration config = GraphicConfiguration.getInstance(); int rowHeaderWidth = config.getRowHeaderWidth() + spreadSheet.getRowMargin() * 2; //should be rowHeader's one // TableColumnModel tm=spreadSheet.getColumnModel(); // int w=tm.getTotalColumnWidth(); enclosing.setSize(d.getWidth()/*+rowHeaderWidth*/, d.getHeight()); viewport.setPreferredSize(enclosing); //setBorder(new EmptyBorder(0,0,0,0)); updateTable(); }
From source file:com.projity.pm.graphic.spreadsheet.common.CommonSpreadSheet.java
protected void configureScrollPaneHeaders(JScrollPane scrollPane) { if (scrollPane instanceof ScaledScrollPane) scrollPane.setColumnHeaderView(((ScaledScrollPane) scrollPane).getTimeScaleComponent()); else//w w w .j av a2s . c o m scrollPane.setColumnHeaderView(getTableHeader()); JViewport vp = new JViewport(); vp.setView(rowHeader); vp.setPreferredSize(rowHeader.getPreferredSize()); scrollPane.setRowHeader(vp); corner = new SpreadSheetCorner(this); scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, corner); //scrollPane.setCorner(JScrollPane.LOWER_LEFT_CORNER,new GradientCorner()); }
From source file:edu.ku.brc.ui.tmanfe.SpreadSheet.java
/** * //from w w w .java 2 s .co m */ protected void buildSpreadsheet() { this.setShowGrid(true); int numRows = model.getRowCount(); scrollPane = new JScrollPane(this, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); setAutoResizeMode(JTable.AUTO_RESIZE_OFF); final SpreadSheet ss = this; JButton cornerBtn = UIHelper.createIconBtn("Blank", IconManager.IconSize.Std16, "SelectAll", new ActionListener() { public void actionPerformed(ActionEvent ae) { ss.selectAll(); } }); cornerBtn.setEnabled(true); scrollPane.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, cornerBtn); // Allows row and collumn selections to exit at the same time setCellSelectionEnabled(true); setRowSelectionAllowed(true); setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); addMouseListener(new MouseAdapter() { /* (non-Javadoc) * @see java.awt.event.MouseAdapter#mousePressed(java.awt.event.MouseEvent) */ @SuppressWarnings("synthetic-access") @Override public void mouseReleased(MouseEvent e) { // XXX For Java 5 Bug prevRowSelInx = getSelectedRow(); prevColSelInx = getSelectedColumn(); if (e.getClickCount() == 2) { int rowIndexStart = getSelectedRow(); int colIndexStart = getSelectedColumn(); ss.editCellAt(rowIndexStart, colIndexStart); if (ss.getEditorComponent() != null && ss.getEditorComponent() instanceof JTextComponent) { ss.getEditorComponent().requestFocus(); final JTextComponent txtComp = (JTextComponent) ss.getEditorComponent(); String txt = txtComp.getText(); FontMetrics fm = txtComp.getFontMetrics(txtComp.getFont()); int x = e.getPoint().x - ss.getEditorComponent().getBounds().x - 1; int prevWidth = 0; for (int i = 0; i < txt.length(); i++) { int width = fm.stringWidth(txt.substring(0, i)); int basePlusHalf = prevWidth + (int) (((width - prevWidth) / 2) + 0.5); //System.out.println(prevWidth + " X[" + x + "] " + width+" ["+txt.substring(0, i)+"] " + i + " " + basePlusHalf); //System.out.println(" X[" + x + "] " + prevWidth + " - "+ basePlusHalf+" - " + width+" ["+txt.substring(0, i)+"] " + i); if (x < width) { // Clearing the selection is needed for Window for some reason final int inx = i + (x <= basePlusHalf ? -1 : 0); SwingUtilities.invokeLater(new Runnable() { @SuppressWarnings("synthetic-access") public void run() { txtComp.setSelectionStart(0); txtComp.setSelectionEnd(0); txtComp.setCaretPosition(inx > 0 ? inx : 0); } }); break; } prevWidth = width; } } } } }); // Create a row-header to display row numbers. // This row-header is made of labels whose Borders, // Foregrounds, Backgrounds, and Fonts must be // the one used for the table column headers. // Also ensure that the row-header labels and the table // rows have the same height. //i have no idea WHY this has to be called. i rearranged //the table and find replace panel, // i started getting an array index out of //bounds on the column header ON MAC ONLY. //tried firing this off, first and it fixed the problem.//meg this.getModel().fireTableStructureChanged(); /* * Create the Row Header Panel */ rowHeaderPanel = new JPanel((LayoutManager) null); if (getColumnModel().getColumnCount() > 0) { TableColumn column = getColumnModel().getColumn(0); TableCellRenderer renderer = getTableHeader().getDefaultRenderer(); if (renderer == null) { renderer = column.getHeaderRenderer(); } Component cellRenderComp = renderer.getTableCellRendererComponent(this, column.getHeaderValue(), false, false, -1, 0); cellFont = cellRenderComp.getFont(); } else { cellFont = (new JLabel()).getFont(); } // Calculate Row Height cellBorder = (Border) UIManager.getDefaults().get("TableHeader.cellBorder"); Insets insets = cellBorder.getBorderInsets(tableHeader); FontMetrics metrics = getFontMetrics(cellFont); rowHeight = insets.bottom + metrics.getHeight() + insets.top; rowLabelWidth = metrics.stringWidth("9999") + insets.right + insets.left; Dimension dim = new Dimension(rowLabelWidth, rowHeight * numRows); rowHeaderPanel.setPreferredSize(dim); // need to call this when no layout manager is used. rhCellMouseAdapter = new RHCellMouseAdapter(this); // Adding the row header labels for (int ii = 0; ii < numRows; ii++) { addRow(ii, ii + 1, false); } JViewport viewPort = new JViewport(); dim.height = rowHeight * numRows; viewPort.setViewSize(dim); viewPort.setView(rowHeaderPanel); scrollPane.setRowHeader(viewPort); // Experimental from the web, but I think it does the trick. addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (!ss.isEditing() && !e.isActionKey() && !e.isControlDown() && !e.isMetaDown() && !e.isAltDown() && e.getKeyCode() != KeyEvent.VK_SHIFT && e.getKeyCode() != KeyEvent.VK_TAB && e.getKeyCode() != KeyEvent.VK_ENTER) { log.error("Grabbed the event as input"); int rowIndexStart = getSelectedRow(); int colIndexStart = getSelectedColumn(); if (rowIndexStart == -1 || colIndexStart == -1) return; ss.editCellAt(rowIndexStart, colIndexStart); Component c = ss.getEditorComponent(); if (c instanceof JTextComponent) ((JTextComponent) c).setText(""); } } }); resizeAndRepaint(); // Taken from a JavaWorld Example (But it works) KeyStroke cut = KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false); KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false); KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false); Action ssAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { SpreadSheet.this.actionPerformed(e); } }; getInputMap().put(cut, "Cut"); getActionMap().put("Cut", ssAction); getInputMap().put(copy, "Copy"); getActionMap().put("Copy", ssAction); getInputMap().put(paste, "Paste"); getActionMap().put("Paste", ssAction); ((JMenuItem) UIRegistry.get(UIRegistry.COPY)).addActionListener(this); ((JMenuItem) UIRegistry.get(UIRegistry.CUT)).addActionListener(this); ((JMenuItem) UIRegistry.get(UIRegistry.PASTE)).addActionListener(this); setSortOrderCycle(SortOrder.ASCENDING, SortOrder.DESCENDING, SortOrder.UNSORTED); }
From source file:windows.sensorWindow.java
/** * window constructor for chart window/*from w w w. ja v a2 s . c om*/ * * @param title * title for the new window */ public sensorWindow(final String title) { super(title); System.out.println("create sensorWindow"); // font customizing // ------------------------------------------------------- /* * Font font1 = null; try { font1 = Font.createFont(Font.TRUETYPE_FONT, * new File("U:/workspace/SWTtest/fonts/roboto/Roboto-Black.ttf")); } * catch (FontFormatException | IOException e1) { e1.printStackTrace(); * } StandardChartTheme chartTheme = new * StandardChartTheme("robotTheme"); * chartTheme.setExtraLargeFont(font1.deriveFont(24f)); * chartTheme.setLargeFont(font1.deriveFont(16f)); * chartTheme.setRegularFont(font1.deriveFont(12f)); * chartTheme.setSmallFont(font1.deriveFont(10f)); * ChartFactory.setChartTheme(chartTheme); */ Font font1 = new Font("Tahoma", Font.BOLD, 16); Font font2 = new Font("Tahoma", Font.PLAIN, 12); Font font3 = new Font("Tahoma", Font.BOLD, 16); customFonts.put("axisLabelFont", font1); customFonts.put("axisValueFont", font2); customFonts.put("titleFont", font3); // ------------------------------------------------------------------------- this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); plot = new CombinedDomainXYPlot(new DateAxis("Time")); for (int i = 0; i < connectionData.presentedBrickList.size(); i++) { Brick tmpBrick = connectionData.presentedBrickList.get(i); addPlot(tmpBrick); } final JFreeChart chart = new JFreeChart("", plot); // chart.setBorderPaint(Color.black); // chart.setBorderVisible(true); // chart.setBackgroundPaint(Color.white); chart.removeLegend(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setRenderer(renderer2); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 4, 4, 4, 4)); final ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(chartRangeSec * 1000); // chart range seconds axis.setLabelFont(customFonts.get("axisLabelFont")); axis.setTickLabelFont(customFonts.get("axisValueFont")); //final JPanel content = new JPanel(new BorderLayout()); content = new JPanel(new BorderLayout()); JScrollPane scrollPane = new JScrollPane(); JViewport viewport = scrollPane.getViewport(); viewport.setView(content); final ChartPanel chartPanel = new ChartPanel(chart); content.add(chartPanel, BorderLayout.NORTH); // content.add(getScrollBar(xAxe), BorderLayout.SOUTH); // disable zoom chartPanel.setRangeZoomable(false); chartPanel.setDomainZoomable(false); // mouse selection chartPanel.addMouseListener(new MouseMarker(chartPanel)); chartPanel.setPreferredSize(new java.awt.Dimension(500, 470)); // chartPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); // setContentPane(content); // =================================================== // buttons buttonPanel = new JPanel(new FlowLayout()); for (int i = 0; i < connectionData.presentedBrickList.size(); i++) { for (int i2 = 0; i2 < 2; i2++) { Brick tmpBrick = connectionData.presentedBrickList.get(i); JButton button = new JButton(tmpBrick.uid + " start"); button.setActionCommand(buttonComAddBtn + tmpBrick.uid + i + "(" + i2 + ")"); button.addActionListener(this); tmplButtons.put(tmpBrick.uid, button); // if ((tmpBrick.ctrlTmpl[0]) || (tmpBrick.ctrlTmpl[1])) // { // buttonPanel.add(button); // } changeTmplCntrl(tmpBrick, i2); } } content.add(buttonPanel, BorderLayout.SOUTH); // =================================================== // =================================================== // scroll bar final JPanel sliderPanel = new JPanel(new FlowLayout()); slider = new JSlider(1, sliderValuesNumber); slider.setValue(sliderValuesNumber); slider.setEnabled(false); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (sliderData.sliderActive == true) { int sliderValue = slider.getValue(); if (sliderValue == sliderValuesNumber) sliderUpdate = true; else sliderUpdate = false; /* System.out.println("slider : " + sliderValue); System.out.println("Millis first: " + sliderData.getMilliseconds( sliderValue - sliderValuesNumber) .toString()); System.out.println("Millis last : " + sliderData.getMilliseconds(sliderValue) .toString()); */ DateRange range = new DateRange( sliderData.getMilliseconds(sliderValue - sliderValuesNumber).getFirstMillisecond(), sliderData.getMilliseconds(sliderValue).getFirstMillisecond()); plot.getDomainAxis().setRange(range); } } }); sliderPanel.add(slider); // chartPanel.add(slider); /* * final Panel chartPanel2 = new Panel(); chartPanel2.add(slider); * content.add(chartPanel2, BorderLayout.SOUTH); */ content.add(sliderPanel, BorderLayout.CENTER); // =================================================== // =================================================== // scrolling /* * String[] data = {"one", "two", "three", "four", "five", "six", * "seven", "eight", "nine", "ten"}; JList list = new JList(data); * * // give the list some scrollbars. // the horizontal (bottom) * scrollbar will only appear // when the screen is too wide. The * vertical // scrollbar is always present, but disabled if the // list * is small. JScrollPane jsp = new JScrollPane(list, * JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, * JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); * * // add the JScrollPane (not the list) to the window. * getContentPane().add(jsp, BorderLayout.CENTER); */ // ================================================== setContentPane(content); this.addComponentListener(new java.awt.event.ComponentAdapter() { public void componentResized(java.awt.event.ComponentEvent e) { chartPanel.setMaximumDrawWidth((int) e.getComponent().getSize().getWidth()); chartPanel.setMaximumDrawHeight((int) e.getComponent().getSize().getHeight()); //chartPanel.setPreferredSize(e.getComponent().getPreferredSize()); //chartPanel.setSize(e.getComponent().getSize()); //chartPanel.setLocation(0,0); } }); // start auto update plot autoUpdatePlot(); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.out.println("close sensor window"); functions.windowController.closeSensorWindow(); } }); }
From source file:app.RunApp.java
/** * Fill the table with Chi and Phi coefficients * /* w w w . j a va 2 s . com*/ * @param dataset Multi-label dataset */ private void fillTableChiPhiCoefficients(MultiLabelInstances dataset) { chiPhiCoefficients = ChartUtils.getChiPhiCoefficients(dataset); data = new Object[chiPhiCoefficients.length][chiPhiCoefficients.length + 1]; column = new Object[data.length + 1]; for (int i = 0; i < chiPhiCoefficients.length; i++) { data[i] = Utils.getValuesByRow(i, chiPhiCoefficients, dataset.getLabelNames()[i]); } for (int i = 0; i < column.length; i++) { if (i == 0) { column[i] = "Labels"; } else { column[i] = (dataset.getLabelNames()[i - 1]); } } AbstractTableModel1 fixedModel = new AbstractTableModel1(data, column); AbstractTableModel2 model = new AbstractTableModel2(data, column); fixedTableChiPhi.setModel(fixedModel); jTableChiPhi.setModel(model); JScrollPane scroll = new JScrollPane(jTableChiPhi); JViewport viewport = new JViewport(); viewport.setView(fixedTableChiPhi); viewport.setPreferredSize(fixedTableChiPhi.getPreferredSize()); scroll.setRowHeaderView(viewport); scroll.setBounds(20, 20, 780, 390); scroll.setCorner(JScrollPane.UPPER_LEFT_CORNER, fixedTableChiPhi.getTableHeader()); jTableChiPhi.setBorder(BorderFactory.createLineBorder(Color.black)); if (firstTimeChi) { panelChiPhi.add(scroll, BorderLayout.CENTER, 0); firstTimeChi = false; return; } panelChiPhi.remove(0); panelChiPhi.add(scroll, BorderLayout.CENTER, 0); }
From source file:app.RunApp.java
/** * Fill the table with coefficient values * /*ww w . j a va 2 s . c o m*/ * @param dataset * @param pairs * @param type */ private void fillTableCoefficients(MultiLabelInstances dataset, String type) { double[][] pairLabelValues; //coocurrence values table if (type.equals("coocurrence")) { pairLabelValues = ChartUtils.getCoocurrences(dataset); coocurrenceCoefficients = pairLabelValues; } //heatmap values table else { pairLabelValues = getHeatMapCoefficients(); heatmapCoefficients = pairLabelValues.clone(); } /** **/ data = new Object[pairLabelValues.length][pairLabelValues.length + 1]; column = new Object[data.length + 1]; if (type.equals("coocurrence")) { for (int i = 0; i < pairLabelValues.length; i++) { for (int j = 0; j < pairLabelValues.length; j++) { if (j == 0) { data[i][j] = dataset.getLabelNames()[i]; } else if (i == (j - 1)) { data[i][j] = ""; } else if (j > i) { data[i][j] = ""; } else { if (pairLabelValues[j - 1][i] <= 0.0) { data[i][j] = ""; } else { data[i][j] = (int) pairLabelValues[j - 1][i]; } } } } } else { for (int i = 0; i < pairLabelValues.length; i++) { for (int j = 0; j < pairLabelValues.length + 1; j++) { if (j == 0) { data[i][j] = dataset.getLabelNames()[i]; } else { if (pairLabelValues[j - 1][i] <= 0.0) { data[i][j] = ""; } else { NumberFormat formatter = new DecimalFormat("#0.000"); data[i][j] = formatter.format(pairLabelValues[j - 1][i]).replace(",", "."); } } } } } for (int i = 0; i < column.length; i++) { if (i == 0) { column[i] = "Labels"; } else { column[i] = (dataset.getLabelNames()[i - 1]); } } AbstractTableModel1 fixedModel = new AbstractTableModel1(data, column); AbstractTableModel2 model = new AbstractTableModel2(data, column); JTable temp, fixedTable_temp; JPanel jpanel_temp; if (type.equals("coocurrence")) { temp = jTableCoocurrences; jpanel_temp = panelCoOcurrenceValues; fixedTable_temp = fixedTableCoocurrences; } else { temp = jTableHeatmap; jpanel_temp = panelHeatmapValues; fixedTable_temp = fixedTableHeatmap; } fixedTable_temp.setModel(fixedModel); temp.setModel(model); JScrollPane scroll = new JScrollPane(temp); JViewport viewport = new JViewport(); viewport.setView(fixedTable_temp); viewport.setPreferredSize(fixedTable_temp.getPreferredSize()); scroll.setRowHeaderView(viewport); scroll.setBounds(20, 20, 780, 390); scroll.setCorner(JScrollPane.UPPER_LEFT_CORNER, fixedTable_temp.getTableHeader()); temp.setBorder(BorderFactory.createLineBorder(Color.black)); jpanel_temp.remove(0); jpanel_temp.add(scroll, BorderLayout.CENTER, 0); }
From source file:org.isatools.isacreator.gui.formelements.SubForm.java
public JScrollPane getFrozenTable(DefaultTableModel model, int width, int height) { // number of initial records equal to the number of columns in the model - the first column which contains field names! frozenTable = new JScrollPane(); IAppWidgetFactory.makeIAppScrollPane(frozenTable); lockedTable = new ExtendedJTable(model, rowEditor); lockedTable.getTableHeader().setReorderingAllowed(false); setTableProperties(lockedTable, true); scrollTable = new ExtendedJTable(model, rowEditor); setTableProperties(scrollTable, false); scrollTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); scrollTable.getTableHeader().setResizingAllowed(true); try {/* w ww.j a v a2 s. co m*/ lockedTable.setDefaultRenderer(Class.forName("java.lang.Object"), DEFAULT_LOCKED_TABLE_RENDERER); scrollTable.setDefaultRenderer(Class.forName("java.lang.Object"), DEFAULT_SCROLL_TABLE_RENDERER); } catch (ClassNotFoundException e) { // ignore } scrollTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); scrollTable.getSelectionModel().addListSelectionListener(this); scrollTable.getColumnModel().getSelectionModel().addListSelectionListener(this); scrollTable.addFocusListener(this); scrollTable.setBackground(UIHelper.BG_COLOR); UIHelper.renderComponent(scrollTable.getTableHeader(), UIHelper.VER_12_PLAIN, UIHelper.BG_COLOR, new Color(141, 198, 63, 40)); excelAdaptor = new ExcelAdaptor(scrollTable, false); frozenTable.setViewportView(scrollTable); frozenTable.setBorder(em); setupTableTabBehaviour(); JTableHeader lockedHeader = lockedTable.getTableHeader(); setHeaderProperties(lockedTable, lockedTableHeaderRenderer); lockedHeader.setReorderingAllowed(false); frozenTable.setCorner(JScrollPane.UPPER_LEFT_CORNER, lockedHeader); setHeaderProperties(scrollTable, scrollTableHeaderRenderer); JViewport viewport = new JViewport(); viewport.setBackground(UIHelper.BG_COLOR); viewport.setView(lockedTable); frozenTable.setRowHeader(viewport); updateTables(); frozenTable.setPreferredSize(new Dimension(width, height)); frozenTable.getViewport().setBackground(UIHelper.BG_COLOR); frozenTable.getHorizontalScrollBar().setBackground(UIHelper.BG_COLOR); return frozenTable; }
From source file:plugin.notes.gui.NotesView.java
private void refreshTreeNodes() { Object obj = notesTree.getLastSelectedPathComponent(); if (obj instanceof NotesTreeNode) { NotesTreeNode node = (NotesTreeNode) obj; editor = node.getTextPane();/*from ww w .j a v a 2 s.c o m*/ root.checkCache(); // TODO: Uh-oh -- never call gc manually without strong reason // Runtime.getRuntime().gc(); JViewport vp = new JViewport(); vp.setView(editor); jScrollPane2.setViewport(vp); editAreaDT = new DropTarget(editor, new DropEditorListener()); editor.addCaretListener(this::editorCaretUpdate); editor.addKeyListener(new java.awt.event.KeyListener() { @Override public void keyTyped(KeyEvent e) { editorKeyTyped(e); } @Override public void keyPressed(KeyEvent e) { // TODO: Method does nothing? } @Override public void keyReleased(KeyEvent e) { // TODO: Method does nothing? } }); editor.getStyledDocument().addUndoableEditListener(this::editorUndoableEditHappened); if (node.isLeaf()) { deleteButton.setEnabled(true); } else { deleteButton.setEnabled(false); } if (node == root) { exportButton.setEnabled(false); } else { exportButton.setEnabled(true); } if (node.isDirty()) { revertButton.setEnabled(true); } else { revertButton.setEnabled(false); } initFileBar(node.getFiles()); saveButton.setEnabled(true); newButton.setEnabled(true); } else if (obj == null) { deleteButton.setEnabled(false); saveButton.setEnabled(false); revertButton.setEnabled(false); newButton.setEnabled(false); } }