List of usage examples for javax.swing JTabbedPane setSelectedIndex
@BeanProperty(bound = false, preferred = true, description = "The tabbedpane's selected tab index.") public void setSelectedIndex(int index)
From source file:edu.snu.leader.discrete.simulator.SimulatorLauncherGUI.java
JTextPane createErrorPane(String errorMessage, Component component, final JTabbedPane tabbedPane, final int tabIndex) { final JTextPane errorPane = new JTextPane(); errorPane.setEditable(false);/*www . j av a 2s .co m*/ errorPane.setText(errorMessage); errorPane.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent arg0) { errorPane.setBackground(Color.YELLOW); tabbedPane.setSelectedIndex(tabIndex); } @Override public void focusLost(FocusEvent arg0) { errorPane.setBackground(Color.WHITE); } }); component.requestFocusInWindow(); return errorPane; }
From source file:com.polivoto.vistas.Charts.java
private void crearPieChart(Pregunta pregunta) { JTabbedPane tabPanel = new JTabbedPane(); panelGrafica.add(tabPanel);//www. java2 s.c o m //Calcular el nmero N de perfiles. Si N=1, no discriminar por pestanas. //Si son N perfiles (N>2), hacer N+1 pestanas (la ltima representa la //suma de los resultados sin segregacin. int n = pregunta.obtenerCantidadDePerfiles(); System.out.println(" n " + n); if (n > 1) { for (int i = 0; i < n; i++) { JPanel panel = hacerPiePanel(pregunta, pregunta.obtenerResultadoPorPerfil(i).getOpciones()); panel.setName(pregunta.obtenerResultadoPorPerfil(i).getPerfil()); tabPanel.addTab(panel.getName(), panel); } } JPanel panel = hacerPiePanel(pregunta, pregunta.obtenerOpciones()); panel.setName("Todos"); tabPanel.addTab(panel.getName(), panel); tabPanel.setFont(new Font("Roboto", 0, 24)); tabPanel.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { tabIndex = ((JTabbedPane) (e.getSource())).getSelectedIndex(); } }); tabPanel.setSelectedIndex(tabIndex); panelGrafica.add(tabPanel, BorderLayout.CENTER); panelGrafica.repaint(); panelGrafica.revalidate(); }
From source file:org.nuclos.client.layout.wysiwyg.component.properties.PropertyChartPropertyDomainStep.java
@Override public void prepare() { super.prepare(); chart = model.getChart();/*w ww .jav a2 s .co m*/ wysiwygChart = model.getWYSIWYGChart(); String sPrefix = getChartProperty(Chart.PROPERTY_COMBINED_PREFIXES); combinedPrefixes = (sPrefix == null) ? new StringBuffer("") : new StringBuffer(sPrefix); panel = new JPanel(); panel.setLayout(new BorderLayout()); final ChartFunction chartFunction = getChartFunction(); if (!chartFunction.isCombinedChart()) { panel.add(getPanelComponent(chartFunction, ""), BorderLayout.CENTER); } else { JPanel editorType = new JPanel(); editorType.setLayout(new GridBagLayout()); JLabel propTypeValue = new JLabel( //SpringLocaleDelegate.getInstance().getMessage("wysiwyg.chart.wizard.domain.value", "Diagramm hinzufgen:"/*)*/); editorType.add(propTypeValue, new GridBagConstraints(0, 0, 0, 1, 1D, 1D, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0)); final JComboBox propTypeComponent = new JComboBox(chartFunction.getCombinedChartFunctions()); editorType.add(propTypeComponent, new GridBagConstraints(0, 1, 1, 1, 1D, 1D, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 15, 0), 0, 0)); final JTabbedPane tabbedPane = new JTabbedPane(); JButton removeButton = new JButton(iconRemove); removeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (tabbedPane.getSelectedIndex() != -1) { PanelComponent panelComponent = (PanelComponent) tabbedPane.getSelectedComponent(); combinedPrefixes = new StringBuffer( combinedPrefixes.toString().replaceAll(panelComponent.prefix, "")); tabbedPane.remove(panelComponent); } } }); editorType.add(removeButton, new GridBagConstraints(1, 1, 1, 1, 1D, 1D, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0)); JButton addButton = new JButton(iconAdd); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ChartFunction cFunction = (ChartFunction) propTypeComponent.getSelectedItem(); String prefix = cFunction.name() + "." + (Math.random() + "").replaceAll("\\.", "") + ":"; combinedPrefixes.append(prefix); tabbedPane.add(cFunction.name(), getPanelComponent(cFunction, prefix)); tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1); } }); editorType.add(addButton, new GridBagConstraints(2, 1, 1, 1, 1D, 1D, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0)); String[] prefixes = combinedPrefixes.toString().split(":"); for (String prefix : prefixes) { if (prefix.length() > 0) { try { ChartFunction cFunction = ChartFunction.valueOf(prefix.split("\\.")[0]); tabbedPane.add(cFunction.name(), getPanelComponent(cFunction, prefix + ":")); } catch (Exception e) { // ignore. } } } panel.add(editorType, BorderLayout.NORTH); panel.add(tabbedPane, BorderLayout.CENTER); } }
From source file:com.emental.mindraider.ui.frames.MindRaiderMainWindow.java
private MindRaiderMainWindow() { super(MindRaider.getTitle(), Gfx.getGraphicsConfiguration()); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/*from w w w . j a v a2 s . c om*/ } }); // catch resize addComponentListener(this); configuration = new ConfigurationBean(); // drag & drop registration DropTarget dropTarget = new DropTarget(this, (DropTargetListener) this); this.setDropTarget(dropTarget); // warn on different java version // checkJavaVersion(); singleton = this; setIconImage(IconsRegistry.getImage("programIcon.gif")); SplashScreen splash = new SplashScreen(this, false); splash.showSplashScreen(); // kernel init MindRaider.preSetProfiles(); // message in here because of locales logger.debug(Messages.getString("MindRaiderJFrame.bootingKernel")); // master control panel MindRaider.setMasterToolBar(new MasterToolBar()); getContentPane().add(MindRaider.masterToolBar, BorderLayout.NORTH); // status bar getContentPane().add(StatusBar.getStatusBar(), BorderLayout.SOUTH); // build menu buildMenu(MindRaider.spidersGraph); // profile MindRaider.setProfiles(); // left sidebar: folder/notebooks hierarchy, taxonomies, ... final JTabbedPane leftSidebar = new JTabbedPane(SwingConstants.BOTTOM); leftSidebar.setTabPlacement(SwingConstants.TOP); // TODO add icons to tabs leftSidebar.addTab(Messages.getString("MindRaiderJFrame.explorer"), ExplorerJPanel.getInstance()); // TODO just blank panel //leftSidebar.addTab("Tags",new OutlookBarMain()); leftSidebar.addTab( Messages.getString("MindRaiderJFrame.trash"), /* IconsRegistry.getImageIcon("trashFull.png"), */ TrashJPanel.getInstance()); leftSidebar.setSelectedIndex(0); leftSidebar.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { if (arg0.getSource() instanceof JTabbedPane) { if (leftSidebar.getSelectedIndex() == 1) { // refresh trash TrashJPanel.getInstance().refresh(); } } } }); // main panel: (notebook outline & RDF Navigator) + Control panel JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); mainPanel.add(OutlineJPanel.getInstance(), BorderLayout.CENTER); // split: left sidebar/main panel leftSidebarSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftSidebar, mainPanel); leftSidebarSplitPane.setOneTouchExpandable(true); leftSidebarSplitPane.setDividerLocation(200); leftSidebarSplitPane.setLastDividerLocation(200); leftSidebarSplitPane.setDividerSize(6); leftSidebarSplitPane.setContinuousLayout(true); getContentPane().add(leftSidebarSplitPane, BorderLayout.CENTER); Gfx.centerAndShowWindow(this, 1024, 768); MindRaider.postSetProfiles(); if (!configuration.isShowSpidersTagSnailPane()) { OutlineJPanel.getInstance().hideSpiders(); } splash.hideSplash(); }
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); }/* w w 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:com.smanempat.controller.ControllerClassification.java
public String[] processMining(JTextField textNumberOfK, JTable tablePreview, JLabel labelPesanError, JTable tableResult, JLabel labelSiswaIPA, JLabel labelSiswaIPS, JLabel labelKeterangan, JYearChooser jYearChooser1, JYearChooser jYearChooser2, JTabbedPane jTabbedPane1) { String numberValidate = textNumberOfK.getText(); ModelClassification modelClassification = new ModelClassification(); int rowCountModel = modelClassification.getRowCount(); int rowCountData = tablePreview.getRowCount(); System.out.println("Row Count Data : " + rowCountData); System.out.println("Row Count Model : " + rowCountModel); String[] knnValue = null;/*ww w . j a v a2 s . c o m*/ /*Validasi Nilai Number of Nearest Neighbor*/ if (Pattern.matches("[0-9]+", numberValidate) == false && numberValidate.length() > 0) { labelPesanError.setText("Number of Nearest Neighbor tidak valid"); JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak valid!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png")); textNumberOfK.requestFocus(); } else if (numberValidate.isEmpty()) { JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak boleh kosong!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png")); labelPesanError.setText("Number of Nearest Neighbor tidak boleh kosong"); textNumberOfK.requestFocus(); } else if (Integer.parseInt(numberValidate) >= rowCountModel) { labelPesanError.setText("Number of Nearest Neighbor tidak boleh lebih dari " + rowCountModel + ""); JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak boleh lebih dari " + rowCountModel + " !", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png")); textNumberOfK.requestFocus(); } else { int confirm = 0; confirm = JOptionPane.showOptionDialog(null, "Yakin ingin memproses data?", "Proses Klasifikasi", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (confirm == JOptionPane.OK_OPTION) { int kValue = Integer.parseInt(textNumberOfK.getText()); String[][] modelValue = getModelValue(rowCountModel); double[][] dataValue = getDataValue(rowCountData, tablePreview); knnValue = getKNNValue(rowCountData, rowCountModel, modelValue, dataValue, kValue); showClassificationResult(tableResult, tablePreview, knnValue, rowCountData, labelSiswaIPA, labelSiswaIPS, labelKeterangan, jYearChooser1, jYearChooser2, kValue); jTabbedPane1.setSelectedIndex(1); } } return knnValue; }
From source file:com.smanempat.controller.ControllerEvaluation.java
public void proccessMining(JTable tableDataSetModel, JTable tableDataSetTesting, JTextField txtNumberOfK, JLabel labelPesanError, JTabbedPane jTabbedPane1, JTable tableResult, JTable tableConfMatrix, JTable tableTahunTesting, JLabel totalAccuracy, JPanel panelChart, JPanel panelChart1, JPanel panelChart2, JRadioButton singleTesting, JRadioButton multiTesting, JTextArea txtArea) throws SQLException { Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); modelEvaluation = new ModelEvaluation(); int rowCountModel = tableDataSetModel.getRowCount(); int rowCountTest = tableDataSetTesting.getRowCount(); int[] tempK;// ww w . ja va 2s . c o m double[][] tempEval; double[][] evalValue; boolean valid = false; /*Validasi Dataset Model dan Dataset Uji*/ if (rowCountModel == 0) { JOptionPane.showMessageDialog(null, "Pilih dataset model terlebih dahulu!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); txtNumberOfK.requestFocus(); } else if (rowCountTest == 0) { JOptionPane.showMessageDialog(null, "Pilih dataset uji terlebih dahulu!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); txtNumberOfK.requestFocus(); } else { valid = true; } /*Validasi Dataset Model dan Dataset Uji*/ if (valid == true) { if (multiTesting.isSelected()) { String iterasi = JOptionPane.showInputDialog("Input Jumlah Iterasi Pengujian :"); boolean validMulti = false; if (iterasi != null) { /*Validasi Jumlah Iterasi*/ if (Pattern.matches("[0-9]+", iterasi) == false && iterasi.length() > 0) { JOptionPane.showMessageDialog(null, "Nilai iterasi tidak valid!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); } else if (iterasi.isEmpty()) { JOptionPane.showMessageDialog(null, "Nilai iterasi tidak boleh kosong!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); } else if (iterasi.length() == 9) { JOptionPane.showMessageDialog(null, "Nilai iterasi terlalu panjang!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); } else if (rowCountTest > rowCountModel) { JOptionPane.showMessageDialog(null, "Data Uji tidak boleh lebih besar daripada data Model!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); } else { validMulti = true; System.out.println("valiMulti = " + validMulti + " Kok"); } /*Validasi Jumlah Iterasi*/ } if (validMulti == true) { tempK = new int[Integer.parseInt(iterasi)]; evalValue = new double[3][tempK.length]; for (int i = 0; i < Integer.parseInt(iterasi); i++) { validMulti = false; String k = JOptionPane .showInputDialog("Input Nilai Nearest Neighbor (k) ke " + (i + 1) + " :"); if (k != null) { /*Validasi Nilai K Tiap Iterasi*/ if (Pattern.matches("[0-9]+", k) == false && k.length() > 0) { JOptionPane.showMessageDialog(null, "Nilai nearest neighbor (k) tidak valid!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); } else if (k.isEmpty()) { JOptionPane.showMessageDialog(null, "Nilai nearest neighbor (k) tidak boleh kosong!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); } else if (k.length() == 9) { JOptionPane.showMessageDialog(null, "Nilai nearest neighbor (k) terlalu panjang!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); } else { validMulti = true; } /*Validasi Nilai K Tiap Iterasi*/ } if (validMulti == true) { tempK[i] = Integer.parseInt(k); System.out.println(tempK[i]); } else { break; } } if (validMulti == true) { for (int i = 0; i < tempK.length; i++) { int kValue = tempK[i]; String[][] modelValue = getModelValue(rowCountModel, tableDataSetModel); double[][] testValue = getTestvalue(rowCountTest, tableDataSetTesting); String[] knnValue = getKNNValue(rowCountModel, rowCountTest, modelValue, testValue, kValue); tempEval = evaluationModel(tableResult, tableConfMatrix, totalAccuracy, tableTahunTesting, tableDataSetTesting, knnValue, i, tempK, panelChart); //Menampung nilai Accuracy evalValue[0][i] = tempEval[0][i]; //Menampung nilai Recall evalValue[1][i] = tempEval[1][i]; //Menampung nilai Precision evalValue[2][i] = tempEval[2][i]; jTabbedPane1.setSelectedIndex(1); txtArea.append( "Tingkat Keberhasilan Sistem dengan Nilai Number of Nearest Neighbor (K) = " + tempK[i] + "\n"); txtArea.append("Akurasi\t\t: " + evalValue[0][i] * 100 + " %\n"); txtArea.append("Recall\t\t: " + evalValue[1][i] * 100 + " %\n"); txtArea.append("Precision\t: " + evalValue[2][i] * 100 + " %\n"); txtArea.append( "=============================================================================\n"); } showChart(tempK, evalValue, panelChart, panelChart1, panelChart2); } } } else if (singleTesting.isSelected()) { boolean validSingle = false; String k = txtNumberOfK.getText(); int nilaiK = 0; evalValue = new double[3][1]; /*Validasi Nilai Number of Nearest Neighbor*/ if (Pattern.matches("[0-9]+", k) == false && k.length() > 0) { labelPesanError.setText("Number of Nearest Neighbor tidak valid"); JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak valid!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); txtNumberOfK.requestFocus(); } else if (k.isEmpty()) { JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak boleh kosong!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); labelPesanError.setText("Number of Nearest Neighbor tidak boleh kosong"); txtNumberOfK.requestFocus(); } else if (rowCountModel == 0 && Integer.parseInt(k) >= rowCountModel) { JOptionPane.showMessageDialog(null, "Pilih dataset model terlebih dahulu!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); txtNumberOfK.requestFocus(); } else if (rowCountTest == 0 && Integer.parseInt(k) >= rowCountTest) { JOptionPane.showMessageDialog(null, "Pilih dataset uji terlebih dahulu!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); txtNumberOfK.requestFocus(); } else if (Integer.parseInt(k) >= rowCountModel) { JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak boleh lebih dari " + rowCountModel + " !", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png"))); txtNumberOfK.requestFocus(); } else { validSingle = true; nilaiK = Integer.parseInt(k); } /*Validasi Nilai Number of Nearest Neighbor*/ if (validSingle == true) { int confirm; int i = 0; confirm = JOptionPane.showOptionDialog(null, "Yakin ingin memproses data?", "Proses Klasifikasi", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (confirm == JOptionPane.OK_OPTION) { int kValue = Integer.parseInt(txtNumberOfK.getText()); String[][] modelValue = getModelValue(rowCountModel, tableDataSetModel); double[][] testValue = getTestvalue(rowCountTest, tableDataSetTesting); String[] knnValue = getKNNValue(rowCountModel, rowCountTest, modelValue, testValue, kValue); tempEval = evaluationModel(tableResult, tableConfMatrix, totalAccuracy, tableTahunTesting, tableDataSetTesting, knnValue, nilaiK, panelChart); evalValue[0][i] = tempEval[0][0]; evalValue[1][i] = tempEval[1][0]; evalValue[2][i] = tempEval[2][0]; jTabbedPane1.setSelectedIndex(1); } System.out.println("com.smanempat.controller.ControllerEvaluation.proccessMining()OKOKOK"); showChart(nilaiK, evalValue, panelChart, panelChart1, panelChart2); Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); } } } }
From source file:org.freeplane.core.resources.components.OptionPanel.java
/** * This method builds the preferences panel. * A list of IPropertyControl is iterated through and * if the IPropertyControl is an instance of TabProperty, * it creates a new "tab" that can be clicked to reveal the appropriate panel. * If the previous selected tab was saved on close, * the appropriate tab is reopened.//from ww w. j av a 2 s . c o m * * @param controlsTree This is the data that needs to be built */ public void buildPanel(final DefaultMutableTreeNode controlsTree) { final JPanel centralPanel = new JPanel(); centralPanel.setLayout(new GridLayout(1, 1)); final JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); FormLayout bottomLayout = null; DefaultFormBuilder bottomBuilder = null; initControls(controlsTree); final Iterator<IPropertyControl> iterator = controls.iterator(); int tabIndex = 0; while (iterator.hasNext()) { final IPropertyControl control = iterator.next(); if (control instanceof TabProperty) { final TabProperty newTab = (TabProperty) control; bottomLayout = new FormLayout(newTab.getName(), ""); bottomBuilder = new DefaultFormBuilder(bottomLayout); bottomBuilder.setDefaultDialogBorder(); final JScrollPane bottomComponent = new JScrollPane(bottomBuilder.getPanel()); UITools.setScrollbarIncrement(bottomComponent); final String tabName = TextUtils.getOptionalText(newTab.getLabel()); tabStringToIndexMap.put(tabName, tabIndex); tabIndexToStringMap.put(tabIndex, tabName); tabbedPane.addTab(tabName, bottomComponent); tabIndex++; } else { control.layout(bottomBuilder); } } tabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(final ChangeEvent event) { final JTabbedPane c = (JTabbedPane) event.getSource(); selectedPanel = tabIndexToStringMap.get(c.getSelectedIndex()); } }); centralPanel.add(tabbedPane); if (selectedPanel != null && tabStringToIndexMap.containsKey(selectedPanel)) { // Without the containsKey call the loading of the tab "behaviour"/"behavior" gives a nullpointer exception tabbedPane.setSelectedIndex(tabStringToIndexMap.get(selectedPanel)); } topDialog.getContentPane().add(centralPanel, BorderLayout.CENTER); final JButton cancelButton = new JButton(); MenuBuilder.setLabelAndMnemonic(cancelButton, TextUtils.getRawText("cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { closeWindow(); } }); final JButton okButton = new JButton(); MenuBuilder.setLabelAndMnemonic(okButton, TextUtils.getRawText("ok")); okButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { if (validate()) { closeWindow(); feedback.writeProperties(getOptionProperties()); } } }); topDialog.getRootPane().setDefaultButton(okButton); topDialog.getContentPane().add(ButtonBarFactory.buildOKCancelBar(cancelButton, okButton), BorderLayout.SOUTH); }
From source file:org.nuclos.client.genericobject.GenericObjectCollectController.java
private void selectTabPane(CollectableGenericObjectWithDependants clct) { // select tab in state //Integer iState = (Integer)clct.getField(NuclosEOField.STATENUMBER.getMetaData().getField()).getValueId(); DynamicAttributeVO vo = clct.getGenericObjectCVO() .getAttribute(NuclosEOField.STATENUMBER.getMetaData().getId().intValue()); if (vo == null) return;/*from ww w . j a v a 2 s . c om*/ Integer iState = (Integer) vo.getValue(); String strTabName = getPreferences().get(TABSELECTED, ""); for (StateVO voState : StateDelegate.getInstance().getStatesByModule(getModuleId())) if (voState.getNumeral().equals(iState)) { if (voState.getTabbedPaneName() != null) strTabName = voState.getTabbedPaneName(); break; } JComponent jcomp = layoutrootDetails.getRootComponent(); List<JTabbedPane> lst = new ArrayList<JTabbedPane>(); searchTabbedPanes(jcomp, lst); for (JTabbedPane tabPane : lst) for (int i = 0; i < tabPane.getTabCount(); i++) if (org.apache.commons.lang.StringUtils.equals(tabPane.getComponentAt(i).getName(), strTabName) || org.apache.commons.lang.StringUtils.equals(tabPane.getTitleAt(i), strTabName)) { tabPane.setSelectedIndex(i); break; } adjustTabbedPanes(lst); }
From source file:pl.otros.logview.api.OtrosApplication.java
public void addClosableTab(String name, String tooltip, Icon icon, JComponent component, boolean show) { JTabbedPane tabbedPane = getJTabbedPane(); if (tabbedPane.indexOfComponent(component) == -1) { int tabCount = tabbedPane.getTabCount(); tabbedPane.addTab(name, icon, component); tabbedPane.setTabComponentAt(tabCount, new TabHeader(tabbedPane, name, icon, tooltip)); tabbedPane.setSelectedIndex(tabCount); }//from w w w . ja v a2 s . c o m if (show) { tabbedPane.setSelectedComponent(component); } }