List of usage examples for javax.swing.table DefaultTableModel DefaultTableModel
public DefaultTableModel(Object[][] data, Object[] columnNames)
DefaultTableModel
and initializes the table by passing data
and columnNames
to the setDataVector
method. From source file:md.mclama.com.ModManager.java
/** * Create the frame.//from w w w . jav a 2 s .co m */ @SuppressWarnings("serial") public ModManager() throws MalformedURLException { setResizable(false); setTitle("McLauncher " + McVersion); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 700, 400); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane.setBounds(0, 0, 694, 372); contentPane.add(tabbedPane); profileListMdl = new DefaultListModel<String>(); ModListModel = new DefaultListModel<String>(); listModel = new DefaultListModel<String>(); getCurrentMods(); panelLauncher = new JPanel(); tabbedPane.addTab("Launcher", null, panelLauncher, null); panelLauncher.setLayout(null); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(556, 36, 132, 248); panelLauncher.add(scrollPane); profileList = new JList<String>(profileListMdl); profileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); scrollPane.setViewportView(profileList); btnNewProfile = new JButton("New"); btnNewProfile.setFont(new Font("SansSerif", Font.PLAIN, 12)); btnNewProfile.setBounds(479, 4, 76, 20); panelLauncher.add(btnNewProfile); btnNewProfile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { newProfile(txtProfile.getText()); } }); btnNewProfile.setToolTipText("Click to create a new profile."); JButton btnRenameProfile = new JButton("Rename"); btnRenameProfile.setBounds(479, 25, 76, 20); panelLauncher.add(btnRenameProfile); btnRenameProfile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { renameProfile(); } }); btnRenameProfile.setToolTipText("Click to rename the selected profile"); JButton btnDelProfile = new JButton("Delete"); btnDelProfile.setBounds(479, 50, 76, 20); panelLauncher.add(btnDelProfile); btnDelProfile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deleteProfile(); } }); btnDelProfile.setToolTipText("Click to delete the selected profile."); JButton btnLaunch = new JButton("Launch"); btnLaunch.setBounds(605, 319, 89, 23); panelLauncher.add(btnLaunch); btnLaunch.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (selProfile != null) { LaunchFactorioWithSelectedMods(false); //dont ignore } } }); btnLaunch.setToolTipText("Click to launch factorio with the selected mod profile."); lblAvailableMods = new JLabel("Available Mods"); lblAvailableMods.setBounds(4, 155, 144, 14); panelLauncher.add(lblAvailableMods); lblAvailableMods.setFont(new Font("SansSerif", Font.PLAIN, 10)); lblAvailableMods.setText("Available Mods: " + -1); txtGamePath = new JTextField(); txtGamePath.setBounds(4, 5, 211, 23); panelLauncher.add(txtGamePath); txtGamePath.setToolTipText("Select tha path to your game!"); txtGamePath.setFont(new Font("Tahoma", Font.PLAIN, 8)); txtGamePath.setText("Game Path"); txtGamePath.setColumns(10); JButton btnFind = new JButton("find"); btnFind.setBounds(227, 3, 32, 23); panelLauncher.add(btnFind); txtProfile = new JTextField(); txtProfile.setBounds(556, 2, 132, 22); panelLauncher.add(txtProfile); txtProfile.setToolTipText("The name of NEW or RENAME profiles"); txtProfile.setText("Profile1"); txtProfile.setColumns(10); lblModsEnabled = new JLabel("Mods Enabled: -1"); lblModsEnabled.setBounds(335, 155, 95, 16); panelLauncher.add(lblModsEnabled); lblModsEnabled.setFont(new Font("SansSerif", Font.PLAIN, 10)); JScrollPane scrollPane_1 = new JScrollPane(); scrollPane_1.setBounds(0, 167, 211, 165); panelLauncher.add(scrollPane_1); modsList = new JList<String>(listModel); modsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); modsList.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { String modName = util.getModVersion(modsList.getSelectedValue()); lblModVersion.setText("Mod Version: " + modName); checkDependency(modsList); if (modName.contains(".zip")) { new File(System.getProperty("java.io.tmpdir") + modName.replace(".zip", "")).delete(); } if (System.currentTimeMillis() - lastClickTime <= 300) { //Double click addMod(); } lastClickTime = System.currentTimeMillis(); } }); scrollPane_1.setViewportView(modsList); modsList.setFont(new Font("Tahoma", Font.PLAIN, 9)); JScrollPane scrollPane_2 = new JScrollPane(); scrollPane_2.setBounds(333, 167, 211, 165); panelLauncher.add(scrollPane_2); enabledModsList = new JList<String>(ModListModel); enabledModsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); enabledModsList.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { lblModVersion.setText("Mod Version: " + util.getModVersion(enabledModsList.getSelectedValue())); checkDependency(enabledModsList); if (System.currentTimeMillis() - lastClickTime <= 300) { //Double click removeMod(); } lastClickTime = System.currentTimeMillis(); } }); enabledModsList.setFont(new Font("SansSerif", Font.PLAIN, 10)); scrollPane_2.setViewportView(enabledModsList); JButton btnEnable = new JButton("Enable"); btnEnable.setBounds(223, 200, 90, 28); panelLauncher.add(btnEnable); btnEnable.setToolTipText("Add mod -->"); JButton btnDisable = new JButton("Disable"); btnDisable.setBounds(223, 240, 90, 28); panelLauncher.add(btnDisable); btnDisable.setToolTipText("Disable mod "); JLabel lblModsAvailable = new JLabel("Mods available"); lblModsAvailable.setBounds(4, 329, 89, 14); panelLauncher.add(lblModsAvailable); lblModsAvailable.setFont(new Font("SansSerif", Font.PLAIN, 10)); JLabel lblEnabledMods = new JLabel("Enabled Mods"); lblEnabledMods.setBounds(337, 329, 89, 16); panelLauncher.add(lblEnabledMods); lblEnabledMods.setFont(new Font("SansSerif", Font.PLAIN, 10)); lblModVersion = new JLabel("Mod Version: (select a mod first)"); lblModVersion.setBounds(4, 117, 183, 14); panelLauncher.add(lblModVersion); lblModVersion.setFont(new Font("SansSerif", Font.PLAIN, 10)); lblRequiredMods = new JLabel("Required Mods: " + reqModsStr); lblRequiredMods.setBounds(6, 143, 538, 14); panelLauncher.add(lblRequiredMods); lblRequiredMods.setHorizontalAlignment(SwingConstants.RIGHT); lblRequiredMods.setFont(new Font("SansSerif", Font.PLAIN, 10)); JButton btnNewButton = new JButton("TEST"); btnNewButton.setVisible(testBtnEnabled); btnNewButton.setEnabled(testBtnEnabled); btnNewButton.setBounds(338, 61, 90, 28); panelLauncher.add(btnNewButton); btnUpdate.setBounds(218, 322, 103, 20); panelLauncher.add(btnUpdate); btnUpdate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { util.updateLauncher(); } }); btnUpdate.setVisible(false); btnUpdate.setFont(new Font("SansSerif", Font.PLAIN, 9)); lblModRequires = new JLabel("Mod Requires: (Select a mod first)"); lblModRequires.setBounds(4, 127, 317, 16); panelLauncher.add(lblModRequires); btnLaunchIgnore = new JButton("Launch + ignore"); btnLaunchIgnore.setToolTipText("Ignore any errors that McLauncher may not correctly account for."); btnLaunchIgnore.setFont(new Font("SansSerif", Font.PLAIN, 11)); btnLaunchIgnore.setBounds(556, 284, 133, 23); panelLauncher.add(btnLaunchIgnore); JButton btnConsole = new JButton("Console"); btnConsole.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean changeto = !con.isVisible(); con.setVisible(changeto); con.updateConsole(); } }); btnConsole.setBounds(335, 0, 90, 28); panelLauncher.add(btnConsole); JPanel panelDownloadMods = new JPanel(); tabbedPane.addTab("Download Mods", null, panelDownloadMods, null); panelDownloadMods.setLayout(null); scrollPane_3 = new JScrollPane(); scrollPane_3.setBounds(0, 0, 397, 303); panelDownloadMods.add(scrollPane_3); dlModel = new DefaultTableModel(new Object[][] {}, new String[] { "Mod Name", "Author", "Version", "Tags" }) { Class[] columnTypes = new Class[] { String.class, String.class, String.class, Object.class }; public Class getColumnClass(int columnIndex) { return columnTypes[columnIndex]; } boolean[] columnEditables = new boolean[] { false, false, false, false }; public boolean isCellEditable(int row, int column) { return columnEditables[column]; }; }; tSorter = new TableRowSorter<DefaultTableModel>(dlModel); tableDownloads = new JTable(); tableDownloads.setRowSorter(tSorter); tableDownloads.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { trow = tableDownloads.getSelectedRow(); trow = tableDownloads.getRowSorter().convertRowIndexToModel(trow); getDlModData(); canDownloadMod = true; } }); tableDownloads.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { trow = tableDownloads.getSelectedRow(); trow = tableDownloads.getRowSorter().convertRowIndexToModel(trow); getDlModData(); canDownloadMod = true; } }); tableDownloads.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); tableDownloads.setShowVerticalLines(true); tableDownloads.setShowHorizontalLines(true); tableDownloads.setModel(dlModel); tableDownloads.getColumnModel().getColumn(0).setPreferredWidth(218); tableDownloads.getColumnModel().getColumn(1).setPreferredWidth(97); tableDownloads.getColumnModel().getColumn(2).setPreferredWidth(77); scrollPane_3.setViewportView(tableDownloads); btnDownload = new JButton("Download"); btnDownload.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (canDownloadMod && !CurrentlyDownloading) { String dlUrl = getModDownloadUrl(); try { if (dlUrl.equals("") || dlUrl.equals(" ") || dlUrl == null) { con.log("Log", "No download link for mod, got... '" + dlUrl + "'"); } else { CurrentlyDownloading = true; CurrentDownload = new Download(new URL(dlUrl), McLauncher); } } catch (MalformedURLException e1) { con.log("Log", "Failed to download mod... No download URL?"); } } } }); btnDownload.setBounds(307, 308, 90, 28); panelDownloadMods.add(btnDownload); btnGotoMod = new JButton("Mod Page"); btnGotoMod.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { util.openWebpage(modPageUrl); } }); btnGotoMod.setEnabled(false); btnGotoMod.setBounds(134, 308, 90, 28); panelDownloadMods.add(btnGotoMod); pBarDownloadMod = new JProgressBar(); pBarDownloadMod.setBounds(538, 308, 150, 10); panelDownloadMods.add(pBarDownloadMod); pBarExtractMod = new JProgressBar(); pBarExtractMod.setBounds(538, 314, 150, 10); panelDownloadMods.add(pBarExtractMod); lblDownloadModInfo = new JLabel("Download progress"); lblDownloadModInfo.setBounds(489, 326, 199, 16); panelDownloadMods.add(lblDownloadModInfo); lblDownloadModInfo.setHorizontalAlignment(SwingConstants.TRAILING); panelModImg = new JPanel(); panelModImg.setBounds(566, 0, 128, 128); panelDownloadMods.add(panelModImg); txtFilterText = new JTextField(); txtFilterText.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { if (txtFilterText.getText().equals("Filter Text")) { txtFilterText.setText(""); newFilter(); } } }); txtFilterText.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (!txtFilterText.getText().equals("Filter Text")) { newFilter(); } } }); txtFilterText.setText("Filter Text"); txtFilterText.setBounds(0, 308, 122, 28); panelDownloadMods.add(txtFilterText); txtFilterText.setColumns(10); comboBox = new JComboBox(); comboBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { newFilter(); } }); comboBox.setModel(new DefaultComboBoxModel(new String[] { "No tag filter", "Vanilla", "Machine", "Mechanic", "New Ore", "Module", "Big Mod", "Power", "GUI", "Map-Gen", "Must-Have", "Equipment" })); comboBox.setBounds(403, 44, 150, 26); panelDownloadMods.add(comboBox); lblModDlCounter = new JLabel("Mod database: "); lblModDlCounter.setFont(new Font("SansSerif", Font.PLAIN, 10)); lblModDlCounter.setBounds(403, 5, 162, 16); panelDownloadMods.add(lblModDlCounter); txtrDMModDescription = new JTextArea(); txtrDMModDescription.setBackground(Color.LIGHT_GRAY); txtrDMModDescription.setBorder(new LineBorder(new Color(0, 0, 0))); txtrDMModDescription.setFocusable(false); txtrDMModDescription.setEditable(false); txtrDMModDescription.setLineWrap(true); txtrDMModDescription.setWrapStyleWord(true); txtrDMModDescription.setText("Mod Description: "); txtrDMModDescription.setBounds(403, 132, 285, 75); panelDownloadMods.add(txtrDMModDescription); lblDMModTags = new JTextArea(); lblDMModTags.setFocusable(false); lblDMModTags.setEditable(false); lblDMModTags.setBorder(new LineBorder(new Color(0, 0, 0))); lblDMModTags.setWrapStyleWord(true); lblDMModTags.setLineWrap(true); lblDMModTags.setBackground(Color.LIGHT_GRAY); lblDMModTags.setText("Mod Tags: "); lblDMModTags.setBounds(403, 71, 160, 60); panelDownloadMods.add(lblDMModTags); lblDMRequiredMods = new JTextArea(); lblDMRequiredMods.setFocusable(false); lblDMRequiredMods.setEditable(false); lblDMRequiredMods.setText("Required Mods: "); lblDMRequiredMods.setWrapStyleWord(true); lblDMRequiredMods.setLineWrap(true); lblDMRequiredMods.setBorder(new LineBorder(new Color(0, 0, 0))); lblDMRequiredMods.setBackground(Color.LIGHT_GRAY); lblDMRequiredMods.setBounds(403, 208, 285, 57); panelDownloadMods.add(lblDMRequiredMods); lblDLModLicense = new JLabel(""); lblDLModLicense.setHorizontalAlignment(SwingConstants.RIGHT); lblDLModLicense.setBounds(403, 294, 285, 16); panelDownloadMods.add(lblDLModLicense); lblWipmod = new JLabel(""); lblWipmod.setBounds(395, 314, 64, 16); panelDownloadMods.add(lblWipmod); JButton btnCancel = new JButton("Cancel"); btnCancel.setToolTipText("Stop downloading"); btnCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { CurrentDownload.cancel(); } }); btnCancel.setBounds(230, 308, 72, 28); panelDownloadMods.add(btnCancel); panelOptions = new JPanel(); tabbedPane.addTab("Options", null, panelOptions, null); panelOptions.setLayout(null); scrollPane_4.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane_4.setBounds(0, 0, 694, 342); panelOptions.add(scrollPane_4); panel = new JPanel(); scrollPane_4.setViewportView(panel); panel.setLayout(null); lblCloseMclauncherAfter = new JLabel("Close McLauncher after launching Factorio?"); lblCloseMclauncherAfter.setBounds(6, 6, 274, 16); panel.add(lblCloseMclauncherAfter); lblCloseMclauncherAfter_1 = new JLabel("Close McLauncher after updating?"); lblCloseMclauncherAfter_1.setBounds(6, 34, 274, 16); panel.add(lblCloseMclauncherAfter_1); lblSortNewestDownloadable = new JLabel("Sort newest downloadable mods first?"); lblSortNewestDownloadable.setBounds(6, 62, 274, 16); panel.add(lblSortNewestDownloadable); tglbtnNewModsFirst = new JToggleButton("Toggle"); tglbtnNewModsFirst.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { lblNeedrestart.setText("McLauncher needs to restart for that to work"); writeData(); } }); tglbtnNewModsFirst.setSelected(true); tglbtnNewModsFirst.setBounds(281, 56, 66, 28); panel.add(tglbtnNewModsFirst); tglbtnCloseAfterUpdate = new JToggleButton("Toggle"); tglbtnCloseAfterUpdate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { writeData(); } }); tglbtnCloseAfterUpdate.setBounds(281, 28, 66, 28); panel.add(tglbtnCloseAfterUpdate); tglbtnCloseAfterLaunch = new JToggleButton("Toggle"); tglbtnCloseAfterLaunch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { writeData(); } }); tglbtnCloseAfterLaunch.setBounds(281, 0, 66, 28); panel.add(tglbtnCloseAfterLaunch); tglbtnDisplayon = new JToggleButton("On"); tglbtnDisplayon.setFont(new Font("SansSerif", Font.PLAIN, 10)); tglbtnDisplayon.setSelected(true); tglbtnDisplayon.setBounds(588, 308, 44, 28); panel.add(tglbtnDisplayon); tglbtnDisplayoff = new JToggleButton("Off"); tglbtnDisplayoff.setFont(new Font("SansSerif", Font.PLAIN, 10)); tglbtnDisplayoff.setBounds(644, 308, 44, 28); panel.add(tglbtnDisplayoff); lblInfo = new JLabel("What enabled and disabled look like"); lblInfo.setFont(new Font("SansSerif", Font.PLAIN, 10)); lblInfo.setHorizontalAlignment(SwingConstants.TRAILING); lblInfo.setBounds(359, 314, 231, 16); panel.add(lblInfo); JSeparator separator = new JSeparator(); separator.setBounds(6, 55, 676, 24); panel.add(separator); JSeparator separator_1 = new JSeparator(); separator_1.setBounds(6, 27, 676, 18); panel.add(separator_1); JSeparator separator_2 = new JSeparator(); separator_2.setBounds(6, 84, 676, 24); panel.add(separator_2); JSeparator separator_3 = new JSeparator(); separator_3.setOrientation(SwingConstants.VERTICAL); separator_3.setBounds(346, 0, 16, 336); panel.add(separator_3); lblNeedrestart = new JLabel(""); lblNeedrestart.setBounds(6, 314, 341, 16); panel.add(lblNeedrestart); tglbtnSendAnonData = new JToggleButton("Toggle"); tglbtnSendAnonData.setToolTipText("Information regarding the activity of McLauncher."); tglbtnSendAnonData.setSelected(true); //set enabled by default. tglbtnSendAnonData.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { writeData(); } }); tglbtnSendAnonData.setBounds(622, 0, 66, 28); panel.add(tglbtnSendAnonData); lblSendAnonymousUse = new JLabel("Send anonymous use data?"); lblSendAnonymousUse.setBounds(359, 6, 251, 16); panel.add(lblSendAnonymousUse); lblDeleteOldMod = new JLabel("Delete old mod before updating?"); lblDeleteOldMod.setBounds(359, 34, 251, 16); panel.add(lblDeleteOldMod); tglbtnDeleteBeforeUpdate = new JToggleButton("Toggle"); tglbtnDeleteBeforeUpdate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { writeData(); } }); tglbtnDeleteBeforeUpdate.setBounds(622, 28, 66, 28); panel.add(tglbtnDeleteBeforeUpdate); tglbtnAlertOnModUpdateAvailable = new JToggleButton("Toggle"); tglbtnAlertOnModUpdateAvailable.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { writeData(); } }); tglbtnAlertOnModUpdateAvailable.setSelected(true); tglbtnAlertOnModUpdateAvailable.setBounds(281, 86, 66, 28); panel.add(tglbtnAlertOnModUpdateAvailable); separator_4 = new JSeparator(); separator_4.setBounds(0, 112, 676, 24); panel.add(separator_4); JLabel lblAlertModHas = new JLabel("Alert mod has update on launch?"); lblAlertModHas.setBounds(6, 92, 231, 16); panel.add(lblAlertModHas); panelChangelog = new JPanel(); tabbedPane.addTab("Changelog", null, panelChangelog, null); panelChangelog.setLayout(new BoxLayout(panelChangelog, BoxLayout.X_AXIS)); scrollPane_6 = new JScrollPane(); panelChangelog.add(scrollPane_6); textChangelog = new JTextArea(); scrollPane_6.setViewportView(textChangelog); textChangelog.setEditable(false); textChangelog.setText( "v0.4.6\r\n\r\n+Fix problem where config file would not save in the correct location. (Thanks Arano-kai)\r\n+McLauncher will now save when you select a path, or profile. (Thanks Arano-kai)\r\n+Fixed an issue where McLauncher could not get the version from a .zip mod. (Thanks Arano-kai)\r\n+Added a Cancel button to stop downloading the current mod. (Suggested by Arano-kai)\r\n\r\n\r\n\r\nv0.4.5\r\n\r\n+McLauncher should now correctly warn you on failed write/read access.\r\n+McLauncher should now work when a user has both zip and installer versions of factorio. (Thanks Jeroon)\r\n+Attempt to fix an error with dependency and .zip files, With versions. (Thanks Arano-kai)\r\n+Fix only allow single selection of mods. (Thanks Arano-kai)\r\n+Fix for the Launch+Ignore button problem on linux being cut off. (Thanks Arano-kai)\r\n+Display download progress.\r\n+Fixed an error that was thrown when clicking on some mods that had a single dependency mod.\r\n+Double clicking on a mod will now enable or disable the mod. (Thanks Arano-kai)"); btnLaunchIgnore.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (selProfile != null) { LaunchFactorioWithSelectedMods(true); //ignore errors, launch. } } }); btnLaunchIgnore.setVisible(false); //This is my test button. I use this to test things then implement them into the swing. btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { testButtonCode(e); } }); //Disable mods button. (from profile) btnDisable.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeMod(); } }); //Enable mods button. (to profile) btnEnable.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addMod(); } }); //Game path button btnFind.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { findPath(); } }); //mouseClick event lister for when you click on a new profile profileList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { selectedProfile(); } }); readData(); //Load settings init(); //some extra init getMods(); //Get the mods the user has installed }
From source file:org.fhcrc.cpl.viewer.quant.gui.ProteinQuantSummaryFrame.java
License:asdf
/** * Find all the peptides contributing to the ratio for the FIRST OCCURRENCE of a * protein in the pepXML file, find all quantitative events for those peptides in the * pepXML file, and show them/* w ww . j a v a 2 s. c o m*/ * @param pepXmlFile * @param proteins */ public void displayData(File pepXmlFile, File protXmlFile, List<ProtXmlReader.Protein> proteins) { _log.debug("displayData 1***"); this.protXmlFile = protXmlFile; this.pepXmlFile = pepXmlFile; Collections.sort(proteins, new Comparator<ProtXmlReader.Protein>() { public int compare(ProtXmlReader.Protein o1, ProtXmlReader.Protein o2) { return o1.getProteinName().compareTo(o2.getProteinName()); } }); DefaultTableModel proteinRatiosTableModel = new DefaultTableModel(0, 4) { //all cells uneditable public boolean isCellEditable(int row, int column) { return false; } public Class getColumnClass(int columnIndex) { switch (columnIndex) { case 0: return String.class; case 1: return Float.class; case 2: case 3: return Integer.class; } return String.class; } }; proteinRatiosTable.setModel(proteinRatiosTableModel); proteinRatiosTable.getColumnModel().getColumn(0).setHeaderValue("Protein"); proteinRatiosTable.getColumnModel().getColumn(1).setHeaderValue("Ratio"); proteinRatiosTable.getColumnModel().getColumn(2).setHeaderValue("Quant Peptides"); proteinRatiosTable.getColumnModel().getColumn(3).setHeaderValue("Events"); _log.debug("displayData getting protein info"); this.proteinNames = new ArrayList<String>(); List<ProtXmlReader.QuantitationRatio> quantRatios = new ArrayList<ProtXmlReader.QuantitationRatio>(); proteinRatiosTableModel.setRowCount(proteins.size()); for (int i = 0; i < proteins.size(); i++) { String proteinName = proteins.get(i).getProteinName(); ProtXmlReader.QuantitationRatio quantRatio = proteins.get(i).getQuantitationRatio(); quantRatios.add(quantRatio); proteinNames.add(proteinName); //careful -- the 3rd column values are populated below proteinRatiosTableModel.setValueAt(proteinName, i, 0); proteinRatiosTableModel.setValueAt(Rounder.round(quantRatio.getRatioMean(), 2), i, 1); } if (proteinNames.size() == 1) eventsTable.hideProteinColumn(); if (proteinGenesMap == null) eventsTable.hideGeneColumn(); else { eventsTable.setProteinGenesMap(proteinGenesMap); } TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(proteinRatiosTableModel); proteinRatiosTable.setRowSorter(sorter); contentPanel.updateUI(); _log.debug("displayData getting quant events"); quantEvents = new ArrayList<QuantEvent>(); Map<String, Set<String>> peptideProteinsQuantMap = new HashMap<String, Set<String>>(); for (int i = 0; i < proteins.size(); i++) { for (String peptide : quantRatios.get(i).getPeptides()) { Set<String> proteinsThisPep = peptideProteinsQuantMap.get(peptide); if (proteinsThisPep == null) { proteinsThisPep = new HashSet<String>(); peptideProteinsQuantMap.put(peptide, proteinsThisPep); } proteinsThisPep.add(proteins.get(i).getProteinName()); } } _log.debug("peptideProteinsQuantMap has " + peptideProteinsQuantMap.size() + " peptides."); System.err.println("Contains the one? " + peptideProteinsQuantMap.containsKey("QCPYCLLYK")); proteinEventsMap = new HashMap<String, List<QuantEvent>>(); Map<String, Set<String>> proteinPeptidesMap = new HashMap<String, Set<String>>(); try { PepXMLFeatureFileHandler.PepXMLFeatureSetIterator fsi = new PepXMLFeatureFileHandler.PepXMLFeatureSetIterator( pepXmlFile); int numFractions = 0; setMessage("Loading all pepXML fractions..."); _log.debug("Loading all pepXML fractions..."); while (fsi.hasNext()) { boolean thisFracHasEvents = false; FeatureSet featureSet = fsi.next(); setMessage("Checking fraction " + MS2ExtraInfoDef.getFeatureSetBaseName(featureSet)); _log.debug("Checking fraction " + MS2ExtraInfoDef.getFeatureSetBaseName(featureSet)); String featureSetBaseName = MS2ExtraInfoDef.getFeatureSetBaseName(featureSet); //check all features to see if they're in our list of peptides. If so, add to quantEvents for (Feature feature : featureSet.getFeatures()) { String peptide = MS2ExtraInfoDef.getFirstPeptide(feature); if (peptideProteinsQuantMap.containsKey(peptide) && IsotopicLabelExtraInfoDef.hasRatio(feature)) { thisFracHasEvents = true; //pick up the labeled residue from the first feature // if (labeledResidue == null) // { // AnalyzeICAT.IsotopicLabel label = IsotopicLabelExtraInfoDef.getLabel(feature); // if (label != null) // { // labeledResidue = "" + label.getResidue(); // labelMassDiff = label.getHeavy() - label.getLight(); // _log.debug("Found label: " + labeledResidue + ", " + labelMassDiff); // } // } QuantEvent quantEvent = new QuantEvent(feature, featureSetBaseName); quantEvent.setProtein(new ArrayList<String>(peptideProteinsQuantMap.get(peptide)).get(0)); quantEvents.add(quantEvent); for (String protein : peptideProteinsQuantMap.get(peptide)) { Set<String> peptidesThisProtein = proteinPeptidesMap.get(protein); if (peptidesThisProtein == null) { peptidesThisProtein = new HashSet<String>(); proteinPeptidesMap.put(protein, peptidesThisProtein); } peptidesThisProtein.add(quantEvent.getPeptide()); List<QuantEvent> eventsThisProtein = proteinEventsMap.get(protein); if (eventsThisProtein == null) { eventsThisProtein = new ArrayList<QuantEvent>(); proteinEventsMap.put(protein, eventsThisProtein); } eventsThisProtein.add(quantEvent); } } } if (thisFracHasEvents) numFractions++; } _log.debug("Processed all pepXML fractions "); for (int i = 0; i < proteins.size(); i++) { String protein = proteinNames.get(i); if (proteinPeptidesMap.get(proteinNames.get(i)) != null) proteinRatiosTableModel.setValueAt(proteinPeptidesMap.get(protein).size(), i, 2); if (proteinEventsMap.get(proteinNames.get(i)) != null) proteinRatiosTableModel.setValueAt(proteinEventsMap.get(protein).size(), i, 3); } if (numFractions < 2) { setMessage("Loaded all quantitation events from 1 fraction"); _log.debug("Loaded all quantitation events from 1 fraction"); } else { setMessage("Loaded all quantitation events from " + numFractions + " separate fractions"); _log.debug("Loaded all quantitation events from " + numFractions + " separate fractions"); } // if (labeledResidue == null) // infoMessage("WARNING: unable to determine modification used for quantitation. " + // "Cannot collapse light and heavy states or perform assessment."); // else // { // labelType = QuantitationUtilities.inferLabelType(labeledResidue, labelMassDiff); // } } catch (Exception e) { //check if the file has a .pep.xml extension, in case someone put the wrong file in if (pepXmlFile.getName().toLowerCase().endsWith("pep.xml")) errorMessage("Failed to load features from pepXML file: " + e.getMessage(), e); else { infoMessage("Failed to load pepXML file " + pepXmlFile.getName() + ". Extension is not .pep.xml... did you specify the wrong file?"); e.printStackTrace(System.err); } return; } _log.debug("Done loading quant events. Events: " + quantEvents.size()); if (quantEvents.isEmpty()) { throw new RuntimeException("No quantitation events found!"); } //sort by peptide, then fraction, then charge, then modifications Collections.sort(quantEvents, new QuantEvent.ProteinPeptideFractionChargeModificationsRatioAscComparator()); _log.debug("About to display events..."); displayEvents(); if (quantRatios.size() == 1) { eventsTable.setLogRatioHeaderRatio(quantRatios.get(0).getRatioMean()); } _log.debug("About to update extreme ratio GUI..."); updateExtremeRatioGUI(); }
From source file:at.tuwien.ifs.feature.evaluation.SimilarityRetrievalGUI.java
public JButton initButtonLoad() { JButton buttonLoad = new JButton("Load"); buttonLoad.addActionListener(new ActionListener() { @Override//from ww w . j ava 2s.c o m public void actionPerformed(ActionEvent e) { fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setFileFilter( new ExtensionFileFilterSwing(new String[] { "arff", "vec", "rp", "rh", "ssd", "tfxidf" })); if (fileChooser.getSelectedFile() != null) { // reusing the dialog fileChooser.setSelectedFile(null); } // TODO: remove fileChooser.setSelectedFile( new File("/data/music/ISMIRgenre/vec/mp3_vec_conv_from_wav/ISMIRgenre.rp")); int returnVal = fileChooser.showDialog(SimilarityRetrievalGUI.this, "Open input data"); if (returnVal == JFileChooser.APPROVE_OPTION) { // FIXME: remove dependency on AbstractSOMLibSparseInputData AbstractSOMLibSparseInputData data = (AbstractSOMLibSparseInputData) InputDataFactory .open(fileChooser.getSelectedFile().getAbsolutePath()); String[] newLabels = data.getLabels(); Arrays.sort(newLabels); if (inputData.size() > 0) { // check if the input data files match; if not, don't add this new one String[] existingLabels = inputData.get(0).getLabels(); Arrays.sort(existingLabels); if (!ArrayUtils.isEquals(existingLabels, newLabels)) { JOptionPane.showMessageDialog(SimilarityRetrievalGUI.this, "New data loaded doesn't have the same labels as the existing ones. Aborting", "Error", JOptionPane.ERROR_MESSAGE); System.out.println(Arrays.toString(existingLabels)); System.out.println(Arrays.toString(newLabels)); return; } } inputData.add(data); final InputDataRadioButton rb = new InputDataRadioButton(data); bgInputData.add(rb); rb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String actionCommand = rb.getActionCommand(); System.out.println(actionCommand); } }); if (inputData.size() == 1) { // first time loaded rb.setSelected(true); // enable the retrieval panel panelRetrieval.setEnabled(true); panelLoadedFeatureFiles.remove(labelNoInputData); // populate the combo box for the retrieval comboQueryVector.setModel(new DefaultComboBoxModel(data.getLabels())); modelNumberNeighbours.setMaximum(data.numVectors() - 1); modelNumberNeighbours.setValue(Math.min(5, data.numVectors())); spinnerNumberNeighbours.setToolTipText("Maximum value:" + (data.numVectors() - 1)); btnStart.setEnabled(true); // fill the library tab Object[][] libraryData = new Object[data.numVectors()][]; ImageIcon icon = UiUtils.getIcon(PlayerControl.ICON_PREFIX, "play" + PlayerControl.ICON_SUFFIX); for (int i = 0; i < libraryData.length; i++) { final JButton button = new JButton(icon); final int index = i; button.setActionCommand(String.valueOf(i)); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String label = inputData.get(0).getLabel(index); try { player.stop(); player.play(new MP3VectorMetaData( new File(txtFieldMusicPath.getText() + File.separator + label), label)); } catch (FileNotFoundException e1) { JOptionPane.showMessageDialog(SimilarityRetrievalGUI.this, "Error playing audio file: " + e1.getMessage(), "Playback Error", JOptionPane.ERROR_MESSAGE); e1.printStackTrace(); } } }); libraryData[i] = new Object[] { button, data.getLabel(i), "unknown" }; } databaseDetailsTable .setModel(new DefaultTableModel(libraryData, databaseDetailsColumnNames)); databaseDetailsTable.getColumn(databaseDetailsColumnNames[0]) .setCellEditor(new ButtonCellEditor()); databaseDetailsTable.getColumn("").setCellRenderer(new ButtonCellRenderer()); resizeDatabaseDetailsTableColumns(); buttonLoadClassInfo.setEnabled(true); } panelLoadedFeatureFiles.add(rb); pack(); } } }); return buttonLoad; }
From source file:com.mirth.connect.client.ui.editors.transformer.TransformerPane.java
public void makeTransformerTable() { transformerTable = new MirthTable(); transformerTable.setBorder(BorderFactory.createEmptyBorder()); // Data Column is hidden transformerTable.setModel(new DefaultTableModel(new String[] { "#", "Name", "Type", "Data" }, 0) { public boolean isCellEditable(int rowIndex, int columnIndex) { boolean[] canEdit; TransformerStepPlugin plugin; try { plugin = getPlugin((String) transformerTableModel.getValueAt(rowIndex, STEP_TYPE_COL)); canEdit = new boolean[] { false, plugin.isNameEditable(), true, true }; } catch (Exception e) { canEdit = new boolean[] { false, false, true, true }; }//from w ww. j a v a2 s . c o m return canEdit[columnIndex]; } }); transformerTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); transformerTableModel = (DefaultTableModel) transformerTable.getModel(); transformerTable.getColumnModel().getColumn(STEP_NAME_COL).setCellEditor(new EditorTableCellEditor(this)); transformerTable.setCustomEditorControls(true); // Set the combobox editor on the type column, and add action listener String[] defaultComboBoxValues = new String[LoadedExtensions.getInstance().getTransformerStepPlugins() .size()]; TransformerStepPlugin[] pluginArray = LoadedExtensions.getInstance().getTransformerStepPlugins().values() .toArray(new TransformerStepPlugin[0]); for (int i = 0; i < pluginArray.length; i++) { defaultComboBoxValues[i] = pluginArray[i].getPluginPointName(); } MirthComboBoxTableCellEditor comboBox = new MirthComboBoxTableCellEditor(transformerTable, defaultComboBoxValues, 2, true, new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { if (transformerTable.getEditingRow() != -1) { int row = getSelectedRow(); String selectedType = ((JComboBox) evt.getSource()).getSelectedItem().toString(); String previousType = (String) transformerTable.getValueAt(row, STEP_TYPE_COL); if (selectedType.equalsIgnoreCase(previousType)) { return; } modified = true; invalidVar = false; TransformerStepPlugin plugin = null; try { if (stepPanel.isModified() && !PlatformUI.MIRTH_FRAME.alertOption( PlatformUI.MIRTH_FRAME, "Are you sure you would like to change this transformer step and lose all of the current transformer data?")) { ((JComboBox) evt.getSource()).getModel().setSelectedItem(previousType); return; } plugin = getPlugin(selectedType); plugin.initData(); transformerTableModel.setValueAt(plugin.getNewName(), row, STEP_NAME_COL); stepPanel.showCard(selectedType); updateTaskPane(selectedType); updateCodePanel(selectedType); } catch (Exception e) { parent.alertThrowable(PlatformUI.MIRTH_FRAME, e); } } } }); transformerTable.setSelectionMode(0); // only select one row at a time transformerTable.getColumnExt(STEP_NUMBER_COL).setMaxWidth(UIConstants.MAX_WIDTH); transformerTable.getColumnExt(STEP_TYPE_COL).setMaxWidth(UIConstants.MAX_WIDTH); transformerTable.getColumnExt(STEP_TYPE_COL).setMinWidth(120); transformerTable.getColumnExt(STEP_NUMBER_COL).setPreferredWidth(30); transformerTable.getColumnExt(STEP_TYPE_COL).setPreferredWidth(120); transformerTable.getColumnExt(STEP_NUMBER_COL).setCellRenderer(new CenterCellRenderer()); transformerTable.getColumnExt(STEP_TYPE_COL).setCellEditor(comboBox); transformerTable.getColumnExt(STEP_TYPE_COL) .setCellRenderer(new MirthComboBoxTableCellRenderer(defaultComboBoxValues)); transformerTable.getColumnExt(STEP_DATA_COL).setVisible(false); transformerTable.setRowHeight(UIConstants.ROW_HEIGHT); transformerTable.packTable(UIConstants.COL_MARGIN); transformerTable.setSortable(false); transformerTable.setOpaque(true); transformerTable.setRowSelectionAllowed(true); transformerTable.setDragEnabled(false); transformerTable.getTableHeader().setReorderingAllowed(false); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); transformerTable.setHighlighters(highlighter); } transformerTable.setDropTarget(dropTarget); transformerTablePane.setDropTarget(dropTarget); transformerTable.setBorder(BorderFactory.createEmptyBorder()); transformerTablePane.setBorder(BorderFactory.createEmptyBorder()); transformerTablePane.setViewportView(transformerTable); // listen for mouse clicks on the actual table transformerTable.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent evt) { checkSelectionAndPopupMenu(evt); } public void mouseReleased(MouseEvent evt) { checkSelectionAndPopupMenu(evt); } }); transformerTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { if (!updating && !evt.getValueIsAdjusting()) { TransformerListSelected(evt); updateCodePanel(null); } } }); transformerTable.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { deleteStep(); } } public void keyReleased(KeyEvent e) { } public void keyTyped(KeyEvent e) { } }); }
From source file:nosqltools.MainForm.java
/** * The View_TableActionPerformed is an event handler which sets the Table View * if text is found within the Text View and if correct JSON objects are found * @param evt // w w w .ja v a2s. c om */ private void View_TableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_View_TableActionPerformed if (!textArea.getText().isEmpty()) { Panel_Text.setVisible(false); Panel_Hierarchical.setVisible(false); Panel_Compare.setVisible(false); Panel_Compare_Upper.setVisible(false); Panel_Connect.setVisible(false); //parsing if (json_util.isDataParsed(textArea.getText())) { Panel_Table.setVisible(true); String[] json_field_names = json_util.getFields(); String[][] json_row_data = json_util.getRows(json_field_names); DefaultTableModel model = (DefaultTableModel) Table_JSON.getModel(); Table_JSON.setModel(new DefaultTableModel(json_row_data, json_field_names)); } else //case for incorrect JSON format { Text_MessageBar.setText(Initializations.JSONINCORRECTFORMAT); Text_MessageBar.setForeground(Color.RED); JOptionPane.showMessageDialog(null, Initializations.JSONINCORRECTFORMAT, "Error", JOptionPane.ERROR_MESSAGE); } } else //case for no JSON objects found { Text_MessageBar.setText(Initializations.NOTEXT); Text_MessageBar.setForeground(Color.RED); JOptionPane.showMessageDialog(null, Initializations.NOTEXT, "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:multiplayer.pong.client.LobbyFrame.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor./* w w w. j a v a 2 s .c om*/ */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jScrollPane2 = new javax.swing.JScrollPane(); jScrollPane2.setBackground(Color.WHITE); usernamesT = new javax.swing.JTable(); usernamesT.setBackground(Color.WHITE); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setBackground(new java.awt.Color(0, 0, 0)); usernamesT.setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null }, { null }, { null }, { null } }, new String[] { "Username" }) { boolean[] canEdit = new boolean[] { false }; public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }); usernamesT.setGridColor(new java.awt.Color(0, 0, 0)); usernamesT.setInheritsPopupMenu(true); jScrollPane2.setViewportView(usernamesT); if (usernamesT.getColumnModel().getColumnCount() > 0) { usernamesT.getColumnModel().getColumn(0).setResizable(false); } JLabel lblUtilisateursEnligne = new JLabel("Utilisateurs en-ligne"); lblUtilisateursEnligne.setForeground(new Color(255, 255, 255)); lblUtilisateursEnligne.setFont(new Font("Trebuchet MS", Font.PLAIN, 14)); commandBtn = new JButton("Envoyer"); commandBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { commandBtnActionPerformed(e); } }); JLabel lblLobbyPrincipal = new JLabel("Lobby Principal"); lblLobbyPrincipal.setFont(new Font("Georgia", Font.PLAIN, 70)); lblLobbyPrincipal.setForeground(new Color(255, 255, 255)); lblLobbyPrincipal.setBackground(new Color(0, 0, 0)); scrollPane = new JScrollPane(); scrollPane.setBackground(Color.WHITE); cmdPrompt = new JTextField(); cmdPrompt.setColumns(10); cmdPrompt.grabFocus(); scrollPane_1 = new JScrollPane(); lblWelcome = new JLabel("Bienvenue, " + SocketHandler.username); lblWelcome.setHorizontalAlignment(SwingConstants.RIGHT); lblWelcome.setFont(new Font("Georgia", Font.PLAIN, 18)); lblWelcome.setForeground(Color.WHITE); JLabel label = new JLabel("Amis connect\u00E9s"); label.setForeground(Color.WHITE); label.setFont(new Font("Trebuchet MS", Font.PLAIN, 14)); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout .createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(Alignment.LEADING) .addComponent(scrollPane_1, GroupLayout.PREFERRED_SIZE, 605, GroupLayout.PREFERRED_SIZE) .addComponent(cmdPrompt, 605, 605, 605)) .addPreferredGap(ComponentPlacement.RELATED)) .addGroup(layout.createSequentialGroup() .addComponent(lblLobbyPrincipal, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(120))) .addGroup(layout.createParallelGroup(Alignment.TRAILING) .addComponent(lblUtilisateursEnligne, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE) .addGroup(Alignment.LEADING, layout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED) .addComponent(lblWelcome, GroupLayout.PREFERRED_SIZE, 160, GroupLayout.PREFERRED_SIZE)) .addComponent(commandBtn, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED) .addComponent(label, GroupLayout.PREFERRED_SIZE, 169, GroupLayout.PREFERRED_SIZE)) .addGroup(Alignment.LEADING, layout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED) .addComponent(jScrollPane2, GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)) .addGroup(Alignment.LEADING, layout.createSequentialGroup().addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE))) .addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout .createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(Alignment.TRAILING).addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(Alignment.LEADING) .addComponent(lblLobbyPrincipal, GroupLayout.PREFERRED_SIZE, 85, GroupLayout.PREFERRED_SIZE) .addComponent(lblWelcome, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 164, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(lblUtilisateursEnligne, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(jScrollPane2, GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE)) .addComponent(scrollPane_1, GroupLayout.DEFAULT_SIZE, 432, Short.MAX_VALUE)) .addGap(9) .addGroup( layout.createParallelGroup(Alignment.BASELINE) .addComponent(cmdPrompt, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE) .addComponent(commandBtn)) .addGap(22)) .addGroup(layout.createSequentialGroup() .addComponent(label, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addGap(492))))); ta = new JTextPane(); ta.setEditable(false); ta.setFont(new Font("SansSerif", Font.PLAIN, 14)); scrollPane_1.setViewportView(ta); friendsT = new JTable(); friendsT.setModel(new DefaultTableModel(new Object[][] {}, new String[] { "Username" })); scrollPane.setViewportView(friendsT); getContentPane().setLayout(layout); pack(); }
From source file:com.unsa.view.MainView.java
private void btnSeleccionarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSeleccionarActionPerformed // TODO add your handling code here: //JFileChooser file=new JFileChooser(); file = new JFileChooser(); //FileNameExtensionFilter filter = new FileNameExtensionFilter("PDF & DOC & DOCX Files", "pdf", "docx","doc"); FileNameExtensionFilter filter1 = new FileNameExtensionFilter("PDF", "pdf"); FileNameExtensionFilter filter2 = new FileNameExtensionFilter("DOCX, DOC", "docx", "doc"); //FileNameExtensionFilter filter3 = new FileNameExtensionFilter("DOC","doc"); file.setFileFilter(filter1);/*from w w w .j a v a2 s . c o m*/ file.setFileFilter(filter2); file.setMultiSelectionEnabled(true); file.showOpenDialog(null); File[] abrir = file.getSelectedFiles(); if (abrir.length == 0) { JOptionPane.showMessageDialog(null, "No seleccion ningun archivo"); return; } txtArchivos.setText(abrir[0].getParent()); String[] lnames = { "Nombre Archivo", "Obs. Dudosa", "Obs. Critica", "Abrir Archivo" }; DefaultTableModel model = new DefaultTableModel(lnames, 0); tableSalida.setModel(model); for (File file2 : abrir) { Object[] data = new Object[4]; data[0] = file2.getName(); data[1] = ""; model.addRow(data); } if (lblInstitucion.getText().equals("") || lblSiglas.getText().equals("") || lblIdioma.getText().equals("")) { btnProcesar.setEnabled(false); } else { btnProcesar.setEnabled(true); } }
From source file:simulation.AureoZauleckAnsLab2.java
public static void DisplayTable(ArrayList<ArrayList> all, ArrayList percentages, String title) { JFrame frame = new JFrame(); //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table = new JTable(); table.setModel(new DefaultTableModel((int) (all.size() + 2), 2)); table.setValueAt("VALUE LABELS", 0, 0); table.setValueAt("PERCENTAGE", 0, 1); table.setValueAt("TOTAL = 100%", (int) (all.size() + 1), 1); for (int i = 0; i < all.size(); i++) { table.setValueAt(all.get(i).get(0), i + 1, 0); table.setValueAt(new DecimalFormat("#.##").format(percentages.get(i)), i + 1, 1); }/*from www .ja va2 s.c om*/ JScrollPane scrollPane = new JScrollPane(table); scrollPane.setBorder(BorderFactory.createTitledBorder(title)); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:simulation.AureoZauleckAnsLab2.java
public static void DisplayTables(double k, ArrayList<Double> cl, ArrayList<Double> cl2, ArrayList<Double> tlcl, ArrayList<Double> tucl, ArrayList<Double> midList, ArrayList<ArrayList<Double>> freq, ArrayList<Double> freqPercent, ArrayList<Double> cfs, ArrayList<Double> cps, String title) { JFrame frame = new JFrame(); //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table = new JTable(); table.setModel(new DefaultTableModel((int) (k + 2), 7)); table.setValueAt("CLASS LIMITS", 0, 0); table.setValueAt("TRUE CLASS LIMITS", 0, 1); table.setValueAt("MIDPOINTS", 0, 2); table.setValueAt("FREQUENCY", 0, 3); table.setValueAt("%", 0, 4); table.setValueAt("CF", 0, 5); table.setValueAt("C%", 0, 6); table.setValueAt("n = " + N, (int) (k + 1), 3); table.setValueAt("TOTAL = 100%", (int) (k + 1), 4); for (int i = 0; i < k; i++) { table.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0); table.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1); table.setValueAt(midList.get(i), i + 1, 2); table.setValueAt(freq.get(i).size(), i + 1, 3); table.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4); table.setValueAt(cfs.get(i), i + 1, 5); table.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6); }//from w w w.j ava 2s .com JScrollPane scrollPane = new JScrollPane(table); scrollPane.setBorder(BorderFactory.createTitledBorder(title)); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); Scanner sc = new Scanner(System.in); int type = 0, testT = 0; String typeTest = ""; do { System.out.println(); System.out.println("COLLAPSE CLASS LIMITS?"); System.out.println("[1] COLLAPSE LOWER CLASS LIMIT"); System.out.println("[2] COLLAPSE UPPPER CLASS LIMIT"); System.out.println("[3] COLLAPSE BOTH"); System.out.println("[4] DON'T COLLAPSE"); System.out.println(); System.out.println("Please pick a number from the choices above."); typeTest = sc.next(); if (IsNumber(typeTest)) { testT = Convert(typeTest); } else { do { System.out.println("Please enter a number only."); typeTest = sc.next(); } while (!IsNumber(typeTest)); testT = Convert(typeTest); } type = testT; } while (type < 1 || type > 4); if (type == 1) { JFrame frame2 = new JFrame(); //frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table2 = new JTable(); table2.setModel(new DefaultTableModel((int) (k + 2), 7)); table2.setValueAt("CLASS LIMITS", 0, 0); table2.setValueAt("TRUE CLASS LIMITS", 0, 1); table2.setValueAt("MIDPOINTS", 0, 2); table2.setValueAt("FREQUENCY", 0, 3); table2.setValueAt("%", 0, 4); table2.setValueAt("CF", 0, 5); table2.setValueAt("C%", 0, 6); table2.setValueAt("n = " + N, (int) (k + 1), 3); table2.setValueAt("TOTAL = 100%", (int) (k + 1), 4); for (int i = 0; i < k; i++) { table2.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0); table2.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1); table2.setValueAt(midList.get(i), i + 1, 2); table2.setValueAt(freq.get(i).size(), i + 1, 3); table2.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4); table2.setValueAt(cfs.get(i), i + 1, 5); table2.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6); } table2.setValueAt("below " + cl2.get(0), 1, 0); table2.setValueAt(" - ", 1, 1); table2.setValueAt(" - ", 1, 2); JScrollPane scrollPane2 = new JScrollPane(table2); scrollPane2.setBorder(BorderFactory.createTitledBorder(title)); frame2.add(scrollPane2, BorderLayout.CENTER); frame2.setSize(300, 150); frame2.setVisible(true); } else if (type == 2) { JFrame frame3 = new JFrame(); //frame3.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table3 = new JTable(); table3.setModel(new DefaultTableModel((int) (k + 2), 7)); table3.setValueAt("CLASS LIMITS", 0, 0); table3.setValueAt("TRUE CLASS LIMITS", 0, 1); table3.setValueAt("MIDPOINTS", 0, 2); table3.setValueAt("FREQUENCY", 0, 3); table3.setValueAt("%", 0, 4); table3.setValueAt("CF", 0, 5); table3.setValueAt("C%", 0, 6); table3.setValueAt("n = " + N, (int) (k + 1), 3); table3.setValueAt("TOTAL = 100%", (int) (k + 1), 4); int a = (int) k; for (int i = 0; i < k; i++) { table3.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0); table3.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1); table3.setValueAt(midList.get(i), i + 1, 2); table3.setValueAt(freq.get(i).size(), i + 1, 3); table3.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4); table3.setValueAt(cfs.get(i), i + 1, 5); table3.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6); } table3.setValueAt(cl.get(a - 1) + " above", a, 0); table3.setValueAt(" - ", a, 1); table3.setValueAt(" - ", a, 2); JScrollPane scrollPane3 = new JScrollPane(table3); scrollPane3.setBorder(BorderFactory.createTitledBorder(title)); frame3.add(scrollPane3, BorderLayout.CENTER); frame3.setSize(300, 150); frame3.setVisible(true); } else if (type == 3) { JFrame frame4 = new JFrame(); //frame4.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table4 = new JTable(); table4.setModel(new DefaultTableModel((int) (k + 2), 7)); table4.setValueAt("CLASS LIMITS", 0, 0); table4.setValueAt("TRUE CLASS LIMITS", 0, 1); table4.setValueAt("MIDPOINTS", 0, 2); table4.setValueAt("FREQUENCY", 0, 3); table4.setValueAt("%", 0, 4); table4.setValueAt("CF", 0, 5); table4.setValueAt("C%", 0, 6); table4.setValueAt("n = " + N, (int) (k + 1), 3); table4.setValueAt("TOTAL = 100%", (int) (k + 1), 4); int a = (int) k; for (int i = 0; i < k; i++) { table4.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0); table4.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1); table4.setValueAt(midList.get(i), i + 1, 2); table4.setValueAt(freq.get(i).size(), i + 1, 3); table4.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4); table4.setValueAt(cfs.get(i), i + 1, 5); table4.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6); } table4.setValueAt("below " + cl2.get(0), 1, 0); table4.setValueAt(cl.get(a - 1) + " above", a, 0); table4.setValueAt(" - ", 1, 1); table4.setValueAt(" - ", 1, 2); table4.setValueAt(" - ", a, 1); table4.setValueAt(" - ", a, 2); JScrollPane scrollPane4 = new JScrollPane(table4); scrollPane4.setBorder(BorderFactory.createTitledBorder(title)); frame4.add(scrollPane4, BorderLayout.CENTER); frame4.setSize(300, 150); frame4.setVisible(true); } else { } }
From source file:com.unsa.view.MainView.java
private void btnProcesarActionPerformed(java.awt.event.ActionEvent evt) throws SQLException, IOException {//GEN-FIRST:event_btnProcesarActionPerformed // TODO add your handling code here: if (lblInstitucion.getText().equals("") || lblInstitucion.getText().equals("") || lblIdioma.getText().equals("")) { JOptionPane.showMessageDialog(null, "Una de las opciones generales est vacio"); return;// w w w. j a v a2 s . com } if (jTextField1.getText().equals("")) { JOptionPane.showMessageDialog(null, "No se especific la ruta donde guardar la metadata"); return; } jProgressBar1.setValue(0); jProgressBar1.setStringPainted(true); File[] listOfFiles = file.getSelectedFiles(); int count = 0; for (File file : listOfFiles) { boolean archivo_daniado = false; if (file.isFile()) { System.out.println(file.getName()); if (file.getName().substring(file.getName().length() - 1).equals("x")) { //is a docx try { XWPFDocument doc = new XWPFDocument(new FileInputStream(file)); alg = new AlgorithmsWord(doc.getParagraphs()); } catch (Exception e) { archivo_daniado = true; } } else { //is not a docx try { HWPFDocument doc = new HWPFDocument(new FileInputStream(file)); Range r = doc.getRange(); alg = new AlgorithmsWord(r); } catch (Exception e) { try { XWPFDocument doc = new XWPFDocument(new FileInputStream(file)); alg = new AlgorithmsWord(doc.getParagraphs()); } catch (Exception ex) { archivo_daniado = true; } } } Metadata metadata = null; if (archivo_daniado == true) { metadata = loadMetadataFail(); } else { metadata = loadMetadata(alg); } metadata.setFileName(file.getName()); listMetaData.add(metadata); int val_calculate = (count + 1) * 100 / listOfFiles.length; jProgressBar1.setValue(val_calculate); count++; } } String name = jTextField1.getText(); ExcelController excel = new ExcelController(name, "UNSA", listMetaData); String[] lnames = { "Nombre Archivo", "Obs. Dudosa", "Obs. Critica", "Abrir Archivo" }; DefaultTableModel model = new DefaultTableModel(lnames, 0); tableSalida.setModel(model); int contador = 0; for (Metadata meta : listMetaData) { Object[] data = new Object[4]; data[0] = listOfFiles[contador].getName(); if (meta.getFailGeneral()) { data[1] = "Fail"; data[2] = "Fail"; } else { data[1] = meta.getStadistic().getObservationGeneral() ? "Observacion" : ""; data[2] = meta.getObservacionGeneral() ? "Falta" : ""; } data[3] = "abrir"; model.addRow(data); contador++; } btnAbrirMetadata.setEnabled(true); }