List of usage examples for javax.swing JTable JTable
public JTable()
JTable
that is initialized with a default data model, a default column model, and a default selection model. From source file:com.titan.storagepanel.DownloadImageDialog.java
public DownloadImageDialog(final Frame frame) { super(frame, true); setTitle("Openstack vm os image"); setBounds(100, 100, 947, 706);//w w w . java2s . c om getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(new BorderLayout(0, 0)); { JPanel panel = new JPanel(); contentPanel.add(panel, BorderLayout.NORTH); panel.setLayout(new MigLayout("", "[41px][107.00px][27px][95.00px][24px][95.00px][]", "[27px]")); { JLabel lblSearch = new JLabel("Search"); panel.add(lblSearch, "cell 0 0,alignx left,aligny center"); } { searchTextField = new JSearchTextField(); searchTextField.setPreferredSize(new Dimension(150, 40)); panel.add(searchTextField, "cell 1 0,growx,aligny center"); } { JLabel lblType = new JLabel("Type"); panel.add(lblType, "cell 2 0,alignx left,aligny center"); } { typeComboBox = new JComboBox( new String[] { "All", "Ubuntu", "Fedora", "Redhat", "CentOS", "Gentoo", "Windows" }); panel.add(typeComboBox, "cell 3 0,growx,aligny top"); } { JLabel lblSize = new JLabel("Size"); panel.add(lblSize, "cell 4 0,alignx left,aligny center"); } { sizeComboBox = new JComboBox(new String[] { "0-700MB", ">700MB" }); panel.add(sizeComboBox, "cell 5 0,growx,aligny top"); } { JButton btnSearch = new JButton("Search"); btnSearch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { d.setVisible(true); } }); panel.add(btnSearch, "cell 6 0"); } } { JScrollPane scrollPane = new JScrollPane(); contentPanel.add(scrollPane, BorderLayout.CENTER); { table = new JTable(); table.setModel(tableModel); table.addMouseListener(new JTableButtonMouseListener(table)); table.addMouseMotionListener(new JTableButtonMouseListener(table)); scrollPane.setViewportView(table); } } { JPanel panel = new JPanel(); getContentPane().add(panel, BorderLayout.SOUTH); { JButton downloadButton = new JButton("Download"); downloadButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (table.getSelectedRowCount() == 1) { JFileChooser jf = new JFileChooser(); int x = jf.showSaveDialog(frame); if (x == JFileChooser.APPROVE_OPTION) { DownloadImage p = (DownloadImage) table.getValueAt(table.getSelectedRow(), 0); DownloadFileDialog d = new DownloadFileDialog(frame, "Downloading image", true, p.file, jf.getSelectedFile()); CommonLib.centerDialog(d); d.setVisible(true); } } } }); panel.add(downloadButton); } } d = new JProgressBarDialog(frame, true); d.progressBar.setIndeterminate(true); d.progressBar.setStringPainted(true); d.thread = new Thread() { public void run() { InputStream in = null; tableModel.columnNames.clear(); tableModel.columnNames.add("image"); tableModel.editables.clear(); tableModel.editables.put(0, true); Vector<Object> col1 = new Vector<Object>(); try { d.progressBar.setString("connecting to titan image site"); in = new URL("http://titan-image.kingofcoders.com/titan-image.xml").openStream(); String xml = IOUtils.toString(in); NodeList list = TitanCommonLib.getXPathNodeList(xml, "/images/image"); for (int x = 0; x < list.getLength(); x++) { DownloadImage downloadImage = new DownloadImage(); downloadImage.author = TitanCommonLib.getXPath(xml, "/images/image[" + (x + 1) + "]/author/text()"); downloadImage.authorEmail = TitanCommonLib.getXPath(xml, "/images/image[" + (x + 1) + "]/authorEmail/text()"); downloadImage.License = TitanCommonLib.getXPath(xml, "/images/image[" + (x + 1) + "]/License/text()"); downloadImage.description = TitanCommonLib.getXPath(xml, "/images/image[" + (x + 1) + "]/description/text()"); downloadImage.file = TitanCommonLib.getXPath(xml, "/images/image[" + (x + 1) + "]/file/text()"); downloadImage.os = TitanCommonLib.getXPath(xml, "/images/image[" + (x + 1) + "]/os/text()"); downloadImage.osType = TitanCommonLib.getXPath(xml, "/images/image[" + (x + 1) + "]/osType/text()"); downloadImage.uploadDate = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse( TitanCommonLib.getXPath(xml, "/images/image[" + (x + 1) + "]/uploadDate/text()")); downloadImage.size = TitanCommonLib.getXPath(xml, "/images/image[" + (x + 1) + "]/size/text()"); downloadImage.architecture = TitanCommonLib.getXPath(xml, "/images/image[" + (x + 1) + "]/architecture/text()"); col1.add(downloadImage); } } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(frame, "Unable to connect titan image site !", "Error", JOptionPane.ERROR_MESSAGE); } finally { IOUtils.closeQuietly(in); } tableModel.values.clear(); tableModel.values.add(col1); tableModel.fireTableStructureChanged(); table.getColumnModel().getColumn(0).setCellRenderer(new DownloadImageTableCellRenderer()); // table.getColumnModel().getColumn(0).setCellEditor(new DownloadImageTableCellEditor()); for (int x = 0; x < table.getRowCount(); x++) { table.setRowHeight(x, 150); } } }; d.setVisible(true); }
From source file:gdt.jgui.tool.JEntityEditor.java
private void showElement(Sack entity, String element$) { try {//from w ww . j a v a 2s . c om // System.out.println("EntityEditor:showElement:"+element$); Core[] ca = null; if ("attributes".equals(element$)) ca = entity.attributesGet(); else ca = entity.elementGet(element$); final JTable table = new JTable(); DefaultTableModel model = new DefaultTableModel(null, new String[] { "type", "name", "value" }); table.setModel(model); table.getTableHeader().setDefaultRenderer(new SimpleHeaderRenderer()); table.getTableHeader().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int col = table.columnAtPoint(e.getPoint()); String name = table.getColumnName(col); // System.out.println("Column index selected " + col + " " + name); sort(name); } }); JScrollPane scrollPane = new JScrollPane(); tabbedPane.add(element$, scrollPane); scrollPane.add(table); scrollPane.setViewportView(table); if (ca != null) for (Core aCa : ca) { model.addRow(new String[] { aCa.type, aCa.name, aCa.value }); } } catch (Exception e) { LOGGER.severe(e.toString()); } }
From source file:com.opendoorlogistics.studio.components.geocoder.SearchResultsPanel.java
SearchResultsPanel(final NominatimConfig config, final GeocodeModel model) { this.model = model; this.config = config; // server selector at top serverBox = Controls.createServerBox(config.getServer()); serverBox.addValueChangedListener(new ValueChangedListener<String>() { @Override//ww w . j av a 2 s. c om public void comboValueChanged(String newValue) { updateAppearance(); } }); countryCode = Controls.createCountryBox(config.getCountryCode()); countryCode.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { updateAppearance(); } }); // refresh button by server selector refresh = new JButton(Icons.loadFromStandardPath("view-refresh-6.png")); refresh.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { refreshResults(); } }); refresh.setToolTipText("Re-run the query"); // add the controls addLine(Controls.createServerLabel(), serverBox); addWhitespace(6); addLine(Controls.createCountryFilterLabel(), countryCode, Box.createRigidArea(new Dimension(10, 1)), refresh); addWhitespace(); // results table in the middle table = new JTable(); table.setColumnSelectionAllowed(false); table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { readSelectedIntoModel(); } }); table.setFillsViewportHeight(true); JScrollPane scrollPane = new JScrollPane(table); add(scrollPane); setTableModel(); model.addListener(this); updateAppearance(); }
From source file:de.juwimm.cms.gui.admin.PanUnitGroupPerUser.java
void jbInit() throws Exception { this.setLayout(new GridBagLayout()); this.unitPickData = new PickListData(); this.unitPickData.setLeftLabel(rb.getString("panel.admin.tab.units.assigned")); this.unitPickData.setRightLabel(rb.getString("panel.admin.tab.units.all")); this.groupPickData = new PickListData(); this.groupPickData.setLeftLabel(rb.getString("panel.admin.tab.groups.assigned")); this.groupPickData.setRightLabel(rb.getString("panel.admin.tab.groups.all")); this.panUnitPick = new PickListPanel(this.unitPickData); this.panGroupPick = new PickListPanel(this.groupPickData); this.btnSave.setText(rb.getString("dialog.save")); this.lblUser.setText(rb.getString("panel.login.username")); this.btnSave.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { save();/*from www . ja va 2s. c o m*/ } }); this.tblUser = new JTable(); JScrollPane scrollUser = new NoResizeScrollPane(tblUser); this.add(lblUser, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 5, 0), 0, 0)); this.add(scrollUser, new GridBagConstraints(0, 1, 1, 2, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 10, 0, 0), 0, 0)); this.add(btnSave, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(10, 10, 10, 0), 0, 0)); this.add(this.panUnitPick, new GridBagConstraints(1, 0, 1, 2, 2.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 10, 0, 10), 0, 0)); this.add(this.panGroupPick, new GridBagConstraints(1, 2, 1, 1, 2.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 10, 0, 10), 0, 0)); }
From source file:edu.harvard.mcz.imagecapture.SpecimenBrowser.java
/** * This method initializes jTable /*from ww w . java 2s .c o m*/ * * @return javax.swing.JTable */ private JTable getJTable() { if (jTable == null) { jTable = new JTable(); jTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); //jTable.setAutoCreateRowSorter(true); SpecimenLifeCycle s = new SpecimenLifeCycle(); SpecimenListTableModel model = null; if (searchCriteria == null) { model = new SpecimenListTableModel(s.findAll()); } else { if (useLike) { model = new SpecimenListTableModel(s.findByExampleLike(searchCriteria)); } else { model = new SpecimenListTableModel(s.findByExample(searchCriteria)); } } jTable.setModel(model); sorter = new TableRowSorter<SpecimenListTableModel>(model); jTable.setRowSorter(sorter); //jTable.setDefaultRenderer(Long.class, new ButtonRenderer()); //jTable.setDefaultEditor(Long.class, new ButtonEditor()); jTable.setDefaultRenderer(Specimen.class, new ButtonRenderer()); jTable.setDefaultEditor(Specimen.class, new ButtonEditor()); // set some column widths int characterWidth = Singleton.getSingletonInstance().getCharacterWidth(); jTable.getColumnModel().getColumn(0).setPreferredWidth(characterWidth * 5); jTable.getColumnModel().getColumn(1).setPreferredWidth(characterWidth * 14); } return jTable; }
From source file:simulation.AureoZauleckAnsLab2.java
/** * *//*from w w w . j a v a2s . c o m*/ public AureoZauleckAnsLab2() { // TODO code application logic here Scanner sc = new Scanner(System.in); String choice_s = ""; int choice = 0; do { DisplayMenu(); choice_s = sc.next(); String title = ""; Scanner s = new Scanner(System.in); //test input if (IsNumber(choice_s)) { choice = Convert(choice_s); } else { do { System.out.println("Please enter a number only."); choice_s = sc.next(); } while (!IsNumber(choice_s)); choice = Convert(choice_s); } if (choice == 1) { System.out.println("*** CATEGORICAL ***"); System.out.println(); System.out.println("TITLE(title of data set)"); //sc = new Scanner(System.in); title = s.nextLine(); System.out.println("this is the title: " + title); ArrayList a = new ArrayList<>(); ArrayList<Double> percentages = new ArrayList<>(); ArrayList<ArrayList> all; a = GetData(); Collections.sort(a); all = Stratified(a); System.out.println("GROUPED DATA: " + all); System.out.println("size " + all.size()); double percent = 0.0, sum = 0.0; for (int i = 0; i < all.size(); i++) { ArrayList inner = new ArrayList<>(); inner = all.get(i); //System.out.println(inner); int inner_n = inner.size(); percent = GetPercentage(N, inner_n); percentages.add(percent); sum += percent; System.out.println("" + inner.get(0) + "\t" + " " + percent); } System.out.println("\t" + "total " + Math.ceil(sum)); System.out.println("all = " + all); 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); } JScrollPane scrollPane = new JScrollPane(table); scrollPane.setBorder(BorderFactory.createTitledBorder(title)); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); int type = 0, testT = 0; String typeTest = ""; do { System.out.println("GENERATE GRAPH?"); System.out.println("[1] YES"); System.out.println("[2] NO"); 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 > 2); if (type == 1) { DefaultPieDataset dataset = new DefaultPieDataset(); for (int i = 0; i < all.size(); i++) { dataset.setValue( all.get(i).get(0).toString() + " = " + new DecimalFormat("#.##").format(percentages.get(i)) + "%", percentages.get(i)); } JFreeChart chart = ChartFactory.createPieChart(title, // chart title dataset, // data true, // include legend true, false); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(560, 367)); JFrame l = new JFrame(); l.setContentPane(chartPanel); l.setSize(400, 400); l.setVisible(true); } else { //do nothing? } int type2 = 0, testT2 = 0; String typeTest2 = ""; do { System.out.println("REDISPLAY TABLE?"); System.out.println("[1] YES"); System.out.println("[2] NO"); System.out.println(); System.out.println("Please pick a number from the choices above."); typeTest2 = sc.next(); if (IsNumber(typeTest2)) { testT2 = Convert(typeTest2); } else { do { System.out.println("Please enter a number only."); typeTest2 = sc.next(); } while (!IsNumber(typeTest2)); testT2 = Convert(typeTest2); } type2 = testT2; } while (type2 < 1 || type2 > 2); if (type2 == 1) { DisplayTable(all, percentages, title); } else { //do nothing? } } else if (choice == 2) { System.out.println("*** NUMERICAL ***"); System.out.println(); System.out.println("TITLE(title of data set)"); title = s.nextLine(); System.out.println("this is the title " + title); ArrayList<Double> a = new ArrayList<>(); //ArrayList<ArrayList> all; //a = GetData2(); double[] arr = { 70, 36, 43, 69, 82, 48, 34, 62, 35, 15, 59, 139, 46, 37, 42, 30, 55, 56, 36, 82, 38, 89, 54, 25, 35, 24, 22, 9, 55, 19 }; /* double[] arr = {112, 100, 127,120,134,118,105,110,109,112, 110, 118, 117, 116, 118, 122, 114, 114, 105, 109, 107, 112, 114, 115, 118, 117, 118, 122, 106, 110, 116, 108, 110, 121, 113, 120, 119, 111, 104, 111, 120, 113, 120, 117, 105, 110, 118, 112, 114, 114}; */ N = arr.length; double t = 0.0; for (int i = 0; i < N; i++) { a.add(arr[i]); } Collections.sort(a); System.out.println("sorted a " + a); double min = (double) a.get(0); double max = (double) a.get(N - 1); System.out.println("Min" + min); System.out.println("Max" + max); double k = Math.ceil(1 + 3.322 * Math.log10(N)); System.out.println("K " + k); double range = GetRange(min, max); System.out.println("Range " + range); double width = Math.ceil(range / k); //todo, i ceiling sa 1st decimal point System.out.println("Width " + width); ArrayList<Double> cl = new ArrayList<>(); cl.add(min); double rest; for (int i = 1; i < k; i++) { cl.add(min += width); } ArrayList<Double> cl2 = new ArrayList<>(); double cl2min = cl.get(1) - 1; cl2.add(cl2min); for (int i = 1; i < k; i++) { cl2.add(cl2min += width); } System.out.println("cl 1 " + cl); System.out.println("cl 2 " + cl2); ArrayList<Double> tlcl = new ArrayList<>(); double tlclmin = cl.get(0) - Multiplier(cl.get(0)); tlcl.add(tlclmin); for (int i = 1; i < k; i++) { tlcl.add(tlclmin += width); } ArrayList<Double> tucl = new ArrayList<>(); double tuclmin = cl2.get(0) + Multiplier(cl2.get(0)); tucl.add(tuclmin); for (int i = 1; i < k; i++) { tucl.add(tuclmin += width); } System.out.println("tlcl 1 " + tlcl); System.out.println("tucl 2 " + tucl); System.out.println("N " + N); ArrayList<Double> midList = new ArrayList<>(); double mid = (cl.get(0) + cl2.get(0)) / 2; midList.add(mid); for (int i = 1; i < k; i++) { midList.add((tlcl.get(i) + tucl.get(i)) / 2); } for (int i = 0; i < k; i++) { System.out.println((tlcl.get(i) + tucl.get(i)) / 2); } System.out.println("mid" + midList); ArrayList<ArrayList<Double>> freq = new ArrayList<>(); double ctr = 0.0; for (int j = 0; j < k; j++) { for (int i = 0; i < N; i++) { if ((a.get(i) >= tlcl.get(j)) && (a.get(i) <= tucl.get(j))) { freq.add(new ArrayList<Double>()); freq.get(j).add(a.get(i)); } } } ArrayList<Double> freqSize = new ArrayList<>(); double size = 0.0; for (int i = 0; i < k; i++) { size = (double) freq.get(i).size(); freqSize.add(size); } ArrayList<Double> freqPercent = new ArrayList<>(); for (int i = 0; i < k; i++) { freqPercent.add(freqSize.get(i) / N * 100); } ArrayList<Double> cfs = new ArrayList<>(); double cf = freqSize.get(0); cfs.add(cf); for (int i = 1; i < k; i++) { cf = freqSize.get(i) + cfs.get(i - 1); cfs.add(cf); } double sum = 0.0; for (int i = 1; i < cfs.size(); i++) { sum += cfs.get(i); } ArrayList<Double> cps = new ArrayList<>(); double cp = 0.0; for (int i = 0; i < k; i++) { cp = (cfs.get(i) / N) * 100; cps.add(cp); } System.out.println("T o t a l: " + sum); System.out.println(cfs); System.out.println(cps); System.out.println("frequency list " + freq); System.out.println("frequency sizes " + freqSize); System.out.println("frequency percentages " + freqPercent); System.out.println(); System.out.println(title); System.out.println("CLASS LIMITS" + "\t" + "T CLASS LIMITS" + "\t" + "MID" + "\t" + "FREQ" + "\t" + "PERCENT" + "\t" + "CF" + "\t" + "CP"); for (int i = 0; i < k; i++) { System.out.println(cl.get(i) + " - " + cl2.get(i) + "\t" + tlcl.get(i) + " - " + tucl.get(i) + "\t" + midList.get(i) + "\t" + freq.get(i).size() + "\t" + new DecimalFormat("#.##").format(freqPercent.get(i)) + "\t" + cfs.get(i) + "\t" + new DecimalFormat("#.##").format(cps.get(i))); } //2 System.out.println("CLASS LIMITS" + "\t" + "T C L" + "\t" + "MID" + "\t" + "FREQ" + "\t" + "PERCENT" + "\t" + "CF" + "\t" + "CP"); for (int i = 0; i < k; i++) { System.out.println(">=" + cl.get(i) + "\t\t" + " - " + "\t" + " - " + "\t" + freq.get(i).size() + "\t" + new DecimalFormat("#.##").format(freqPercent.get(i)) + "\t" + cfs.get(i) + "\t" + new DecimalFormat("#.##").format(cps.get(i))); } //3 System.out.println("CLASS LIMITS" + "\t" + "T C L" + "\t" + "MID" + "\t" + "FREQ" + "\t" + "PERCENT" + "\t" + "CF" + "\t" + "CP"); for (int i = 0; i < k; i++) { System.out.println("<=" + cl2.get(i) + "\t\t" + " - " + "\t" + " - " + "\t" + freq.get(i).size() + "\t" + new DecimalFormat("#.##").format(freqPercent.get(i)) + "\t" + cfs.get(i) + "\t" + new DecimalFormat("#.##").format(cps.get(i))); } System.out.println("CLASS LIMITS" + "\t" + "T CLASS LIMITS" + "\t" + "MID" + "\t" + "FREQ" + "\t" + "PERCENT" + "\t" + "CF" + "\t" + "CP"); for (int i = 0; i < k; i++) { System.out.println(">=" + cl.get(i) + " and <=" + cl2.get(i) + "\t" + " - " + "\t" + " - " + "\t" + freq.get(i).size() + "\t" + new DecimalFormat("#.##").format(freqPercent.get(i)) + "\t" + cfs.get(i) + "\t" + new DecimalFormat("#.##").format(cps.get(i))); } DisplayTables(k, cl, cl2, tlcl, tucl, midList, freq, freqPercent, cfs, cps, title); int type = 0, testT = 0; String typeTest = ""; do { do { System.out.println(); System.out.println("GENERATE GRAPH?"); System.out.println("[1] YES"); System.out.println("[2] NO"); 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 > 2); if (type == 1) { int bins = (int) k; System.out.println(); System.out.println("You may input a label for your X axis:"); String x = ""; x = s.nextLine(); createHistogram(a, bins, title, x); int type2 = 0, testT2 = 0; String typeTest2 = ""; do { System.out.println(); System.out.println("REDISPLAY TABLE?"); System.out.println("[1] YES"); System.out.println("[2] NO"); System.out.println(); System.out.println("Please pick a number from the choices above."); typeTest2 = sc.next(); if (IsNumber(typeTest2)) { testT2 = Convert(typeTest2); } else { do { System.out.println("Please enter a number only."); typeTest2 = sc.next(); } while (!IsNumber(typeTest2)); testT2 = Convert(typeTest2); } type2 = testT2; } while ((type2 < 1 || type2 > 2) && type != 2); if (type2 == 1) { DisplayTables(k, cl, cl2, tlcl, tucl, midList, freq, freqPercent, cfs, cps, title); } else { //do nothing? } } } while (type != 2); } else if (choice == 3) { System.out.println("*** QUIT ***"); } } while (choice != 3); System.out.println("Thank you for your time."); s = new Simulation(); }
From source file:com.vgi.mafscaling.OpenLoop.java
private void createRunTables(JPanel dataRunPanel) { GridBagConstraints gbc_run = new GridBagConstraints(); gbc_run.anchor = GridBagConstraints.PAGE_START; gbc_run.insets = new Insets(0, 2, 0, 2); for (int i = 0; i < RunCount; ++i) { runTables[i] = new JTable(); JTable table = runTables[i]; table.getTableHeader().setReorderingAllowed(false); table.setModel(new DefaultTableModel(RunRowsCount, 3)); table.setColumnSelectionAllowed(true); table.setCellSelectionEnabled(true); table.setBorder(new LineBorder(new Color(0, 0, 0))); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table.getColumnModel().getColumn(0) .setHeaderValue("<html><center>Engine<br>Speed<br>(RPM)<br></center></html>"); table.getColumnModel().getColumn(1) .setHeaderValue("<html><center>MAF<br>Sensor<br>Voltage<br></center></html>"); table.getColumnModel().getColumn(2) .setHeaderValue("<html><center>AFR<br>Error<br>%<br></center></html>"); Utils.initializeTable(table, ColumnWidth); excelAdapter.addTable(table, true, false); gbc_run.gridx = i;// ww w .ja v a2 s . c o m gbc_run.gridy = 0; dataRunPanel.add(table.getTableHeader(), gbc_run); gbc_run.gridy = 1; dataRunPanel.add(table, gbc_run); } }
From source file:com.sciaps.view.SpectrumShotPanel.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./*from w w w .j a v a 2 s . com*/ */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; btnCreateAvg_ = new javax.swing.JButton(); btnHideShot_ = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); btnDeleteScan_ = new javax.swing.JButton(); btnDelete_ = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); tblShots_ = new JTable() { //Implement table cell tool tips. @Override public String getToolTipText(MouseEvent e) { String tip = null; java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); int colIndex = columnAtPoint(p); try { tip = getValueAt(rowIndex, colIndex).toString(); } catch (RuntimeException e1) { //catch null pointer exception if mouse is over an empty line } return tip; } }; btnShowShotl_ = new javax.swing.JButton(); btnBackgroundRemoval_ = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); txtSampleRate_ = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); txtFilterText_ = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); btnBackgroundRemoval_1 = new javax.swing.JButton(); btnBackgroundRemoval_2 = new javax.swing.JButton(); btnAnalyze_ = new javax.swing.JButton(); setMaximumSize(new java.awt.Dimension(160, 190)); setMinimumSize(new java.awt.Dimension(160, 190)); setPreferredSize(new java.awt.Dimension(160, 190)); setLayout(new java.awt.GridBagLayout()); btnCreateAvg_.setText("Create Shot Avg"); btnCreateAvg_.setToolTipText("Create An Avg of All Highlighted"); btnCreateAvg_.setMargin(new java.awt.Insets(2, 2, 2, 2)); btnCreateAvg_.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCreateAvg_ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 14; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(btnCreateAvg_, gridBagConstraints); btnHideShot_.setText("Hide Shot(s)"); btnHideShot_.setToolTipText("Hide Shot Series"); btnHideShot_.setMargin(new java.awt.Insets(2, 2, 2, 2)); btnHideShot_.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnHideShot_ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 12; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(btnHideShot_, gridBagConstraints); jLabel1.setBackground(new java.awt.Color(204, 204, 204)); jLabel1.setText("Shot List:"); jLabel1.setOpaque(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(jLabel1, gridBagConstraints); btnDeleteScan_.setText("Delete Scan"); btnDeleteScan_.setToolTipText("Delete All Shots In A Scan"); btnDeleteScan_.setMargin(new java.awt.Insets(2, 2, 2, 2)); btnDeleteScan_.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnDeleteScan_ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 10; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(btnDeleteScan_, gridBagConstraints); btnDelete_.setText("Delete Shot(s)"); btnDelete_.setToolTipText("Delete Shot(s)"); btnDelete_.setMargin(new java.awt.Insets(2, 2, 2, 2)); btnDelete_.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnDelete_ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 13; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(btnDelete_, gridBagConstraints); jLabel2.setBackground(new java.awt.Color(204, 204, 204)); jLabel2.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel2.setText("Scan Data"); jLabel2.setFocusable(false); jLabel2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jLabel2.setOpaque(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 0); add(jLabel2, gridBagConstraints); tblShots_ .setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); tblShots_.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { tblShots_MouseClicked(evt); } }); jScrollPane2.setViewportView(tblShots_); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 5; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; add(jScrollPane2, gridBagConstraints); btnShowShotl_.setText("Show Shot(s)"); btnShowShotl_.setToolTipText("Show Shot Series"); btnShowShotl_.setMargin(new java.awt.Insets(2, 2, 2, 2)); btnShowShotl_.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnShowShotl_ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 11; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(btnShowShotl_, gridBagConstraints); btnBackgroundRemoval_.setText("Background Removal"); btnBackgroundRemoval_.setToolTipText("Remove background noise for the selected shots"); btnBackgroundRemoval_.setMargin(new java.awt.Insets(2, 2, 2, 2)); btnBackgroundRemoval_.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnBackgroundRemoval_ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 7; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(btnBackgroundRemoval_, gridBagConstraints); jPanel1.setLayout(new java.awt.GridBagLayout()); txtSampleRate_.setText("30"); txtSampleRate_.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { txtSampleRate_KeyReleased(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(0, 0, 1, 0); jPanel1.add(txtSampleRate_, gridBagConstraints); jLabel3.setBackground(new java.awt.Color(204, 204, 204)); jLabel3.setText("Sample Rate:"); jLabel3.setOpaque(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 5); jPanel1.add(jLabel3, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(4, 0, 0, 0); jPanel1.add(txtFilterText_, gridBagConstraints); jLabel4.setBackground(new java.awt.Color(204, 204, 204)); jLabel4.setText("Filter:"); jLabel4.setOpaque(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 5); jPanel1.add(jLabel4, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; add(jPanel1, gridBagConstraints); btnBackgroundRemoval_1.setText("Find Peak"); btnBackgroundRemoval_1.setToolTipText("Find the peaks"); btnBackgroundRemoval_1.setMargin(new java.awt.Insets(2, 2, 2, 2)); btnBackgroundRemoval_1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnBackgroundRemoval_1ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 9; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(btnBackgroundRemoval_1, gridBagConstraints); btnBackgroundRemoval_2.setText("Normalize Spectrum"); btnBackgroundRemoval_2.setToolTipText("Normalize a spectrum"); btnBackgroundRemoval_2.setMargin(new java.awt.Insets(2, 2, 2, 2)); btnBackgroundRemoval_2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnBackgroundRemoval_2ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 8; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(btnBackgroundRemoval_2, gridBagConstraints); btnAnalyze_.setText("Analyze"); btnAnalyze_.setToolTipText("Analyze a spectrum"); btnAnalyze_.setMargin(new java.awt.Insets(2, 2, 2, 2)); btnAnalyze_.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAnalyze_ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 6; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(btnAnalyze_, gridBagConstraints); }
From source file:gtu._work.ui.SvnLastestCommitInfoUI.java
private void initGUI() { try {//ww w . ja v a2 s . c o m BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); this.setFocusable(false); this.setTitle("SVN lastest commit wather"); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("svn dir", null, jPanel1, null); { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); { TableModel svnTableModel = new DefaultTableModel(); svnTable = new JTable(); jScrollPane1.setViewportView(svnTable); svnTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { try { if (evt.getButton() == 3) { final List<File> list = new ArrayList<File>(); SvnFile svnFile = null; final StringBuilder sb = new StringBuilder(); for (int row : svnTable.getSelectedRows()) { svnFile = (SvnFile) svnTable.getModel().getValueAt( svnTable.getRowSorter().convertRowIndexToModel(row), SvnTableColumn.SVN_FILE.pos); list.add(svnFile.file); sb.append(svnFile.file.getName() + ","); } if (sb.length() > 200) { sb.delete(200, sb.length() - 1); } JMenuItem copySelectedMeun = new JMenuItem(); copySelectedMeun.setText("copy selected file : " + list.size()); copySelectedMeun.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil .newInstance().iconPlainMessage().confirmButtonYesNo() .showConfirmDialog( "are you sure copy files :\n" + sb + "\n???", "COPY SELECTED FILE : " + list.size())) { return; } final File copyToDir = JFileChooserUtil.newInstance() .selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (copyToDir == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("dir folder is not correct!", "ERROR"); return; } new Thread(Thread.currentThread().getThreadGroup(), new Runnable() { public void run() { StringBuilder errMsg = new StringBuilder(); int errCount = 0; for (File f : list) { try { FileUtil.copyFile(f, new File(copyToDir, f.getName())); } catch (IOException e) { e.printStackTrace(); errCount++; errMsg.append(f + "\n"); } } JOptionPaneUtil.newInstance().iconPlainMessage() .showMessageDialog( "copy completed!\nerror : " + errCount + "\nerror list : \n" + errMsg, "COMPLETED"); } }, "copySelectedFiles_" + hashCode()).start(); } }); JMenuItem copySelectedOringTreeMeun = new JMenuItem(); copySelectedOringTreeMeun .setText("copy selected file (orign tree): " + list.size()); copySelectedOringTreeMeun.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil .newInstance().iconPlainMessage().confirmButtonYesNo() .showConfirmDialog( "are you sure copy files :\n" + sb + "\n???", "COPY SELECTED FILE : " + list.size())) { return; } final File copyToDir = JFileChooserUtil.newInstance() .selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (copyToDir == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("dir folder is not correct!", "ERROR"); return; } new Thread(Thread.currentThread().getThreadGroup(), new Runnable() { public void run() { File srcBaseDir = FileUtil .exportReceiveBaseDir(list); int cutLength = 0; if (srcBaseDir != null) { cutLength = srcBaseDir.getAbsolutePath() .length(); } StringBuilder errMsg = new StringBuilder(); int errCount = 0; File newFile = null; for (File f : list) { try { newFile = new File(copyToDir + "/" + f.getAbsolutePath() .substring(cutLength), f.getName()); newFile.getParentFile().mkdirs(); FileUtil.copyFile(f, newFile); } catch (IOException e) { e.printStackTrace(); errCount++; errMsg.append(f + "\n"); } } JOptionPaneUtil.newInstance().iconPlainMessage() .showMessageDialog( "copy completed!\nerror : " + errCount + "\nerror list : \n" + errMsg, "COMPLETED"); } }, "copySelectedFiles_orignTree_" + hashCode()).start(); } }); JPopupMenuUtil.newInstance(svnTable).applyEvent(evt) .addJMenuItem(copySelectedMeun, copySelectedOringTreeMeun) .show(); } if (!JMouseEventUtil.buttonLeftClick(2, evt)) { return; } int row = JTableUtil.newInstance(svnTable).getSelectedRow(); SvnFile svnFile = (SvnFile) svnTable.getModel().getValueAt(row, SvnTableColumn.SVN_FILE.pos); String command = String.format("cmd /c call \"%s\"", svnFile.file); System.out.println(command); try { Runtime.getRuntime().exec(command); } catch (IOException e) { e.printStackTrace(); } } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); svnTable.setModel(svnTableModel); JTableUtil.defaultSetting(svnTable); } } { jPanel3 = new JPanel(); jPanel1.add(jPanel3, BorderLayout.NORTH); jPanel3.setPreferredSize(new java.awt.Dimension(379, 35)); { filterText = new JTextField(); jPanel3.add(filterText); filterText.setPreferredSize(new java.awt.Dimension(258, 24)); filterText.getDocument() .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() { public void process(DocumentEvent event) { try { String scanText = JCommonUtil.getDocumentText(event); reloadSvnTable(scanText, _defaultScanProcess); } catch (Exception ex) { JCommonUtil.handleException(ex); } } })); } { choiceSvnDir = new JButton(); jPanel3.add(choiceSvnDir); choiceSvnDir.setText("choice svn dir"); choiceSvnDir.setPreferredSize(new java.awt.Dimension(154, 24)); choiceSvnDir.addActionListener(new ActionListener() { Pattern svnOutputPattern = Pattern .compile("\\s*(\\d*)\\s+(\\d+)\\s+(\\w+)\\s+([\\S]+)"); public void actionPerformed(ActionEvent evt) { try { System.out.println("choiceSvnDir.actionPerformed, event=" + evt); final File svnDir = JFileChooserUtil.newInstance().selectDirectoryOnly() .showOpenDialog().getApproveSelectedFile(); if (svnDir == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("dir is not correct!", "ERROR"); return; } Thread thread = new Thread(Thread.currentThread().getThreadGroup(), new Runnable() { public void run() { long startTime = System.currentTimeMillis(); String command = String .format("cmd /c svn status -v \"%s\"", svnDir); Matcher matcher = null; try { long projectLastestVersion = 0; SvnFile svnFile = null; Process process = Runtime.getRuntime().exec(command); BufferedReader reader = new BufferedReader( new InputStreamReader(process.getInputStream(), "BIG5")); for (String line = null; (line = reader .readLine()) != null;) { matcher = svnOutputPattern.matcher(line); if (matcher.find()) { try { if (StringUtils .isNotBlank(matcher.group(1))) { projectLastestVersion = Math.max( projectLastestVersion, Long.parseLong( matcher.group(1))); } svnFile = new SvnFile(); svnFile.lastestVersion = Long .parseLong(matcher.group(2)); svnFile.author = matcher.group(3); svnFile.filePath = matcher.group(4); svnFile.file = new File(svnFile.filePath); svnFile.fileName = svnFile.file.getName(); svnFileSet.add(svnFile); authorSet.add(svnFile.author); String extension = null; if (svnFile.file.isFile() && (extension = getExtension( svnFile.fileName)) != null) { fileExtenstionSet.add(extension); } } catch (Exception ex) { ex.printStackTrace(); } } else { System.out.println("ignore : " + line); } } reader.close(); lastestVersion = projectLastestVersion; projectName = svnDir.getName(); resetUiAndShowMessage(startTime, projectName, projectLastestVersion); } catch (IOException e) { JCommonUtil.handleException(e); } } }, "loadSvnLastest_" + this.hashCode()); thread.setDaemon(true); thread.start(); setTitle("sweeping..."); } catch (Exception ex) { JCommonUtil.handleException(ex); } } String getExtension(String name) { int pos = -1; if ((pos = name.lastIndexOf(".")) != -1) { return name.substring(pos).toLowerCase(); } return null; } }); } { jLabel1 = new JLabel(); jPanel3.add(jLabel1); jLabel1.setText("match :"); jLabel1.setPreferredSize(new java.awt.Dimension(56, 22)); } { matchCount = new JLabel(); jPanel3.add(matchCount); matchCount.setPreferredSize(new java.awt.Dimension(82, 22)); } } } { jPanel2 = new JPanel(); FlowLayout jPanel2Layout = new FlowLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("config", null, jPanel2, null); { DefaultComboBoxModel authorComboBoxModel = new DefaultComboBoxModel(); authorComboBox = new JComboBox(); jPanel2.add(authorComboBox); authorComboBox.setModel(authorComboBoxModel); authorComboBox.setPreferredSize(new java.awt.Dimension(260, 24)); authorComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { Object author = authorComboBox.getSelectedItem(); if (author instanceof Map.Entry) { Map.Entry<?, ?> entry = (Map.Entry<?, ?>) author; reloadSvnTable((String) entry.getKey(), _authorScanProcess); } else { reloadSvnTable((String) author, _authorScanProcess); } } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(); fileExtensionComboBox = new JComboBox(); jPanel2.add(fileExtensionComboBox); fileExtensionComboBox.setModel(jComboBox1Model); fileExtensionComboBox.setPreferredSize(new java.awt.Dimension(186, 24)); fileExtensionComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { String extension = (String) fileExtensionComboBox.getSelectedItem(); reloadSvnTable(extension, _fileExtensionScanProcess); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { jScrollPane2 = new JScrollPane(); jScrollPane2.setPreferredSize(new java.awt.Dimension(130, 200)); jPanel2.add(jScrollPane2); { DefaultListModel model = new DefaultListModel(); fileExtensionFilter = new JList(); jScrollPane2.setViewportView(fileExtensionFilter); fileExtensionFilter.setModel(model); fileExtensionFilter.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { try { System.out .println(Arrays.toString(fileExtensionFilter.getSelectedValues())); String extensionStr = ""; StringBuilder sb = new StringBuilder(); for (Object val : fileExtensionFilter.getSelectedValues()) { sb.append(val + ","); } extensionStr = (sb.length() > 0 ? sb.deleteCharAt(sb.length() - 1) : sb) .toString(); System.out.format("extensionStr = [%s]\n", extensionStr); multiExtendsionFilter.setName(extensionStr); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } } { multiExtendsionFilter = new JButton(); jPanel2.add(multiExtendsionFilter); multiExtendsionFilter.setText("multi extension filter"); multiExtendsionFilter.setPreferredSize(new java.awt.Dimension(166, 34)); multiExtendsionFilter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { reloadSvnTable(multiExtendsionFilter.getName(), _fileExtensionMultiScanProcess); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { loadAuthorReference = new JButton(); jPanel2.add(loadAuthorReference); loadAuthorReference.setText("load author reference"); loadAuthorReference.setPreferredSize(new java.awt.Dimension(188, 35)); loadAuthorReference.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { File file = JFileChooserUtil.newInstance().selectFileOnly().showOpenDialog() .getApproveSelectedFile(); if (file == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("file is not correct!", "ERROR"); return; } authorProps.load(new FileInputStream(file)); reloadAuthorComboBox(); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { saveCurrentData = new JButton(); jPanel2.add(saveCurrentData); saveCurrentData.setText("save current data"); saveCurrentData.setPreferredSize(new java.awt.Dimension(166, 34)); saveCurrentData.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { File saveDataConfig = new File(jarExistLocation, getSaveCurrentDataFileName()); ObjectOutputStream writer = new ObjectOutputStream( new FileOutputStream(saveDataConfig)); writer.writeObject(projectName); writer.writeObject(authorSet); writer.writeObject(fileExtenstionSet); writer.writeObject(svnFileSet); writer.writeObject(authorProps); writer.writeObject(lastestVersion); writer.flush(); writer.close(); JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("current project : " + projectName + " save completed! \n" + saveDataConfig, "SUCCESS"); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { loadDataFromFile = new JButton(); jPanel2.add(loadDataFromFile); loadDataFromFile.setText("load data cfg"); loadDataFromFile.setPreferredSize(new java.awt.Dimension(165, 35)); loadDataFromFile.addActionListener(new ActionListener() { @SuppressWarnings("unchecked") public void actionPerformed(ActionEvent evt) { try { File file = JFileChooserUtil.newInstance().selectFileOnly() .addAcceptFile(".cfg", ".cfg").showOpenDialog() .getApproveSelectedFile(); if (file == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("file is not correct!", "ERROR"); return; } long startTime = System.currentTimeMillis(); ObjectInputStream input = new ObjectInputStream(new FileInputStream(file)); projectName = (String) input.readObject(); authorSet = (Set<String>) input.readObject(); fileExtenstionSet = (Set<String>) input.readObject(); svnFileSet = (Set<SvnFile>) input.readObject(); authorProps = (Properties) input.readObject(); lastestVersion = (Long) input.readObject(); input.close(); resetUiAndShowMessage(startTime, projectName, lastestVersion); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } } } pack(); this.setSize(726, 459); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.hsh.bfr.db.gui.dbtable.editoren.MyChartDialog.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents splitPane1 = new JSplitPane(); scrollPane1 = new JScrollPane(); table1 = new JTable(); panel1 = new JPanel(); button1 = new JButton(); panel2 = new JPanel(); button2 = new JButton(); button3 = new JButton(); button4 = new JButton(); CellConstraints cc = new CellConstraints(); //======== this ======== setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); Container contentPane = getContentPane(); contentPane.setLayout(new FormLayout("default:grow", "2*(default, $lgap), default")); //======== splitPane1 ======== {//from w w w .java 2s. com splitPane1.setDividerLocation(200); //======== scrollPane1 ======== { scrollPane1.setPreferredSize(new Dimension(200, 423)); //---- table1 ---- table1.setModel( new DefaultTableModel( new Object[][] { { "3.0", "5" }, { null, null }, { null, null }, { null, null }, { null, null }, { null, null }, { null, null }, { null, null }, { null, null }, { null, null }, { null, null }, { null, null }, { null, null }, { null, null }, { null, null }, { null, null }, { null, null }, { null, null }, { null, null }, { null, null }, }, new String[] { "Zeit (h)", "Temperatur" }) { /** * */ private static final long serialVersionUID = 1L; Class<?>[] columnTypes = new Class<?>[] { String.class, String.class }; @Override public Class<?> getColumnClass(int columnIndex) { return columnTypes[columnIndex]; } }); { TableColumnModel cm = table1.getColumnModel(); cm.getColumn(0).setPreferredWidth(100); } scrollPane1.setViewportView(table1); } splitPane1.setLeftComponent(scrollPane1); //======== panel1 ======== { panel1.setLayout(new FormLayout("default:grow", "fill:default:grow")); //---- button1 ---- button1.setText("text"); panel1.add(button1, cc.xy(1, 1)); } splitPane1.setRightComponent(panel1); } contentPane.add(splitPane1, cc.xy(1, 1)); //======== panel2 ======== { panel2.setLayout(new FormLayout("3*(default:grow, $lcgap), default:grow", "default")); ((FormLayout) panel2.getLayout()).setColumnGroups(new int[][] { { 1, 3, 5, 7 } }); //---- button2 ---- button2.setText("OK"); button2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { button2ActionPerformed(e); } }); panel2.add(button2, cc.xy(3, 1)); //---- button3 ---- button3.setText("Abbrechen"); button3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { button3ActionPerformed(e); } }); panel2.add(button3, cc.xy(5, 1)); //---- button4 ---- button4.setText("Hilfe"); button4.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { button4ActionPerformed(e); } }); panel2.add(button4, cc.xy(7, 1)); } contentPane.add(panel2, cc.xy(1, 5)); setSize(555, 390); setLocationRelativeTo(null); // JFormDesigner - End of component initialization //GEN-END:initComponents }