List of usage examples for javax.swing ListSelectionModel SINGLE_SELECTION
int SINGLE_SELECTION
To view the source code for javax.swing ListSelectionModel SINGLE_SELECTION.
Click Source Link
From source file:de.juwimm.cms.content.panel.PanDocuments.java
public PanDocuments(boolean showRegionCombo, boolean showDocumentProperties) { this.showRegionCombo = showRegionCombo; this.showDocumentProperties = showDocumentProperties; viewComponentId = PanContentView.getInstance().getViewComponent().getViewComponentId(); try {/*from w w w. java2 s . c o m*/ jbInit(); tblDocuments.getSelectionModel().addListSelectionListener(new DocumentListSelectionListener()); tblDocuments.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); btnDelete.setText(Messages.getString("panel.content.documents.deleteDocument")); btnAdd.setText(Messages.getString("panel.content.documents.addDocument")); btnPreview.setText(Messages.getString("dialog.preview")); btnUpdate.setText(Messages.getString("panel.content.documents.updateDocument")); btnUpdate.setVisible(false); lbLinkDescription.setText(Messages.getString("panel.content.documents.linkdescription")); lbDocumentLabel.setText(Messages.getString("panel.content.documents.documentLabel")); lbDocumentDescription.setText(Messages.getString("panel.content.documents.documentDescription")); lbAuthor.setText(Messages.getString("panel.content.documents.author")); lbCategory.setText(Messages.getString("panel.content.documents.category")); ckbDocumentSearchable.setText(Messages.getString("panel.content.documents.documentSearchable")); ckbDocumentSearchable.setSelected(true); cbxDisplayTypeInline.setText(rb.getString("content.modules.externalLink.displayTypeInline")); } catch (Exception exe) { log.error("Initialization error", exe); } this.panDocumentButtons.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { resizeScrollpane(); } }); this.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { resizeScrollpane(); } }); intActUnit = new Integer(((ContentManager) getBean(Beans.CONTENT_MANAGER)).getActUnitId()); intRootUnit = new Integer(((ContentManager) getBean(Beans.CONTENT_MANAGER)).getRootUnitId()); this.cboRegion.addItem( new CboModel(Messages.getString("panel.content.documents.files4ThisUnit"), intActUnit, true)); this.cboRegion.addItem( new CboModel(Messages.getString("panel.content.documents.files4AllUnits"), intRootUnit, true)); this.cboRegion.addItem(new CboModel(Messages.getString("panel.content.documents.files4ThisComponent"), viewComponentId, false)); cboRegion.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { regionSelected(); } }); cboRegion.setSelectedIndex(2); btnAdd.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btnAddActionPerformed(e); } }); btnPreview.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btnPreviewActionPerformed(e); } }); btnUpdate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btnUpdateActionPerformed(e); } }); btnDelete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btnDeleteActionPerformed(e); } }); //regionSelected(); }
From source file:ec.util.chart.swing.JTimeSeriesRendererSupportDemo.java
private Component createSeriesTable(ListSelectionModel seriesSelectionModel) { XTable result = new XTable(); result.setSelectionModel(seriesSelectionModel); result.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); result.setModel(new SeriesModel(support.seriesInfos)); ColorCellRenderer r0 = new ColorCellRenderer(FontAwesome.FA_CIRCLE_O); result.setDefaultRenderer(Color.class, r0); result.setDefaultEditor(Color.class, new ColorCellEditor(colorSchemeSupport, r0)); ColorCellRenderer r3 = new ColorCellRenderer(FontAwesome.FA_FONT); result.getColumnModel().getColumn(3).setCellRenderer(r3); result.getColumnModel().getColumn(3).setCellEditor(new ColorCellEditor(colorSchemeSupport, r3)); result.setDefaultRenderer(Font.class, FontCellRenderer.INSTANCE); result.setDefaultEditor(Font.class, new FontCellEditor()); result.setDefaultRenderer(Stroke.class, StrokeCellRenderer.INSTANCE); result.setDefaultEditor(Stroke.class, new StrokeCellEditor()); result.getModel().addTableModelListener(new TableModelListener() { @Override/* w w w. jav a 2s . c om*/ public void tableChanged(TableModelEvent e) { chart.fireChartChanged(); } }); return ModernUI.withEmptyBorders(new JScrollPane(result)); }
From source file:io.heming.accountbook.ui.MainFrame.java
public MainFrame() throws Exception { categoryFacade = new CategoryFacade(); recordFacade = new RecordFacade(); builder = new Pages.Builder(); builder.order("id", false); pages = builder.make();/*w ww . ja v a 2s . c o m*/ date_chooser_visible = false; disable = false; // Create widgets model = new TableModel(); table = new JTable(model) { /** * tip. * * @param evt * @return */ @Override public String getToolTipText(MouseEvent evt) { String tip = null; java.awt.Point point = evt.getPoint(); int row = rowAtPoint(point); int col = columnAtPoint(point); Rectangle bounds = getCellRect(row, col, false); Component comp = prepareRenderer(getCellRenderer(row, col), row, col); try { if (comp.getPreferredSize().width > bounds.width) { tip = getValueAt(row, col).toString(); } } catch (RuntimeException e) { //catch null pointer exception if mouse is over an empty line } return tip; } }; if (pages.hasNext()) { model.setRecords(pages.next()); } // ? table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); TableColumnModel columnModel = table.getColumnModel(); columnModel.getColumn(0).setPreferredWidth(80); columnModel.getColumn(1).setPreferredWidth(160); columnModel.getColumn(2).setPreferredWidth(80); columnModel.getColumn(3).setPreferredWidth(100); columnModel.getColumn(4).setPreferredWidth(100); columnModel.getColumn(5).setPreferredWidth(360); // Layout JScrollPane pane = new JScrollPane(table); add(pane, BorderLayout.CENTER); table.getTableHeader().setReorderingAllowed(false); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // table header table.getTableHeader().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int col = table.columnAtPoint(e.getPoint()); String name = table.getColumnName(col); // TODO } }); // ? addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { quit(); } }); categories = categoryFacade.listBySale(); initMenuBar(); initToolBar(); initStatusBar(); initTablePopupMenu(); searchRecords(); setIconImage(new ImageIcon(getClass().getResource("64.png")).getImage()); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setTitle(""); setSize(860, 620); }
From source file:net.openbyte.gui.WelcomeFrame.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner Evaluation license - Gary Lee scrollPane1 = new JScrollPane(); list1 = new JList(); button1 = new JButton(); label2 = new JLabel(); button2 = new JButton(); button3 = new JButton(); button4 = new JButton(); button5 = new JButton(); scrollPane2 = new JScrollPane(); xImagePanel1 = new JXImagePanel(); button6 = new JButton(); button7 = new JButton(); button8 = new JButton(); //======== this ======== setTitle("Welcome to OpenByte"); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setResizable(false);/*w w w. jav a 2s. c om*/ Container contentPane = getContentPane(); contentPane.setLayout(null); //======== scrollPane1 ======== { scrollPane1.setBorder(new TitledBorder(LineBorder.createGrayLineBorder(), "Recent Projects")); //---- list1 ---- list1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list1.setBackground(new Color(240, 240, 240)); list1.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { list1ValueChanged(e); } }); scrollPane1.setViewportView(list1); } contentPane.add(scrollPane1); scrollPane1.setBounds(15, 10, 165, 340); //---- button1 ---- button1.setText("Open Project"); button1.setEnabled(false); button1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { button1ActionPerformed(e); } }); contentPane.add(button1); button1.setBounds(105, 355, 110, button1.getPreferredSize().height); //---- label2 ---- label2.setText("Media"); contentPane.add(label2); label2.setBounds(new Rectangle(new Point(605, 210), label2.getPreferredSize())); //---- button2 ---- button2.setText("Minecraft Forums"); button2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { button2ActionPerformed(e); } }); contentPane.add(button2); button2.setBounds(500, 230, 151, button2.getPreferredSize().height); //---- button3 ---- button3.setText("GitHub"); button3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { button3ActionPerformed(e); } }); contentPane.add(button3); button3.setBounds(500, 260, 150, button3.getPreferredSize().height); //---- button4 ---- button4.setText("+"); button4.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { button4ActionPerformed(e); } }); contentPane.add(button4); button4.setBounds(15, 355, 45, button4.getPreferredSize().height); //---- button5 ---- button5.setText("-"); button5.setEnabled(false); button5.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { button5ActionPerformed(e); } }); contentPane.add(button5); button5.setBounds(60, 355, 40, button5.getPreferredSize().height); //======== scrollPane2 ======== { scrollPane2.setBorder(null); scrollPane2.setViewportView(xImagePanel1); } contentPane.add(scrollPane2); scrollPane2.setBounds(210, 25, 445, 160); //---- button6 ---- button6.setText("Preferences"); button6.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { button6ActionPerformed(e); } }); contentPane.add(button6); button6.setBounds(500, 290, 150, 30); //---- button7 ---- button7.setText("About"); button7.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { button7ActionPerformed(e); } }); contentPane.add(button7); button7.setBounds(500, 320, 150, 30); //---- button8 ---- button8.setText("Plugins"); button8.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { button8ActionPerformed(e); } }); contentPane.add(button8); button8.setBounds(500, 350, 150, 30); { // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < contentPane.getComponentCount(); i++) { Rectangle bounds = contentPane.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = contentPane.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; contentPane.setMinimumSize(preferredSize); contentPane.setPreferredSize(preferredSize); } setSize(675, 425); setLocationRelativeTo(getOwner()); // JFormDesigner - End of component initialization //GEN-END:initComponents }
From source file:net.sf.taverna.t2.workbench.cagrid.CaGridComponent.java
private void addResultPanel() { GridBagConstraints c = new GridBagConstraints(); c.gridx = 0;/*w w w .ja va 2s . c o m*/ c.gridy = ++row; c.fill = GridBagConstraints.BOTH; c.weightx = 0.01; c.weighty = 0.01; c.anchor = GridBagConstraints.SOUTHEAST; c.gridwidth = GridBagConstraints.REMAINDER; resultPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); resultPanel.setDividerLocation(200); resultPanel.setBorder(null); runListModel = new DefaultListModel(); runList = new JList(runListModel); runList.setBorder(new EmptyBorder(5, 5, 5, 5)); runList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); runListPanel = new JPanel(new BorderLayout()); runListPanel.setBorder(LineBorder.createGrayLineBorder()); JLabel worklflowRunsLabel = new JLabel("Workflow Runs"); worklflowRunsLabel.setBorder(new EmptyBorder(5, 5, 5, 5)); removeCaGridRunsButton = new JButton("Remove"); // button to remove previous workflow runs removeCaGridRunsButton.setAlignmentX(JComponent.RIGHT_ALIGNMENT); removeCaGridRunsButton.setEnabled(false); removeCaGridRunsButton.setToolTipText("Remove caGrid run(s)"); removeCaGridRunsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int[] selected = runList.getSelectedIndices(); for (int i = selected.length - 1; i >= 0; i--) { CaGridRun cr = (CaGridRun) runListModel.get(selected[i]); //delete the EPR file File file = new File(new File(System.getProperty("user.home")), cr.workflowid + ".epr"); file.delete(); System.out.println(cr.workflowid + ".epr deleted"); runListModel.remove(selected[i]); } // Set the first item as selected - if there is one if (runListModel.size() > 0) { runList.setSelectedIndex(0); } else { resultText.setText(""); resultText.revalidate(); } } }); runListPanel.add(worklflowRunsLabel, BorderLayout.NORTH); runListPanel.add(removeCaGridRunsButton, BorderLayout.BEFORE_FIRST_LINE); JScrollPane scrollPane = new JScrollPane(runList); scrollPane.setBorder(null); runListPanel.add(scrollPane, BorderLayout.CENTER); // loadWorkflowRunsFromStoredEPRFiles(): add CaGridRun to runList for each EPR // add two buttons: remove and refresh status runList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { Object selection = runList.getSelectedValue(); if (selection instanceof CaGridRun) { removeCaGridRunsButton.setEnabled(true); CaGridRun dataflowRun = (CaGridRun) selection; // update status and refresh outputPanel String resultDisplayString = updateResultDisplayString(dataflowRun); resultText.setText(resultDisplayString); resultText.setLineWrap(true); resultText.setEditable(false); outputPanel.revalidate(); revalidate(); } else { removeCaGridRunsButton.setEnabled(false); revalidate(); } } } }); resultPanel.setTopComponent(runListPanel); //each output should be a (xml) string outputPanel = new JScrollPane(); resultText = new JTextArea(); outputPanel = new JScrollPane(resultText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); //outputPanel = new JPanel(new BorderLayout()); outputPanel.setBorder(LineBorder.createGrayLineBorder()); outputPanel.setBackground(Color.WHITE); //outputPanel.add(new JLabel("Workflow Execution Outputs shows here.", JLabel.CENTER), null); resultPanel.setBottomComponent(outputPanel); add(resultPanel, c); //add runComponent to the GUI ArrayList<CaGridRun> loadedRunList = loadWorkflowRunsFromStoredEPRFiles(null, (String) services.getSelectedItem()); if (loadedRunList != null) { for (int m = 0; m < loadedRunList.size(); m++) { CaGridRun cr = (CaGridRun) loadedRunList.get(m); runListModel.add(0, cr); } System.out.println(loadedRunList.size() + " EPR loaded."); runList.setSelectedIndex(0); } }
From source file:org.angnysa.yaba.swing.BudgetFrame.java
private void buildReconciliationTable() { reconciliationModel = new ReconciliationTableModel(service); reconciliationTable = new JTable(reconciliationModel); reconciliationTable.setRowHeight((int) (reconciliationTable.getRowHeight() * 1.2)); reconciliationTable.setDefaultEditor(LocalDate.class, new CustomCellEditor(new JFormattedTextField(new JodaLocalDateFormat()))); reconciliationTable.setDefaultEditor(Double.class, new CustomCellEditor(new JFormattedTextField(NumberFormat.getNumberInstance()))); reconciliationTable.setDefaultRenderer(LocalDate.class, new FormattedTableCellRenderer(new JodaLocalDateFormat())); reconciliationTable.setDefaultRenderer(Double.class, new FormattedTableCellRenderer(TransactionAmountFormatFactory.getFormat())); reconciliationTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); reconciliationTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete"); //$NON-NLS-1$ reconciliationTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "delete"); //$NON-NLS-1$ reconciliationTable.getActionMap().put("delete", new AbstractAction() { //$NON-NLS-1$ private static final long serialVersionUID = 1L; @Override/*from w w w. java2 s . co m*/ public void actionPerformed(ActionEvent e) { int row = reconciliationTable.getSelectedRow(); if (row >= 0) { reconciliationModel.deleteRow(row); } } }); transactionTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int row = transactionTable.getSelectedRow(); if (row >= 0) { row = transactionTable.getRowSorter().convertRowIndexToModel(row); TransactionDefinition td = transactionModel.getTransactionForRow(row); if (td != null) { reconciliationModel.setCurrentTransactionId(td.getId()); } else { reconciliationModel.setCurrentTransactionId(-1); } } else { reconciliationModel.setCurrentTransactionId(-1); } } } }); }
From source file:stockit.Trader.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 ava2 s . c o m */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel1 = new javax.swing.JLabel(); panel = new javax.swing.JPanel(); displayBtn = new javax.swing.JButton(); allStockBtn = new javax.swing.JButton(); jSeparator1 = new javax.swing.JSeparator(); transactionBtn = new javax.swing.JButton(); searchStock = new javax.swing.JLabel(); transaction = new javax.swing.JLabel(); trader = new javax.swing.JLabel(); companyText = new javax.swing.JLabel(); companyVariable = new javax.swing.JLabel(); performanceBtn = new javax.swing.JButton(); jLabel7 = new javax.swing.JLabel(); jScrollPane3 = new javax.swing.JScrollPane(); listOfClients = new javax.swing.JList<>(); jScrollPane4 = new javax.swing.JScrollPane(); table = new javax.swing.JTable(); searchClientBtn = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); selectedStock = new javax.swing.JLabel(); variableStockChange = new javax.swing.JLabel(); jMenuBar1 = new javax.swing.JMenuBar(); flieMenuItem = new javax.swing.JMenu(); logoutItem = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setPreferredSize(new java.awt.Dimension(1050, 873)); setSize(new java.awt.Dimension(1050, 873)); jLabel1.setText("Trader:"); javax.swing.GroupLayout panelLayout = new javax.swing.GroupLayout(panel); panel.setLayout(panelLayout); panelLayout.setHorizontalGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 765, Short.MAX_VALUE)); panelLayout.setVerticalGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 408, Short.MAX_VALUE)); displayBtn.setText("Stock Performance"); displayBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { displayBtnActionPerformed(evt); } }); allStockBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/stockit/rsz_market-icon-3.png"))); // NOI18N allStockBtn.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); allStockBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { allStockBtnActionPerformed(evt); } }); transactionBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource( "/stockit/rsz_4kcf4flghdlgbu3jaet9jtonae_mpyd4w0kbgz5sxue6ry9-iem85hz3mdx1-iufyzxn.png"))); // NOI18N transactionBtn .setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); transactionBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { transactionBtnActionPerformed(evt); } }); searchStock.setText("Search Stocks"); transaction.setText("Transaction"); trader.setText(username); companyText.setText("Company Name:"); companyVariable.setText(companyName); performanceBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/stockit/rsz_refresh.png"))); // NOI18N performanceBtn .setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); performanceBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { performanceBtnActionPerformed(evt); } }); jLabel7.setText("Refresh"); listOfClients.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); jScrollPane3.setViewportView(listOfClients); table.setModel(new javax.swing.table.DefaultTableModel(new Object[][] { }, new String[] { "Symbol", "Name", "Sector", "Quantity", "High", "Low", "Last", "Today Change", "Currency", "Profit/Loss" }) { Class[] types = new Class[] { java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class }; boolean[] canEdit = new boolean[] { false, false, false, false, false, false, false, false, false, false }; public Class getColumnClass(int columnIndex) { return types[columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }); table.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { public void mouseDragged(java.awt.event.MouseEvent evt) { tableMouseDragged(evt); } }); table.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { tableMouseClicked(evt); } }); table.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { tableKeyPressed(evt); } public void keyReleased(java.awt.event.KeyEvent evt) { tableKeyReleased(evt); } }); jScrollPane4.setViewportView(table); if (table.getColumnModel().getColumnCount() > 0) { table.getColumnModel().getColumn(2).setResizable(false); } searchClientBtn .setIcon(new javax.swing.ImageIcon(getClass().getResource("/stockit/rsz_search-icon-512.png"))); // NOI18N searchClientBtn .setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); searchClientBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { searchClientBtnActionPerformed(evt); } }); jLabel2.setText("View Client"); selectedStock.setText("Selected Stock:"); flieMenuItem.setText("File"); logoutItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_DELETE, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); logoutItem.setText("Logout"); logoutItem.setToolTipText("Click to Logout of Application"); logoutItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { logoutItemActionPerformed(evt); } }); flieMenuItem.add(logoutItem); jMenuBar1.add(flieMenuItem); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(trader, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(480, 480, 480).addComponent(companyText).addGap(14, 14, 14) .addComponent(companyVariable, javax.swing.GroupLayout.PREFERRED_SIZE, 282, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout .createSequentialGroup().addGap(12, 12, 12) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(7, 7, 7) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(searchClientBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup().addGap(18, 18, 18) .addComponent(jLabel2))) .addGap(7, 7, 7) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(allStockBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup().addGap(10, 10, 10) .addComponent(searchStock))) .addGap(7, 7, 7) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(transactionBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout .createSequentialGroup().addGap(10, 10, 10) .addComponent(transaction))) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addGap(7, 7, 7) .addComponent(performanceBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup().addGap(28, 28, 28) .addComponent(jLabel7)))) .addGroup(layout.createSequentialGroup().addContainerGap() .addComponent(displayBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(selectedStock) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(variableStockChange, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane4) .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING))) .addGroup(layout.createSequentialGroup().addGap(130, 130, 130) .addComponent(panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(companyText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(companyVariable, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(trader, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(7, 7, 7) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addComponent(searchClientBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(7, 7, 7).addComponent(jLabel2)) .addGroup(layout.createSequentialGroup() .addComponent(allStockBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(7, 7, 7).addComponent(searchStock)) .addGroup(layout.createSequentialGroup() .addComponent(transactionBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(7, 7, 7) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(transaction).addComponent(jLabel7))) .addComponent(performanceBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(7, 7, 7) .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(displayBtn).addComponent(selectedStock)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE) .addComponent(panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(54, 54, 54)) .addGroup(layout.createSequentialGroup() .addComponent(variableStockChange, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))); pack(); setLocationRelativeTo(null); }
From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java
public Jmetrik() { super("jMetrik"); setPreferredSize(new Dimension(1024, 650)); setDefaultCloseOperation(EXIT_ON_CLOSE); //properly close database if user closes window this.addWindowListener(new WindowAdapter() { @Override/*from w w w .ja v a 2 s .co m*/ public void windowClosing(WindowEvent we) { if (workspace != null) { workspace.closeDatabase(); } System.exit(0); } }); //add statusbar statusBar = new StatusBar(1024, 30); statusBar.setBorder(new EmptyBorder(2, 2, 2, 2)); getContentPane().add(statusBar, BorderLayout.SOUTH); //start logging startLog(); //left-right splitpane JSplitPane splitPane1 = new JSplitPane(); splitPane1.setDividerLocation(200); //setup workspace list workspaceList = new JList(); workspaceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); workspaceList.setModel(new SortedListModel<DataTableName>()); workspaceList.addKeyListener(new DeleteKeyListener()); // workspaceList.getInsets().set(5, 5, 5, 5); //add icon to list cell renderer String urlString = "/images/spreadsheet.png"; URL url = this.getClass().getResource(urlString); final ImageIcon tableIcon = new ImageIcon(url, "Table"); workspaceList.setCellRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); label.setIcon(tableIcon); return label; } }); JScrollPane scrollPane1 = new JScrollPane(workspaceList); scrollPane1.setPreferredSize(new Dimension(200, 698)); splitPane1.setLeftComponent(scrollPane1); //tabbed pane for top pane tabbedPane = new JTabbedPane(); tabbedPane.setTabPlacement(JTabbedPane.BOTTOM); //setup data table dataTable = new DataTable(); dataTable.setRowHeight(18); //change size of table header and center text JTableHeader header = dataTable.getTableHeader(); header.setDefaultRenderer(new TableHeaderCellRenderer()); JScrollPane dataScrollPane = new JScrollPane(dataTable); tabbedPane.addTab("Data", dataScrollPane); //setup variable table variableTable = new DataTable(); variableTable.setRowHeight(18); variableTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { super.mouseClicked(e); if (e.getClickCount() == 2) { JTable target = (JTable) e.getSource(); int row = target.getSelectedRow(); int col = target.getSelectedColumn(); if (col == 0) { if (target.getModel() instanceof VariableModel) { VariableModel vModel = (VariableModel) target.getModel(); String s = (String) vModel.getValueAt(row, col); DatabaseName db = workspace.getDatabaseName(); DataTableName table = workspace.getCurrentDataTable(); RenameVariableDialog renameVariableDialog = new RenameVariableDialog(Jmetrik.this, db, table, s); renameVariableDialog.setVisible(true); if (renameVariableDialog.canRun()) { RenameVariableCommand command = renameVariableDialog.getCommand(); workspace.runProcess(command); } } //end instanceof } //end if col==0 } //end if click count==2 }//end mouse clicked }); //change size of table header and center text JTableHeader variableHeader = variableTable.getTableHeader(); variableHeader.setDefaultRenderer(new TableHeaderCellRenderer()); variableHeader.setPreferredSize(new Dimension(30, 21)); JScrollPane variableScrollPane = new JScrollPane(variableTable); tabbedPane.addTab("Variables", variableScrollPane); splitPane1.setRightComponent(tabbedPane); getContentPane().add(splitPane1, BorderLayout.CENTER); //add status bar listener - needed to display status message that are generated within this class this.addPropertyChangeListener(statusBar.getStatusListener()); //add listener for displaying error messages - needed to display errors and exceptions this.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener()); //instantiate file utilities fileUtils = new JmetrikFileUtils(); fileUtils.addPropertyChangeListener(statusBar.getStatusListener()); //set import and export path to user's documents folder JFileChooser chooser = new JFileChooser(); FileSystemView fw = chooser.getFileSystemView(); importExportPath = fw.getDefaultDirectory().toString().replaceAll("\\\\", "/"); //create and start a workspace startWorkspace(); //create menu bar and tool bar this.setJMenuBar(createMenuBar()); JToolBar toolBar = createToolBar(); toolBar.setFloatable(false); toolBar.setRollover(true); getContentPane().add(toolBar, BorderLayout.PAGE_START); pack(); }
From source file:edu.ku.brc.specify.plugins.CollectionRelOneToManyPlugin.java
@Override public void initialize(Properties propertiesArg, boolean isViewModeArg) { super.initialize(propertiesArg, isViewModeArg); String relName = propertiesArg.getProperty("relname"); if (StringUtils.isNotEmpty(relName)) { DataProviderSessionIFace tmpSession = null; try {//from ww w. j av a2s . c o m tmpSession = DataProviderFactory.getInstance().createSession(); colRelType = tmpSession.getData(CollectionRelType.class, "name", relName, DataProviderSessionIFace.CompareType.Equals); if (colRelType != null) { leftSideCol = colRelType.getLeftSideCollection(); rightSideCol = colRelType.getRightSideCollection(); rightSideCol.getCollectionId(); leftSideCol.getCollectionId(); catNumFormatter = getCatNumFormatter(leftSideCol, rightSideCol); Collection currCollection = AppContextMgr.getInstance().getClassObject(Collection.class); isLeftSide = currCollection.getId().equals(leftSideCol.getId()); if (!isLeftSide) { // major error } } else { DBTableInfo ti = DBTableIdMgr.getInstance() .getInfoById(CollectionRelationship.getClassTableId()); UIRegistry.showError( String.format("The %s name '%s' doesn't exist (defined in the form for the plugin).", ti.getTitle(), relName)); } } catch (Exception ex) { ex.printStackTrace(); } finally { if (tmpSession != null) { tmpSession.close(); } } CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g,2px,p", "f:p:g"), this); model = new ColObjDataModel(); table = new JTable(model); JScrollPane sp = UIHelper.createScrollPane(table, false); pb.add(sp, cc.xy(1, 1)); searchAddBtn = UIHelper.createIconBtn("SearchAdd", IconManager.IconSize.Std20, "", true, createSearchAL()); removeBtn = UIHelper.createIconBtn("Eraser", IconManager.IconSize.NonStd, "", true, createRemoveAL()); infoBtn = UIHelper.createIconBtn("InfoIcon", IconManager.IconSize.Std20, "", true, createInfoAL()); PanelBuilder rpb = new PanelBuilder(new FormLayout("f:p:g", "p,4px,p,4px,p, f:p:g")); int y = 1; rpb.add(infoBtn, cc.xy(1, y)); y += 2; if (!isViewMode) { rpb.add(searchAddBtn, cc.xy(1, y)); y += 2; rpb.add(removeBtn, cc.xy(1, y)); y += 2; } pb.add(rpb.getPanel(), cc.xy(3, 1)); UIHelper.makeTableHeadersCentered(table, true); UIHelper.setVisibleRowCount(table, 5); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setCellSelectionEnabled(false); table.setColumnSelectionAllowed(false); table.setRowSelectionAllowed(true); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { updateBtns(); } }); updateBtns(); } else { System.err.println(propertiesArg); log.error("CollectionRelOneToManyPlugin - initialize attribute for 'relname' is null and can't be!"); } }
From source file:TopLevelTransferHandlerDemo.java
public TopLevelTransferHandlerDemo() { super("TopLevelTransferHandlerDemo"); setJMenuBar(createDummyMenuBar());/*w w w . jav a 2 s. c om*/ getContentPane().add(createDummyToolBar(), BorderLayout.NORTH); JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, list, dp); sp.setDividerLocation(120); getContentPane().add(sp); //new Doc("sample.txt"); //new Doc("sample.txt"); //new Doc("sample.txt"); list.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } Doc val = (Doc) list.getSelectedValue(); if (val != null) { val.select(); } } }); final TransferHandler th = list.getTransferHandler(); nullItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { if (nullItem.isSelected()) { list.setTransferHandler(null); } else { list.setTransferHandler(th); } } }); thItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { if (thItem.isSelected()) { setTransferHandler(handler); } else { setTransferHandler(null); } } }); dp.setTransferHandler(handler); }