List of usage examples for javax.swing JSplitPane setTopComponent
@BeanProperty(bound = false, description = "The component above, or to the left of the divider.") public void setTopComponent(Component comp)
From source file:com.choicemaker.cm.modelmaker.gui.panels.HoldVsAccuracyPlotPanel.java
private void layoutPanel() { GridBagLayout layout = new GridBagLayout(); setLayout(layout);//from w w w . j a v a 2 s . c o m layout.columnWeights = new double[] { 1f, 0f }; layout.columnWidths = new int[] { 200, 300 }; GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 5, 10); //Row 0.......................................................... //histo c.gridy = 0; c.gridx = 0; c.gridwidth = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; ChartPanel p = new ChartPanel(chart, false, false, false, true, true); // p.setHorizontalZoom(true); // p.setVerticalZoom(true); add(p, c); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setDividerSize(2); splitPane.setContinuousLayout(true); splitPane.setDividerLocation(0.5d); splitPane.setResizeWeight(0.5f); splitPane.setOneTouchExpandable(true); splitPane.setTopComponent(accuracyPanel); splitPane.setBottomComponent(hrPanel); c.gridx = 1; c.gridheight = 1; add(splitPane, c); }
From source file:logdruid.ui.mainpanel.StatRecordingSelectorPanel.java
/** * Create the panel./*from w ww . j ava2 s .c om*/ */ public StatRecordingSelectorPanel(final Repository rep, Source src) { repository = rep; source = src; records = rep.getRecordings(StatRecording.class); // Collections.sort(records); Iterator it = records.iterator(); while (it.hasNext()) { Recording record = (Recording) it.next(); data.add(new Object[] { record.getName(), record.getRegexp(), record.getType(), src.isActiveRecordingOnSource(record) }); } model = new logdruid.ui.mainpanel.StatRecordingSelectorPanel.MyTableModel(data, header); StatRecordingSelectorPanel thiis = this; logger.info("source is " + ((source == null) ? "null" : src.getSourceName())); setLayout(new BorderLayout(0, 0)); JPanel panel_1 = new JPanel(); panel_1.setLayout(new BorderLayout(0, 0)); table = new JTable(model); JScrollPane scrollPane = new JScrollPane(table); panel_1.add(scrollPane, BorderLayout.CENTER); table.setPreferredScrollableViewportSize(new Dimension(0, 150)); table.setFillsViewportHeight(true); table.setAutoCreateRowSorter(true); // Set up column sizes. initColumnSizes(table); JSplitPane splitPane = new JSplitPane(); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); add(splitPane); jPanelDetail = new JPanel(); splitPane.setBottomComponent(jPanelDetail); splitPane.setTopComponent(panel_1); jPanelDetail.setLayout(new BorderLayout(0, 0)); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { int selectedRow = ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1); logger.info("ListSelectionListener - selectedRow: " + selectedRow); if (selectedRow >= 0) { if (jPanelDetail != null) { logger.debug("ListSelectionListener - valueChanged"); jPanelDetail.removeAll(); recEditor = getEditor(repository.getRecording(StatRecording.class, selectedRow)); if (recEditor != null) { jPanelDetail.add(recEditor, BorderLayout.CENTER); } jPanelDetail.revalidate(); } } } }); if (repository.getRecordings(StatRecording.class).size() > 0) { recEditor = getEditor(repository.getRecording(StatRecording.class, 0)); jPanelDetail.add(recEditor, BorderLayout.CENTER); table.setRowSelectionInterval(0, 0); } if (model.getRowCount() > 0) { table.getRowSorter().toggleSortOrder(0); table.setRowSelectionInterval(0, 0); } }
From source file:logdruid.ui.mainpanel.EventRecordingSelectorPanel.java
/** * Create the panel.//www . j ava 2 s . c o m */ public EventRecordingSelectorPanel(final Repository rep, Source src) { repository = rep; source = src; records = rep.getRecordings(EventRecording.class); // Collections.sort(records); Iterator it = records.iterator(); while (it.hasNext()) { Recording record = (Recording) it.next(); data.add(new Object[] { record.getName(), record.getRegexp(), record.getType(), src.isActiveRecordingOnSource(record) }); } model = new logdruid.ui.mainpanel.EventRecordingSelectorPanel.MyTableModel(data, header); logger.info("source is " + ((source == null) ? "null" : src.getSourceName())); JPanel panel_1 = new JPanel(); GridBagConstraints gbc_panel_1 = new GridBagConstraints(); gbc_panel_1.fill = GridBagConstraints.BOTH; gbc_panel_1.insets = new Insets(5, 0, 5, 5); gbc_panel_1.gridx = 1; gbc_panel_1.gridy = 0; panel_1.setLayout(new BorderLayout(0, 0)); table = new JTable(model); JScrollPane scrollPane = new JScrollPane(table); panel_1.add(scrollPane, BorderLayout.CENTER); table.setPreferredScrollableViewportSize(new Dimension(0, 150)); table.setFillsViewportHeight(true); table.setAutoCreateRowSorter(true); // Set up column sizes. initColumnSizes(table); setLayout(new BorderLayout(0, 0)); JSplitPane splitPane = new JSplitPane(); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); add(splitPane); jPanelDetail = new JPanel(); splitPane.setBottomComponent(jPanelDetail); splitPane.setTopComponent(panel_1); GridBagConstraints gbc_jPanelDetail = new GridBagConstraints(); gbc_jPanelDetail.insets = new Insets(0, 0, 0, 5); gbc_jPanelDetail.fill = GridBagConstraints.BOTH; gbc_jPanelDetail.gridx = 1; gbc_jPanelDetail.gridy = 3; jPanelDetail.setLayout(new BorderLayout(0, 0)); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { int selectedRow = ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1); logger.info("ListSelectionListener - selectedRow: " + selectedRow); if (selectedRow >= 0) { if (jPanelDetail != null) { logger.debug("ListSelectionListener - valueChanged"); jPanelDetail.removeAll(); recEditor = getEditor(repository.getRecording(EventRecording.class, selectedRow)); if (recEditor != null) { jPanelDetail.add(recEditor, BorderLayout.CENTER); } jPanelDetail.revalidate(); } } } }); if (repository.getRecordings(EventRecording.class).size() > 0) { recEditor = getEditor(repository.getRecording(EventRecording.class, 0)); jPanelDetail.add(recEditor, BorderLayout.CENTER); table.setRowSelectionInterval(0, 0); } if (model.getRowCount() > 0) { table.getRowSorter().toggleSortOrder(0); table.setRowSelectionInterval(0, 0); } }
From source file:com.choicemaker.cm.modelmaker.gui.panels.AsymmetricThresholdVsAccuracyPlotPanel.java
private void layoutPanel() { setLayout(new BorderLayout()); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setDividerSize(2);/* www. j a v a 2s .c o m*/ splitPane.setContinuousLayout(true); splitPane.setDividerLocation(0.5d); splitPane.setResizeWeight(0.5f); splitPane.setOneTouchExpandable(true); ChartPanel dP = new ChartPanel(dPlot, false, false, false, true, true); // dP.setHorizontalZoom(true); // dP.setVerticalZoom(true); splitPane.setTopComponent(dP); ChartPanel mP = new ChartPanel(mPlot, false, false, false, true, true); // mP.setHorizontalZoom(true); // mP.setVerticalZoom(true); splitPane.setBottomComponent(mP); add(splitPane, BorderLayout.CENTER); }
From source file:logdruid.ui.mainpanel.MetadataRecordingSelectorPanel.java
/** * Create the panel.//from w w w. j ava 2 s . co m */ public MetadataRecordingSelectorPanel(Repository rep, Source src) { repository = rep; source = src; records = rep.getRecordings(MetadataRecording.class); // Collections.sort(records); Iterator it = records.iterator(); while (it.hasNext()) { Recording record = (Recording) it.next(); data.add(new Object[] { record.getName(), record.getRegexp(), record.getType(), src.isActiveRecordingOnSource(record) }); } model = new logdruid.ui.mainpanel.MetadataRecordingSelectorPanel.MyTableModel(data, header); logger.info("source is " + ((source == null) ? "null" : src.getSourceName())); setLayout(new BorderLayout(0, 0)); JPanel panel_1 = new JPanel(); panel_1.setLayout(new BorderLayout(0, 0)); table = new JTable(model); JScrollPane scrollPane = new JScrollPane(table); panel_1.add(scrollPane, BorderLayout.CENTER); table.setPreferredScrollableViewportSize(new Dimension(0, 150)); table.setFillsViewportHeight(true); table.setAutoCreateRowSorter(true); // Set up column sizes. initColumnSizes(table); reloadTable(); JSplitPane splitPane = new JSplitPane(); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); add(splitPane); jPanelDetail = new JPanel(); splitPane.setBottomComponent(jPanelDetail); splitPane.setTopComponent(panel_1); jPanelDetail.setLayout(new BorderLayout(0, 0)); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { // ((table.getSelectedRow()!=-1)?table.convertRowIndexToModel(table.getSelectedRow()):-1) // persist repository // display selected row int selectedRow = ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1); logger.info("ListSelectionListener - selectedRow: " + selectedRow); if (selectedRow >= 0) { if (jPanelDetail != null) { logger.debug("ListSelectionListener - valueChanged"); jPanelDetail.removeAll(); recEditor = getEditor(repository.getRecording(MetadataRecording.class, selectedRow)); if (recEditor != null) { jPanelDetail.add(recEditor, BorderLayout.CENTER); } reloadTable(); jPanelDetail.revalidate(); } } } }); if (repository.getRecordings(MetadataRecording.class).size() > 0) { recEditor = getEditor(repository.getRecording(MetadataRecording.class, 0)); jPanelDetail.add(recEditor, BorderLayout.CENTER); table.setRowSelectionInterval(0, 0); } if (model.getRowCount() > 0) { table.getRowSorter().toggleSortOrder(0); table.setRowSelectionInterval(0, 0); } //reloadTable(); // jPanelDetail.revalidate(); }
From source file:com.intuit.tank.tools.script.ScriptFilterRunner.java
/** * @return/*ww w. j a v a 2 s . c o m*/ */ private Component createContentPanel() { JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true); scriptEditorTA = new RSyntaxTextArea(); setSyntaxStyle(); RTextScrollPane sp = new RTextScrollPane(scriptEditorTA); pane.setTopComponent(sp); JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); JPanel panel = new JPanel(new BorderLayout()); output = new TextAreaOutputLogger(scrollPane, INITIAL_OUTPUT_CONTENT); output.setEditable(false); output.setAutoscrolls(true); output.setScrollContent(true); output.setWrapStyleWord(true); scrollPane.setViewportView(output); JToolBar toolBar = new JToolBar(); JButton clearBT = new JButton("Clear"); clearBT.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { output.setText(INITIAL_OUTPUT_CONTENT); } }); final JCheckBox scrollCB = new JCheckBox("Auto Scroll Content"); scrollCB.setSelected(true); scrollCB.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { output.setScrollContent(scrollCB.isSelected()); } }); toolBar.add(clearBT); toolBar.add(scrollCB); panel.add(toolBar, BorderLayout.NORTH); panel.add(scrollPane, BorderLayout.CENTER); pane.setBottomComponent(panel); pane.setDividerLocation(300); return pane; }
From source file:net.sf.nmedit.nomad.core.Nomad.java
void setupUI() { this.clipBoard = new Clipboard("nomad clipboard"); ApplicationClipboard.setApplicationClipboard(clipBoard); mainWindow.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); mainWindow.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { Nomad.sharedInstance().handleExit(); }/*from w w w . jav a2 s. c om*/ }); pageContainer = new DefaultDocumentManager(); Container contentPane = mainWindow.getContentPane(); explorerTree = new FileExplorerTree(); explorerTree.setFont(new Font("Arial", Font.PLAIN, 11)); explorerTree.createPopup(menuBuilder); JScrollPane explorerTreeScroller = new JScrollPane(explorerTree); toolPane = new JTabbedPane2(); toolPane.setCloseActionEnabled(false); toolPane.addTab("Explorer", getImage("/icons/eview16/filenav_nav.gif"), explorerTreeScroller); new DropTarget(contentPane, new URIListDropHandler() { public void uriListDropped(URI[] uriList) { for (URI uri : uriList) { try { File f = new File(uri); openOrSelect(f); } catch (IllegalArgumentException e) { // ignore } } } }); synthPane = new JTabbedPane2(); synthPane.setCloseActionEnabled(true); JSplitPane sidebarSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false); sidebarSplit.setTopComponent(toolPane); sidebarSplit.setBottomComponent(synthPane); sidebarSplit.setResizeWeight(0.8); sidebarSplit.setOneTouchExpandable(true); /* JComponent sidebar = new JPanel(new BorderLayout()); sidebar.setBorder(null); sidebar.add(sidebarSplit, BorderLayout.CENTER); */ if (!Platform.isFlavor(OS.MacOSFlavor)) { /* JToolBar tb = createQuickActionToolbar(); sidebar.add(tb, BorderLayout.NORTH);*/ } else { registerForMacOSXEvents(); } JSplitPane splitLR = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitLR.setResizeWeight(0); splitLR.setDividerLocation(200); splitLR.setRightComponent(pageContainer); splitLR.setLeftComponent(sidebarSplit); contentPane.setLayout(new BorderLayout()); contentPane.add(splitLR, BorderLayout.CENTER); if (contentPane instanceof JComponent) ((JComponent) contentPane).revalidate(); }
From source file:com.net2plan.gui.tools.GUINetworkDesign.java
@Override public void configure(JPanel contentPane) { this.currentNetPlan = new NetPlan(); BidiMap<NetworkLayer, Integer> mapLayer2VisualizationOrder = new DualHashBidiMap<>(); Map<NetworkLayer, Boolean> layerVisibilityMap = new HashMap<>(); for (NetworkLayer layer : currentNetPlan.getNetworkLayers()) { mapLayer2VisualizationOrder.put(layer, mapLayer2VisualizationOrder.size()); layerVisibilityMap.put(layer, true); }/*from ww w .ja v a2 s . c o m*/ this.vs = new VisualizationState(currentNetPlan, mapLayer2VisualizationOrder, layerVisibilityMap, MAXSIZEUNDOLISTPICK); topologyPanel = new TopologyPanel(this, JUNGCanvas.class); JPanel leftPane = new JPanel(new BorderLayout()); JPanel logSection = configureLeftBottomPanel(); if (logSection == null) { leftPane.add(topologyPanel, BorderLayout.CENTER); } else { JSplitPane splitPaneTopology = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPaneTopology.setTopComponent(topologyPanel); splitPaneTopology.setBottomComponent(logSection); splitPaneTopology.addPropertyChangeListener(new ProportionalResizeJSplitPaneListener()); splitPaneTopology.setBorder(new LineBorder(contentPane.getBackground())); splitPaneTopology.setOneTouchExpandable(true); splitPaneTopology.setDividerSize(7); leftPane.add(splitPaneTopology, BorderLayout.CENTER); } contentPane.add(leftPane, "grow"); viewEditTopTables = new ViewEditTopologyTablesPane(GUINetworkDesign.this, new BorderLayout()); reportPane = new ViewReportPane(GUINetworkDesign.this, JSplitPane.VERTICAL_SPLIT); setCurrentNetPlanDoNotUpdateVisualization(currentNetPlan); Pair<BidiMap<NetworkLayer, Integer>, Map<NetworkLayer, Boolean>> res = VisualizationState .generateCanvasDefaultVisualizationLayerInfo(getDesign()); vs.setCanvasLayerVisibilityAndOrder(getDesign(), res.getFirst(), res.getSecond()); /* Initialize the undo/redo manager, and set its initial design */ this.undoRedoManager = new UndoRedoManager(this, MAXSIZEUNDOLISTCHANGES); this.undoRedoManager.addNetPlanChange(); onlineSimulationPane = new OnlineSimulationPane(this); executionPane = new OfflineExecutionPanel(this); whatIfAnalysisPane = new WhatIfAnalysisPane(this); // Closing windows WindowUtils.clearFloatingWindows(); final JTabbedPane tabPane = new JTabbedPane(); tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.network), viewEditTopTables); tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.offline), executionPane); tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.online), onlineSimulationPane); tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.whatif), whatIfAnalysisPane); tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.report), reportPane); // Installing customized mouse listener MouseListener[] ml = tabPane.getListeners(MouseListener.class); for (int i = 0; i < ml.length; i++) { tabPane.removeMouseListener(ml[i]); } // Left click works as usual, right click brings up a pop-up menu. tabPane.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { JTabbedPane tabPane = (JTabbedPane) e.getSource(); int tabIndex = tabPane.getUI().tabForCoordinate(tabPane, e.getX(), e.getY()); if (tabIndex >= 0 && tabPane.isEnabledAt(tabIndex)) { if (tabIndex == tabPane.getSelectedIndex()) { if (tabPane.isRequestFocusEnabled()) { tabPane.requestFocus(); tabPane.repaint(tabPane.getUI().getTabBounds(tabPane, tabIndex)); } } else { tabPane.setSelectedIndex(tabIndex); } if (!tabPane.isEnabled() || SwingUtilities.isRightMouseButton(e)) { final JPopupMenu popupMenu = new JPopupMenu(); final JMenuItem popWindow = new JMenuItem("Pop window out"); popWindow.addActionListener(e1 -> { final int selectedIndex = tabPane.getSelectedIndex(); final String tabName = tabPane.getTitleAt(selectedIndex); final JComponent selectedComponent = (JComponent) tabPane.getSelectedComponent(); // Pops up the selected tab. final WindowController.WindowToTab windowToTab = WindowController.WindowToTab .parseString(tabName); if (windowToTab != null) { switch (windowToTab) { case offline: WindowController.buildOfflineWindow(selectedComponent); WindowController.showOfflineWindow(true); break; case online: WindowController.buildOnlineWindow(selectedComponent); WindowController.showOnlineWindow(true); break; case whatif: WindowController.buildWhatifWindow(selectedComponent); WindowController.showWhatifWindow(true); break; case report: WindowController.buildReportWindow(selectedComponent); WindowController.showReportWindow(true); break; default: return; } } tabPane.setSelectedIndex(0); }); // Disabling the pop up button for the network state tab. if (WindowController.WindowToTab.parseString(tabPane .getTitleAt(tabPane.getSelectedIndex())) == WindowController.WindowToTab.network) { popWindow.setEnabled(false); } popupMenu.add(popWindow); popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } } }); // Building windows WindowController.buildTableControlWindow(tabPane); WindowController.showTablesWindow(false); addAllKeyCombinationActions(); updateVisualizationAfterNewTopology(); }
From source file:org.jfree.chart.demo.SuperDemo.java
private JPanel createChartDisplayPanel() { displayPanel = new JPanel(new BorderLayout()); chartContainer = new JPanel(new BorderLayout()); chartContainer.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder(Color.black))); chartContainer.add(createNoDemoSelectedPanel()); descriptionContainer = new JPanel(new BorderLayout()); descriptionContainer.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); descriptionContainer.setPreferredSize(new Dimension(600, 140)); descriptionPane = new JTextPane(); descriptionPane.setEditable(false);//from ww w.ja v a 2s. co m JScrollPane jscrollpane = new JScrollPane(descriptionPane, 20, 31); descriptionContainer.add(jscrollpane); displayDescription("select.html"); JSplitPane jsplitpane = new JSplitPane(0); jsplitpane.setTopComponent(chartContainer); jsplitpane.setBottomComponent(descriptionContainer); displayPanel.add(jsplitpane); jsplitpane.setDividerLocation(0.75D); return displayPanel; }
From source file:logdruid.ui.RecordingList.java
/** * Create the panel.//w w w.j a va 2 s. c o m */ public RecordingList(final Repository rep) { if (Preferences.getPreference("timings").equals("true")) { header = (String[]) new String[] { "name", "regexp", "type", "active", "success time", "failed time", "match attempt", "success match" }; } else { header = (String[]) new String[] { "name", "regexp", "type", "active" }; } records = rep.getRecordings(); // Collections.sort(records); Iterator it = records.iterator(); while (it.hasNext()) { Recording record = (Recording) it.next(); stats = DataVault.getRecordingStats(record.getName()); if (stats != null) { data.add(new Object[] { record.getName(), record.getRegexp(), record.getType(), record.getIsActive(), stats[0], stats[1], stats[2], stats[3] }); } else { data.add(new Object[] { record.getName(), record.getRegexp(), record.getType(), record.getIsActive(), 0, 0, 0, 0 }); } } repository = rep; model = new MyTableModel2(data, header); JPanel panel_1 = new JPanel(); GridBagConstraints gbc_panel_1 = new GridBagConstraints(); gbc_panel_1.fill = GridBagConstraints.BOTH; gbc_panel_1.insets = new Insets(5, 0, 5, 5); gbc_panel_1.gridx = 1; gbc_panel_1.gridy = 0; panel_1.setLayout(new BorderLayout(0, 0)); table = new JTable(model); JScrollPane scrollPane = new JScrollPane(table); int column; panel_1.add(scrollPane); table.setPreferredScrollableViewportSize(new Dimension(0, 150)); table.setFillsViewportHeight(true); // Set up column sizes. initColumnSizes(table); table.setAutoCreateRowSorter(true); // RowSorter sorter = table.getRowSorter(); // sorter.setSortKeys(Arrays.asList(new RowSorter.SortKey(0, SortOrder.ASCENDING))); if (model.getRowCount() > 0) { table.getRowSorter().toggleSortOrder(0); table.getRowSorter().toggleSortOrder(2); } table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { int selectedRow = ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1); ; logger.info("ListSelectionListener - selectedRow: " + selectedRow); if (selectedRow >= 0) { if (jPanelDetail != null) { logger.info("ListSelectionListener - valueChanged"); jPanelDetail.removeAll(); recEditor = getEditor(repository.getRecording(selectedRow)); if (recEditor != null) { jPanelDetail.add(recEditor, BorderLayout.CENTER); } jPanelDetail.revalidate(); } } } }); JPanel panel = new JPanel(); FlowLayout flowLayout = (FlowLayout) panel.getLayout(); flowLayout.setAlignment(FlowLayout.LEFT); flowLayout.setVgap(2); flowLayout.setHgap(2); panel_1.add(panel, BorderLayout.SOUTH); JButton btnNewMeta = new JButton("New Meta"); panel.add(btnNewMeta); btnNewMeta.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int rowCount = table.getRowCount(); jPanelDetail.removeAll(); Recording re = new MetadataRecording("name", "regex", "example line", "", true, null); recEditor = new MetadataRecordingEditor(thiis, repository, "the line", "regex", (MetadataRecording) re); jPanelDetail.add(recEditor, BorderLayout.CENTER); repository.addRecording(re); model.addRow( new Object[] { re.getName(), re.getRegexp(), re.getType(), re.getIsActive(), 0, 0, 0, 0 }); model.fireTableRowsInserted(rowCount, rowCount); table.setRowSelectionInterval(rowCount, rowCount); logger.info("New record - row count : " + rowCount); } }); JButton btnDuplicate = new JButton("Duplicate"); btnDuplicate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int rowCount = table.getRowCount(); int selectRow = ((table.getSelectedRow() != -1) ? table.getSelectedRow() : -1); int selectedRow = ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1); repository.addRecording( repository.getRecording(table.convertRowIndexToModel(table.getSelectedRow())).duplicate()); model.fireTableRowsInserted(rowCount, rowCount); table.setRowSelectionInterval(selectRow, selectRow); } }); JButton btnNewStat = new JButton("New Stat"); btnNewStat.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int rowCount = table.getRowCount(); jPanelDetail.removeAll(); Recording re = new StatRecording("name", "regex", "example line", "", true, null); recEditor = new StatRecordingEditor(thiis, repository, "the line", "regex", (StatRecording) re); jPanelDetail.add(recEditor, BorderLayout.CENTER); repository.addRecording(re); model.addRow( new Object[] { re.getName(), re.getRegexp(), re.getType(), re.getIsActive(), 0, 0, 0, 0 }); model.fireTableRowsInserted(rowCount, rowCount); table.setRowSelectionInterval(rowCount, rowCount); logger.info("New record - row count : " + rowCount); } }); panel.add(btnNewStat); JButton btnNewEvent = new JButton("New Event"); btnNewEvent.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int rowCount = table.getRowCount(); logger.info("table.getRowCount()" + table.getRowCount()); jPanelDetail.removeAll(); Recording re = new EventRecording("name", "regex", "example line", "", true, null); recEditor = new EventRecordingEditor(thiis, repository, "the line", "regex", (EventRecording) re); jPanelDetail.add(recEditor, BorderLayout.CENTER); repository.addRecording(re); model.addRow( new Object[] { re.getName(), re.getRegexp(), re.getType(), re.getIsActive(), 0, 0, 0, 0 }); model.fireTableRowsInserted(rowCount, rowCount); table.setRowSelectionInterval(rowCount, rowCount); logger.info("New record - row count : " + rowCount); } }); panel.add(btnNewEvent); panel.add(btnDuplicate); JButton btnDelete = new JButton("Delete"); btnDelete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int rowCount = table.getRowCount(); int selectedRow = ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1); ; int realSelectedRow = table.getSelectedRow(); logger.info("selectedRow : " + selectedRow + ", row count: " + table.getRowCount()); if (rowCount != 0) { repository.deleteRecording(selectedRow); model.fireTableRowsDeleted(selectedRow, selectedRow); // table.remove(selectedRow); if (realSelectedRow != -1) { if (realSelectedRow != 0) table.setRowSelectionInterval(realSelectedRow - 1, realSelectedRow - 1); else if (realSelectedRow > 0) table.setRowSelectionInterval(realSelectedRow, realSelectedRow); else if (rowCount > 1) table.setRowSelectionInterval(0, 0); } /* if (table.getRowCount() > 0) { if (selectedRow == table.getRowCount()) { table.setRowSelectionInterval(selectedRow - 1, selectedRow - 1); } else table.setRowSelectionInterval(selectedRow, selectedRow); }*/ } } }); panel.add(btnDelete); setLayout(new BorderLayout(0, 0)); JSplitPane splitPane = new JSplitPane(); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); add(splitPane, BorderLayout.CENTER); jPanelDetail = new JPanel(); GridBagConstraints gbc_jPanelDetail = new GridBagConstraints(); gbc_jPanelDetail.insets = new Insets(0, 0, 0, 5); gbc_jPanelDetail.fill = GridBagConstraints.BOTH; gbc_jPanelDetail.gridx = 1; gbc_jPanelDetail.gridy = 4; splitPane.setBottomComponent(jPanelDetail); splitPane.setTopComponent(panel_1); jPanelDetail.setLayout(new BorderLayout(0, 0)); if (repository.getRecordingCount() > 0) { //recEditor = getEditor(repository.getRecording(0)); //jPanelDetail.add(recEditor, BorderLayout.CENTER); table.setRowSelectionInterval(0, 0); } jPanelDetail.revalidate(); }