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:Clavis.Windows.WShedule.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 .c o m*/ */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanelInicial = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new org.jdesktop.swingx.JXTable(); ; jButtonSair = new javax.swing.JButton(); jXDatePickerInicio = new org.jdesktop.swingx.JXDatePicker(); jXDatePickerFim = new org.jdesktop.swingx.JXDatePicker(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jButtonImprimir = new javax.swing.JButton(); jComboBoxEstado = new javax.swing.JComboBox<>(); jLabel3 = new javax.swing.JLabel(); jButtonExportar = new javax.swing.JButton(); setMinimumSize(new java.awt.Dimension(900, 600)); setSize(new java.awt.Dimension(900, 600)); jPanelInicial.setBorder(javax.swing.BorderFactory.createCompoundBorder( javax.swing.BorderFactory.createLineBorder(painelcor, 4), javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)))); jPanelInicial.setMinimumSize(new java.awt.Dimension(900, 500)); jPanelInicial.setPreferredSize(new java.awt.Dimension(900, 500)); org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder1 = new org.jdesktop.swingx.border.DropShadowBorder(); dropShadowBorder1.setCornerSize(6); dropShadowBorder1.setShadowSize(3); dropShadowBorder1.setShowLeftShadow(true); jScrollPane1.setBorder(javax.swing.BorderFactory.createCompoundBorder(dropShadowBorder1, javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)))); jTable1.setBorder(null); if (mat.getTypeOfMaterial().getMaterialTypeID() == 1) { jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {}, new String[] { lingua.translate("Utilizador"), lingua.translate("Horrio"), lingua.translate("Data"), lingua.translate("Atividade"), lingua.translate("Disciplina") })); jTable1.getColumnModel().getColumn(0).setPreferredWidth(250); jTable1.getColumnModel().getColumn(1).setMinWidth(90); jTable1.getColumnModel().getColumn(2).setMinWidth(90); jTable1.getColumnModel().getColumn(3).setMinWidth(150); jTable1.getColumnModel().getColumn(4).setMinWidth(150); } else { jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {}, new String[] { lingua.translate("Utilizador"), lingua.translate("Data inicial"), lingua.translate("Data final"), lingua.translate("Atividade") })); jTable1.getColumnModel().getColumn(0).setPreferredWidth(250); jTable1.getColumnModel().getColumn(1).setMinWidth(90); jTable1.getColumnModel().getColumn(2).setMinWidth(90); jTable1.getColumnModel().getColumn(3).setMinWidth(150); } jScrollPane1.setViewportView(jTable1); Border border = BorderFactory.createEmptyBorder(5, 5, 0, 0); UIManager.put("Table.focusCellHighlightBorder", border); jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setHorizontalAlignment(javax.swing.JLabel.CENTER); renderer.setFocusable(false); javax.swing.JLabel lo = new javax.swing.JLabel(); lo.setBackground(new Color(100, 100, 100)); lo.setOpaque(true); jScrollPane1.setCorner(javax.swing.JScrollPane.UPPER_TRAILING_CORNER, lo); jTable1.setRowHeight(30); jTable1.setEditable(false); jTable1.setSelectionBackground(Color.DARK_GRAY); jTable1.getColumnModel().getColumn(1).setCellRenderer(renderer); jTable1.getColumnModel().getColumn(2).setCellRenderer(renderer); jTable1.getColumnModel().getColumn(3).setCellRenderer(renderer); if (mat.getTypeOfMaterial().getMaterialTypeID() == 1) { jTable1.getColumnModel().getColumn(4).setCellRenderer(renderer); } DefaultTableCellRenderer headerRenderer = new DefaultTableCellRenderer() { private static final long serialVersionUID = 2L; @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); setFont(new Font("Cantarell", Font.PLAIN, 14)); this.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 0, new Color(1, 1, 1))); return this; } }; DefaultTableCellRenderer headerRenderer2 = new DefaultTableCellRenderer() { private static final long serialVersionUID = 3L; @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); setFont(new Font("Cantarell", Font.PLAIN, 14)); this.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(1, 1, 1)), BorderFactory.createEmptyBorder(0, 20, 0, 0))); this.setBackground(new Color(100, 100, 100)); setForeground(Color.WHITE); setPreferredSize(new Dimension(100, 40)); return this; } }; headerRenderer.setBackground(new Color(100, 100, 100)); headerRenderer.setForeground(Color.WHITE); headerRenderer.setPreferredSize(new Dimension(100, 40)); headerRenderer.setHorizontalAlignment(javax.swing.JLabel.CENTER); for (int i = 0; i < jTable1.getColumnCount(); i++) { if (i == 0) { headerRenderer2.setHorizontalAlignment(javax.swing.JLabel.LEFT); jTable1.getColumnModel().getColumn(i).setHeaderRenderer(headerRenderer2); } else { jTable1.getColumnModel().getColumn(i).setHeaderRenderer(headerRenderer); } } jButtonSair.setBackground(new java.awt.Color(1, 1, 1)); jButtonSair.setToolTipText(""); jButtonSair.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); jButtonSair.setFocusPainted(false); jButtonSair.setMaximumSize(new java.awt.Dimension(90, 40)); jButtonSair.setMinimumSize(new java.awt.Dimension(90, 40)); jButtonSair.setPreferredSize(new java.awt.Dimension(90, 40)); jButtonSair.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonSairActionPerformed(evt); } }); jXDatePickerInicio.setBackground(new java.awt.Color(254, 254, 254)); org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder2 = new org.jdesktop.swingx.border.DropShadowBorder(); dropShadowBorder2.setCornerSize(6); dropShadowBorder2.setShadowSize(3); dropShadowBorder2.setShowLeftShadow(true); jXDatePickerInicio.setBorder(javax.swing.BorderFactory.createCompoundBorder(dropShadowBorder2, javax.swing.BorderFactory.createMatteBorder(0, 1, 1, 1, new java.awt.Color(0, 0, 0)))); jXDatePickerInicio.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N jXDatePickerInicio.setMaximumSize(new java.awt.Dimension(1155551, 26)); jXDatePickerInicio.setMinimumSize(new java.awt.Dimension(66, 26)); jXDatePickerInicio.setPreferredSize(new java.awt.Dimension(131, 26)); jXDatePickerInicio.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jXDatePickerInicioActionPerformed(evt); } }); jXDatePickerFim.setBackground(new java.awt.Color(254, 254, 254)); org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder3 = new org.jdesktop.swingx.border.DropShadowBorder(); dropShadowBorder3.setCornerSize(6); dropShadowBorder3.setShadowSize(3); dropShadowBorder3.setShowLeftShadow(true); jXDatePickerFim.setBorder(javax.swing.BorderFactory.createCompoundBorder(dropShadowBorder3, javax.swing.BorderFactory.createMatteBorder(0, 1, 1, 1, new java.awt.Color(0, 0, 0)))); jXDatePickerFim.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N jXDatePickerFim.setMaximumSize(new java.awt.Dimension(1155551, 26)); jXDatePickerFim.setMinimumSize(new java.awt.Dimension(66, 26)); jXDatePickerFim.setPreferredSize(new java.awt.Dimension(121, 26)); jLabel1.setBackground(new java.awt.Color(100, 100, 100)); jLabel1.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N jLabel1.setForeground(new java.awt.Color(254, 254, 254)); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel1.setText("Incio"); jLabel1.setVerticalAlignment(javax.swing.SwingConstants.TOP); jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); jLabel1.setMaximumSize(new java.awt.Dimension(3343446, 96)); jLabel1.setMinimumSize(new java.awt.Dimension(36, 26)); jLabel1.setOpaque(true); jLabel1.setPreferredSize(new java.awt.Dimension(100, 20)); jLabel2.setBackground(new java.awt.Color(100, 100, 100)); jLabel2.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N jLabel2.setForeground(new java.awt.Color(254, 254, 254)); jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel2.setText("Fim"); jLabel2.setVerticalAlignment(javax.swing.SwingConstants.TOP); jLabel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jLabel2.setMaximumSize(new java.awt.Dimension(355557, 96)); jLabel2.setMinimumSize(new java.awt.Dimension(37, 26)); jLabel2.setOpaque(true); jLabel2.setPreferredSize(new java.awt.Dimension(100, 20)); jButtonImprimir.setBackground(new java.awt.Color(51, 102, 153)); jButtonImprimir.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); jButtonImprimir.setFocusPainted(false); jButtonImprimir.setMaximumSize(new java.awt.Dimension(5345, 40)); jButtonImprimir.setPreferredSize(new java.awt.Dimension(90, 40)); jButtonImprimir.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonImprimirActionPerformed(evt); } }); jComboBoxEstado.setBackground(new java.awt.Color(213, 213, 213)); jComboBoxEstado.setBorder(null); jComboBoxEstado.setFocusable(false); jComboBoxEstado.setMinimumSize(new java.awt.Dimension(35, 22)); jComboBoxEstado.setPreferredSize(new java.awt.Dimension(125, 28)); jComboBoxEstado.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBoxEstadoActionPerformed(evt); } }); jLabel3.setBackground(new java.awt.Color(100, 100, 100)); jLabel3.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N jLabel3.setForeground(new java.awt.Color(254, 254, 254)); jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel3.setText("Estado"); jLabel3.setVerticalAlignment(javax.swing.SwingConstants.TOP); jLabel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jLabel3.setMaximumSize(new java.awt.Dimension(355557, 96)); jLabel3.setMinimumSize(new java.awt.Dimension(37, 26)); jLabel3.setOpaque(true); jLabel3.setPreferredSize(new java.awt.Dimension(100, 20)); jButtonExportar.setBackground(new java.awt.Color(51, 102, 153)); jButtonExportar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); jButtonExportar.setFocusPainted(false); jButtonExportar.setMaximumSize(new java.awt.Dimension(5345, 40)); jButtonExportar.setPreferredSize(new java.awt.Dimension(90, 40)); jButtonExportar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonExportarActionPerformed(evt); } }); javax.swing.GroupLayout jPanelInicialLayout = new javax.swing.GroupLayout(jPanelInicial); jPanelInicial.setLayout(jPanelInicialLayout); jPanelInicialLayout.setHorizontalGroup(jPanelInicialLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(42, 42, 42) .addGroup(jPanelInicialLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelInicialLayout.createSequentialGroup().addComponent(jScrollPane1) .addGap(42, 42, 42)) .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(29, 29, 29) .addComponent(jButtonSair, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButtonExportar, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonImprimir, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(71, 71, 71)))) .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(71, 71, 71) .addGroup(jPanelInicialLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jXDatePickerInicio, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanelInicialLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE) .addComponent(jXDatePickerFim, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 201, Short.MAX_VALUE) .addGroup(jPanelInicialLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jComboBoxEstado, 0, 241, Short.MAX_VALUE)) .addGap(71, 71, 71))); jPanelInicialLayout .setVerticalGroup(jPanelInicialLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(16, 16, 16) .addGroup(jPanelInicialLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(0, 0, 0) .addGroup(jPanelInicialLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jXDatePickerInicio, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jXDatePickerFim, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jComboBoxEstado, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 465, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanelInicialLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButtonImprimir, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonSair, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonExportar, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(16, 16, 16))); try { if (Clavis.KeyQuest.class.getResource("Images/exit26x24.png") != null) { BufferedImage im = ImageIO.read(Clavis.KeyQuest.class.getResourceAsStream("Images/exit26x24.png")); ImageIcon imic = new ImageIcon(im); if (imic != null) { jButtonSair.setIcon(imic); } } } catch (IOException eo) { } jButtonSair.setToolTipText(lingua.translate("Voltar")); javax.swing.JPanel pan2 = new javax.swing.JPanel(null); String compoe = lingua.translate("Hoje dia") + ": " + new TimeDate.Date().toString(); javax.swing.JLabel fil2 = new javax.swing.JLabel(compoe); fil2.setBounds(0, 0, 300, 26); fil2.setHorizontalAlignment(SwingConstants.CENTER); pan2.setPreferredSize(new Dimension(300, 30)); pan2.setBounds(0, 0, 300, 30); pan2.add(fil2); jXDatePickerInicio.setLinkPanel(pan2); jXDatePickerInicio.setLocale(lingua.systemlocale); jXDatePickerInicio.getEditor().setSelectionColor(Color.DARK_GRAY); jXDatePickerInicio.getEditor().setBorder(BorderFactory.createEmptyBorder()); jXDatePickerInicio.getEditor().setHorizontalAlignment(SwingConstants.CENTER); javax.swing.JButton bbt2 = (javax.swing.JButton) jXDatePickerInicio.getComponent(1); bbt2.setBackground(Color.WHITE); jXDatePickerInicio.addActionListener(actionJXDatePicker()); jXDatePickerInicio.setFormats("dd/MM/yyyy"); javax.swing.JPanel pan = new javax.swing.JPanel(null); String compoe0 = lingua.translate("Hoje dia") + ": " + new TimeDate.Date().toString(); javax.swing.JLabel fil = new javax.swing.JLabel(compoe); fil.setBounds(0, 0, 300, 26); fil.setHorizontalAlignment(SwingConstants.CENTER); pan.setPreferredSize(new Dimension(300, 30)); pan.setBounds(0, 0, 300, 30); pan.add(fil); jXDatePickerFim.setLinkPanel(pan); Component[] t = jXDatePickerFim.getLinkPanel().getComponents(); jXDatePickerFim.setLocale(lingua.systemlocale); jXDatePickerFim.getEditor().setSelectionColor(Color.DARK_GRAY); jXDatePickerFim.getEditor().setBorder(BorderFactory.createEmptyBorder()); jXDatePickerFim.getEditor().setHorizontalAlignment(SwingConstants.CENTER); javax.swing.JButton bbt = (javax.swing.JButton) jXDatePickerFim.getComponent(1); bbt.setBackground(Color.WHITE); jXDatePickerFim.addActionListener(actionJXDatePicker()); jXDatePickerFim.setFormats("dd/MM/yyyy"); jLabel1.setText(lingua.translate("Incio")); jLabel2.setText(lingua.translate("Fim")); try { if (Clavis.KeyQuest.class.getResource("Images/print.png") != null) { BufferedImage im = ImageIO.read(Clavis.KeyQuest.class.getResourceAsStream("Images/print.png")); ImageIcon imic = new ImageIcon(im); if (imic != null) { jButtonImprimir.setIcon(imic); } } } catch (IOException eo) { } jButtonImprimir.setToolTipText(lingua.translate("Imprimir")); jComboBoxEstado.setModel(new javax.swing.DefaultComboBoxModel<>( new String[] { lingua.translate("todos"), lingua.translate("terminado"), lingua.translate("no realizado"), lingua.translate("por realizar") })); Clavis.KeyQuest.addVisualComboBox(jComboBoxEstado); ((javax.swing.JLabel) jComboBoxEstado.getRenderer()).setHorizontalAlignment(javax.swing.JLabel.CENTER); jLabel3.setText(lingua.translate("Estado")); try { if (Clavis.KeyQuest.class.getResource("Images/exportar.png") != null) { BufferedImage im = ImageIO.read(Clavis.KeyQuest.class.getResourceAsStream("Images/exportar.png")); ImageIcon imic = new ImageIcon(im); if (imic != null) { jButtonExportar.setIcon(imic); } } } catch (IOException eo) { } jButtonExportar.setToolTipText(lingua.translate("Exportar para excel")); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addComponent(jPanelInicial, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(0, 0, 0))); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanelInicial, javax.swing.GroupLayout.DEFAULT_SIZE, 600, Short.MAX_VALUE)); }
From source file:com.mirth.connect.client.ui.SettingsPanelDatabaseTasks.java
private void initComponents() { JPanel containerPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3, fill")); containerPanel.setBackground(getBackground()); containerPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Database Tasks", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11))); containerPanel.add(new JLabel( "Cleanup or optimization tasks for the internal database. If no tasks are present, no action is necessary."), "top, wrap"); taskTable = new MirthTable(); taskTable//w w w . j a v a 2 s .c om .setModel(new RefreshTableModel(new Object[] { "Status", "Name", "Description", "Start Time" }, 0)); taskTable.setDragEnabled(false); taskTable.setRowSelectionAllowed(true); taskTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); taskTable.setRowHeight(UIConstants.ROW_HEIGHT); taskTable.setFocusable(false); taskTable.setOpaque(true); taskTable.getTableHeader().setReorderingAllowed(false); taskTable.setEditable(false); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { taskTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } taskTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { checkSelection(evt); } @Override public void mouseReleased(MouseEvent evt) { checkSelection(evt); } private void checkSelection(MouseEvent evt) { if (taskTable.rowAtPoint(new Point(evt.getX(), evt.getY())) < 0) { taskTable.clearSelection(); setVisibleTasks(2, 3, false); } } }); taskTable.getColumnModel().getColumn(0).setMinWidth(75); taskTable.getColumnModel().getColumn(0).setMaxWidth(75); taskTable.getColumnModel().getColumn(0).setCellRenderer(new ImageCellRenderer()); taskTable.getColumnModel().getColumn(1).setMinWidth(45); taskTable.getColumnModel().getColumn(1).setPreferredWidth(250); taskTable.getColumnModel().getColumn(2).setMinWidth(75); taskTable.getColumnModel().getColumn(2).setPreferredWidth(475); taskTable.getColumnModel().getColumn(3).setMinWidth(95); taskTable.getColumnModel().getColumn(3).setMaxWidth(95); taskTable.getColumnModel().getColumn(3).setCellRenderer(new DateCellRenderer()); taskTable.getSelectionModel().addListSelectionListener(this); JScrollPane taskTableScrollPane = new JScrollPane(taskTable); containerPanel.add(taskTableScrollPane, "grow, push"); add(containerPanel, "grow, h 60%"); JPanel channelsPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3, fill")); channelsPanel.setBackground(getBackground()); channelsPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Affected Channels", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11))); channelsTable = new MirthTable(); channelsTable.setModel(new RefreshTableModel(new Object[] { "Name", "Id" }, 0)); channelsTable.setDragEnabled(false); channelsTable.setRowSelectionAllowed(false); channelsTable.setRowHeight(UIConstants.ROW_HEIGHT); channelsTable.setFocusable(false); channelsTable.setOpaque(true); channelsTable.getTableHeader().setReorderingAllowed(false); channelsTable.setEditable(false); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { channelsTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } channelsPanel.add(new JScrollPane(channelsTable), "grow"); add(channelsPanel, "newline, grow, h 40%"); }
From source file:cz.muni.fi.javaseminar.kafa.bookregister.gui.MainWindow.java
private void initAuthorsTable() { authorsTable.getColumnModel().getColumn(2) .setCellEditor(new DatePickerCellEditor(new SimpleDateFormat("dd. MM. yyyy"))); authorsTable.getColumnModel().getColumn(2).setCellRenderer(new DefaultTableCellRenderer() { @Override/*ww w .jav a 2s.c om*/ public Component getTableCellRendererComponent(JTable jtable, Object value, boolean selected, boolean hasFocus, int row, int column) { if (value instanceof Date) { // You could use SimpleDateFormatter instead value = new SimpleDateFormat("dd. MM. yyyy").format(value); } return super.getTableCellRendererComponent(jtable, value, selected, hasFocus, row, column); } }); authorsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ListSelectionModel selectionModel = authorsTable.getSelectionModel(); selectionModel.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { DefaultListSelectionModel source = (DefaultListSelectionModel) e.getSource(); if (source.getMinSelectionIndex() >= 0) { authorsTableModel.setCurrentSlectedIndex(source.getMinSelectionIndex()); } if (!e.getValueIsAdjusting()) { booksTableModel.setAuthorIndex(source.getMinSelectionIndex()); } } }); authorsTable.getColumnModel().getColumn(2) .setCellEditor(new DatePickerCellEditor(new SimpleDateFormat("dd. MM. yyyy"))); authorsTable.getColumnModel().getColumn(2).setCellRenderer(new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable jtable, Object value, boolean selected, boolean hasFocus, int row, int column) { if (value instanceof Date) { // You could use SimpleDateFormatter instead value = new SimpleDateFormat("dd. MM. yyyy").format(value); } return super.getTableCellRendererComponent(jtable, value, selected, hasFocus, row, column); } }); JPopupMenu authorsPopupMenu = new JPopupMenu(); JMenuItem deleteItem = new JMenuItem("Delete"); authorsPopupMenu.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { int rowAtPoint = authorsTable.rowAtPoint( SwingUtilities.convertPoint(authorsPopupMenu, new Point(0, 0), authorsTable)); if (rowAtPoint > -1) { authorsTable.setRowSelectionInterval(rowAtPoint, rowAtPoint); authorsTableModel.setCurrentSlectedIndex(rowAtPoint); } } }); } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // TODO Auto-generated method stub } @Override public void popupMenuCanceled(PopupMenuEvent e) { // TODO Auto-generated method stub } }); deleteItem.addActionListener(new ActionListener() { private Author author; @Override public void actionPerformed(ActionEvent e) { new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { author = authorsTableModel.getAuthors().get(authorsTable.getSelectedRow()); log.debug("Deleting author: " + author.getFirstname() + " " + author.getSurname() + " from database."); authorManager.deleteAuthor(author); return null; } @Override protected void done() { try { get(); } catch (InterruptedException | ExecutionException e) { if (e.getCause() instanceof DataIntegrityViolationException) { JOptionPane.showMessageDialog(MainWindow.this, "Couldn't delete author; there are still some books assigned to him.", "Error", JOptionPane.ERROR_MESSAGE); } log.error("There was an exception thrown during deletion author: " + author.getFirstname() + " " + author.getSurname(), e); return; } updateModel(); } }.execute(); } }); authorsPopupMenu.add(deleteItem); authorsTable.setComponentPopupMenu(authorsPopupMenu); }
From source file:com.sec.ose.osi.ui.frm.main.manage.ManagedProjectTableModel.java
public void setColumnType(JTable table) { table.setShowVerticalLines(false);/*from ww w.ja va2s. c om*/ table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setColumnSelectionAllowed(false); table.setRowSelectionAllowed(false); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.setRowHeight(30); JTableHeader header = table.getTableHeader(); header.setPreferredSize(new java.awt.Dimension(table.getTableHeader().getWidth(), 30)); header.setFont(new Font("Arial", Font.BOLD, 12)); header.setReorderingAllowed(false); TableColumnModel cm = table.getColumnModel(); TableColumn col = null; analyzeHeader = new CheckBoxHeader(new CheckboxHeaderItemListener(table, COL_ANALYZE_TARGET), "Analyze Target"); col = cm.getColumn(COL_ANALYZE_TARGET); col.setHeaderRenderer(analyzeHeader); JCheckBox chkbox = new JCheckBox(); chkbox.setBackground(Color.white); chkbox.setHorizontalAlignment(JLabel.CENTER); col.setCellRenderer(new DefaultTableCellRenderer() { private static final long serialVersionUID = 1L; public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { ManagedProjectTableModel model = (ManagedProjectTableModel) table.getModel(); String sPrjName = (String) table.getValueAt(row, ManagedProjectTableModel.COL_PROJECT_NAME); OSIProjectInfo item = model.getProjectInfo(sPrjName); JCheckBox chkbox = new JCheckBox(); chkbox.setSelected(((Boolean) value).booleanValue()); if (item != null) { chkbox.setEnabled(item.isLocationValid()); } chkbox.setHorizontalAlignment(JLabel.CENTER); chkbox.setBackground(Color.white); return (Component) chkbox; } }); col.setCellEditor(new DefaultCellEditor(chkbox)); col = cm.getColumn(COL_ANALYZE_STATUS); col.setCellRenderer(new StatusIconCellRenderer()); col = cm.getColumn(COL_SOURCE_LOCATION); col.setCellRenderer(new FileBrowseCellRenderer()); col.setCellEditor(new FileBrowseCellEditor()); }
From source file:au.org.ala.delta.intkey.ui.TaxonSelectionDialog.java
private void init(List<Item> taxa, boolean displayNumbering, boolean singleSelect, boolean includeSpecimenAsOption) { ResourceMap resourceMap = Application.getInstance().getContext().getResourceMap(TaxonSelectionDialog.class); resourceMap.injectFields(this); ActionMap actionMap = Application.getInstance().getContext().getActionMap(TaxonSelectionDialog.class, this); setTitle(MessageFormat.format(title, _directiveName)); _fullTextTaxonFormatter = new ItemFormatter(true, CommentStrippingMode.RETAIN, AngleBracketHandlingMode.REPLACE, true, false, false); _panelButtons.setBorder(new EmptyBorder(0, 20, 10, 20)); _panelButtons.setLayout(new GridLayout(0, 5, 5, 5)); _btnOk = new JButton(); _btnOk.setAction(actionMap.get("taxonSelectionDialog_OK")); _btnSelectAll = new JButton(); _btnSelectAll.setAction(actionMap.get("taxonSelectionDialog_SelectAll")); _btnKeywords = new JButton(); _btnKeywords.setAction(actionMap.get("taxonSelectionDialog_Keywords")); _btnImages = new JButton(); _btnImages.setAction(actionMap.get("taxonSelectionDialog_Images")); _btnImages.setEnabled(false);/*from www . ja va2 s. c om*/ _btnSearch = new JButton(); _btnSearch.setAction(actionMap.get("taxonSelectionDialog_Search")); _btnCancel = new JButton(); _btnCancel.setAction(actionMap.get("taxonSelectionDialog_Cancel")); _btnDeselectAll = new JButton(); _btnDeselectAll.setAction(actionMap.get("taxonSelectionDialog_DeselectAll")); _btnFullText = new JButton(); _btnFullText.setAction(actionMap.get("taxonSelectionDialog_FullText")); _btnFullText.setEnabled(false); _btnHelp = new JButton(); _btnHelp.setAction(actionMap.get("taxonSelectionDialog_Help")); // Some of the buttons should not be displayed if not in advanced mode if (_context.getUI().isAdvancedMode()) { _panelButtons.add(_btnOk); _panelButtons.add(_btnSelectAll); _panelButtons.add(_btnKeywords); _panelButtons.add(_btnImages); _panelButtons.add(_btnSearch); _panelButtons.add(_btnCancel); _panelButtons.add(_btnDeselectAll); _panelButtons.add(_btnFullText); _panelButtons.add(_btnHelp); } else { _panelButtons.setLayout(new GridLayout(0, 4, 5, 0)); _panelButtons.add(_btnOk); _panelButtons.add(_btnCancel); _panelButtons.add(_btnSelectAll); _panelButtons.add(_btnDeselectAll); } _selectedTaxa = null; _includeSpecimenAsOption = includeSpecimenAsOption; if (taxa != null) { _listModel = new DefaultListModel(); if (_includeSpecimenAsOption) { _listModel.addElement(IntkeyContext.SPECIMEN_KEYWORD); } for (Item taxon : taxa) { _listModel.addElement(taxon); } _list.setCellRenderer(new TaxonCellRenderer(displayNumbering, false)); _list.setModel(_listModel); } if (singleSelect) { _list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } _list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (_list.getSelectedIndices().length == 1 && !_list.getSelectedValue().equals(IntkeyContext.SPECIMEN_KEYWORD)) { Item taxon = (Item) _list.getSelectedValue(); _btnImages.setEnabled(taxon.getImages().size() > 0); _btnFullText.setEnabled(true); } else { _btnImages.setEnabled(false); _btnFullText.setEnabled(false); } } }); _list.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) { // Treat double click on a list item as the ok button being // pressed. taxonSelectionDialog_OK(); } } }); _selectedKeywords = new ArrayList<String>(); }
From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowserAdvancedFilter.java
private void initMetaDataSearchTable() { metaDataSearchTable.setModel(new DefaultTableModel(new Object[][] {}, new String[] { "Metadata", "Operator", "Value", "Ignore Case" }) { public boolean isCellEditable(int rowIndex, int columnIndex) { if (columnIndex == 3 && cachedMetaDataColumns.get(getValueAt(rowIndex, 0)) .getType() != MetaDataColumnType.STRING) { return false; }/*w ww.j av a 2 s . c o m*/ return true; } @Override public void setValueAt(Object value, int row, int column) { int metaDataColumnIndex = findColumn("Metadata"); int operatorColumnIndex = findColumn("Operator"); int valueColumnIndex = findColumn("Value"); int ignoreCaseColumnIndex = findColumn("Ignore Case"); if (column == valueColumnIndex) { MetaDataColumn metaDataColumn = cachedMetaDataColumns.get(getValueAt(row, metaDataColumnIndex)); if (StringUtils.isNotEmpty((String) value)) { try { metaDataColumn.getType().castValue(value); } catch (MetaDataColumnException e) { parent.alertError(parent, "Invalid value for column type " + metaDataColumn.getType().toString()); return; } } } else if (column == metaDataColumnIndex) { if (!value.equals(getValueAt(row, metaDataColumnIndex))) { MetaDataSearchOperator operator = MetaDataSearchOperator.EQUAL; super.setValueAt(operator, row, operatorColumnIndex); MetaDataColumn metaDataColumn = cachedMetaDataColumns.get(value); if (metaDataColumn.getType() != MetaDataColumnType.STRING) { super.setValueAt(Boolean.FALSE, row, ignoreCaseColumnIndex); } } super.setValueAt("", row, valueColumnIndex); } super.setValueAt(value, row, column); } }); metaDataSearchTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); metaDataSearchTable.setDragEnabled(false); metaDataSearchTable.setSortable(false); metaDataSearchTable.getTableHeader().setReorderingAllowed(false); addMetaDataSearchButton.setEnabled(!messageBrowser.getMetaDataColumns().isEmpty()); metaDataSearchTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { deleteMetaDataSearchButton.setEnabled(getSelectedRow(metaDataSearchTable) != -1); } }); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { metaDataSearchTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } List<MetaDataColumn> metaDataColumns = messageBrowser.getMetaDataColumns(); cachedMetaDataColumns.clear(); String[] metaDataNames = new String[metaDataColumns.size()]; for (int i = 0; i < metaDataColumns.size(); i++) { String columnName = metaDataColumns.get(i).getName(); metaDataNames[i] = columnName; cachedMetaDataColumns.put(columnName, metaDataColumns.get(i)); } MirthComboBoxTableCellEditor metaDataEditor = new MirthComboBoxTableCellEditor(metaDataSearchTable, metaDataNames, 1, false, null); metaDataEditor.getComboBox().setAutoResizeDropdown(true); TableColumn metaDataColumn = metaDataSearchTable.getColumnModel().getColumn(0); metaDataColumn.setCellRenderer(new MirthComboBoxTableCellRenderer(metaDataNames)); metaDataColumn.setCellEditor(metaDataEditor); metaDataColumn.setMinWidth(METADATA_NAME_COLUMN_WIDTH); metaDataColumn.setMaxWidth(METADATA_NAME_COLUMN_WIDTH * 2); metaDataColumn.setPreferredWidth(METADATA_NAME_COLUMN_WIDTH); // Need to create this custom editor since the combo box values are dynamic based on metadata column type. MirthComboBoxTableCellEditor operatorEditor = new MirthComboBoxTableCellEditor(metaDataSearchTable, MetaDataSearchOperator.values(), 1, false, null) { public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { MetaDataColumn metaDataColumn = cachedMetaDataColumns.get(table.getValueAt(row, 0)); comboBox.setModel(new DefaultComboBoxModel( MetaDataSearchOperator.valuesForColumnType(metaDataColumn.getType()))); return super.getTableCellEditorComponent(table, value, isSelected, row, column); } }; TableColumn operatorColumn = metaDataSearchTable.getColumnModel().getColumn(1); operatorColumn.setCellRenderer(new MirthComboBoxTableCellRenderer(MetaDataSearchOperator.values())); operatorColumn.setCellEditor(operatorEditor); operatorColumn.setMinWidth(METADATA_OPERATOR_COLUMN_WIDTH); operatorColumn.setMaxWidth(METADATA_OPERATOR_COLUMN_WIDTH); TableColumn caseColumn = metaDataSearchTable.getColumnModel().getColumn(3); caseColumn.setMinWidth(METADATA_CASE_COLUMN_WIDTH); caseColumn.setMaxWidth(METADATA_CASE_COLUMN_WIDTH); deleteMetaDataSearchButton.setEnabled(false); }
From source file:edu.clemson.cs.nestbed.client.gui.ConfigManagerFrame.java
public ConfigManagerFrame(Testbed testbed, Project project, ProjectDeploymentConfiguration config) throws RemoteException, NotBoundException, MalformedURLException, ClassNotFoundException { super(testbed.getName() + " Deployment Configuration Manager"); this.testbed = testbed; this.project = project; this.config = config; lookupRemoteManagers();//from w w w . ja v a 2s . co m // TODO: We need to deregister listeners programCompileManager.addRemoteObserver(new ProgramCompileObserver()); programManager.addRemoteObserver(new ProgramObserver()); progProfManager.addRemoteObserver(new ProgramProfilingSymbolObserver()); progProfMsgSymManager.addRemoteObserver(new ProgramProfilingMessageSymbolObserver()); createComponents(); programTree.addMouseListener(new ProgramTreeMouseListener()); programTree.setCellRenderer(new ProgramTreeCellRenderer()); programTree.setRootVisible(false); programTree.setShowsRootHandles(true); programTree.setDragEnabled(true); programTree.setTransferHandler(new ProgramTreeTransferHandler()); programTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); profilingSymbolTable.addMouseListener(new ProfilingSymbolTableMouseListener()); profilingSymbolTable.setModel(new ProfilingSymbolTableModel()); profilingSymbolTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); new DropTarget(profilingSymbolTable, DnDConstants.ACTION_COPY_OR_MOVE, new ProgramSymbolDropTarget(), true); profilingMsgTable.addMouseListener(new ProfilingMessageTableMouseListener()); profilingMsgTable.setModel(new ProfilingMessageSymbolTableModel()); profilingMsgTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); new DropTarget(profilingMsgTable, DnDConstants.ACTION_COPY_OR_MOVE, new ProgramMessageSymbolDropTarget(), true); setSize(WINDOW_WIDTH, WINDOW_HEIGHT); setJMenuBar(buildMenuBar()); Container c = getContentPane(); c.setLayout(new BorderLayout()); JSplitPane top = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, buildLeftPanel(), buildMoteGridPanel()); JSplitPane panel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, top, buildBottomPanel()); c.add(panel, BorderLayout.CENTER); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractTable.java
protected void initComponent() { layout = new MigLayout("flowy, fill, insets 0", "", "[min!][fill]"); panel = new JPanel(layout); topPanel = new JPanel(new BorderLayout()); topPanel.setVisible(false);/* w w w .j a v a2 s . co m*/ panel.add(topPanel, "growx"); scrollPane = new JScrollPane(impl); impl.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); impl.setFillsViewportHeight(true); panel.add(scrollPane, "grow"); impl.setShowGrid(true); impl.setGridColor(Color.lightGray); impl.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { handleClickAction(); } } @Override public void mousePressed(MouseEvent e) { showPopup(e); } @Override public void mouseReleased(MouseEvent e) { showPopup(e); } protected void showPopup(MouseEvent e) { if (e.isPopupTrigger() && contextMenuEnabled) { // select row Point p = e.getPoint(); int viewRowIndex = impl.rowAtPoint(p); int rowNumber; if (viewRowIndex >= 0) { rowNumber = impl.convertRowIndexToModel(viewRowIndex); } else { rowNumber = -1; } ListSelectionModel model = impl.getSelectionModel(); if (!model.isSelectedIndex(rowNumber)) { model.setSelectionInterval(rowNumber, rowNumber); } // show popup menu JPopupMenu popupMenu = createPopupMenu(); if (popupMenu.getComponentCount() > 0) { popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } } }); ColumnControlButton columnControlButton = new ColumnControlButton(impl) { @Override protected ColumnVisibilityAction createColumnVisibilityAction(TableColumn column) { ColumnVisibilityAction columnVisibilityAction = super.createColumnVisibilityAction(column); columnVisibilityAction.addPropertyChangeListener(evt -> { if ("SwingSelectedKey".equals(evt.getPropertyName()) && evt.getNewValue() instanceof Boolean) { ColumnVisibilityAction action = (ColumnVisibilityAction) evt.getSource(); String columnName = action.getActionCommand(); boolean collapsed = !((boolean) evt.getNewValue()); Column col = getColumn(columnName); if (col != null) { col.setCollapsed(collapsed); } } }); return columnVisibilityAction; } }; impl.setColumnControl(columnControlButton); impl.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enter"); impl.getActionMap().put("enter", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (enterPressAction != null) { enterPressAction.actionPerform(DesktopAbstractTable.this); } else { handleClickAction(); } } }); Messages messages = AppBeans.get(Messages.NAME); // localize default column control actions for (Object actionKey : impl.getActionMap().allKeys()) { if ("column.packAll".equals(actionKey)) { BoundAction action = (BoundAction) impl.getActionMap().get(actionKey); action.setName(messages.getMessage(DesktopTable.class, "DesktopTable.packAll")); } else if ("column.packSelected".equals(actionKey)) { BoundAction action = (BoundAction) impl.getActionMap().get(actionKey); action.setName(messages.getMessage(DesktopTable.class, "DesktopTable.packSelected")); } else if ("column.horizontalScroll".equals(actionKey)) { BoundAction action = (BoundAction) impl.getActionMap().get(actionKey); action.setName(messages.getMessage(DesktopTable.class, "DesktopTable.horizontalScroll")); } } // Ability to configure fonts in table // Add action to column control String configureFontsLabel = messages.getMessage(DesktopTable.class, "DesktopTable.configureFontsLabel"); impl.getActionMap().put(ColumnControlButton.COLUMN_CONTROL_MARKER + "fonts", new AbstractAction(configureFontsLabel) { @Override public void actionPerformed(ActionEvent e) { Component rootComponent = SwingUtilities.getRoot(impl); final FontDialog fontDialog = FontDialog.show(rootComponent, impl.getFont()); fontDialog.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { Font result = fontDialog.getResult(); if (result != null) { impl.setFont(result); packRows(); } } }); fontDialog.open(); } }); // Ability to reset settings String resetSettingsLabel = messages.getMessage(DesktopTable.class, "DesktopTable.resetSettings"); impl.getActionMap().put(ColumnControlButton.COLUMN_CONTROL_MARKER + "resetSettings", new AbstractAction(resetSettingsLabel) { @Override public void actionPerformed(ActionEvent e) { resetPresentation(); } }); scrollPane.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { if (!columnsInitialized) { adjustColumnHeaders(); } columnsInitialized = true; } }); // init default row height SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (!fontInitialized) { applyFont(impl, impl.getFont()); } } }); }
From source file:net.sf.jabref.gui.plaintextimport.TextInputDialog.java
private void initRawPanel() { rawPanel.setLayout(new BorderLayout()); // Textarea/*ww w.ja v a 2s .c o m*/ textPane.setEditable(false); document = textPane.getStyledDocument(); addStylesToDocument(); try { document.insertString(0, "", document.getStyle("regular")); } catch (BadLocationException ex) { LOGGER.warn("Problem setting style", ex); } OverlayPanel testPanel = new OverlayPanel(textPane, Localization.lang("paste text here")); testPanel.setPreferredSize(new Dimension(450, 255)); testPanel.setMaximumSize(new Dimension(450, Integer.MAX_VALUE)); // Setup fields (required to be done before setting up popup menu) fieldList = new JList<>(getAllFields()); fieldList.setCellRenderer(new SimpleCellRenderer(fieldList.getFont())); ListSelectionModel listSelectionModel = fieldList.getSelectionModel(); listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listSelectionModel.addListSelectionListener(new FieldListSelectionHandler()); fieldList.addMouseListener(new FieldListMouseListener()); // After the call to getAllFields initPopupMenuAndToolbar(); //Add listener to components that can bring up popup menus. MouseListener popupListener = new PopupListener(inputMenu); textPane.addMouseListener(popupListener); testPanel.addMouseListener(popupListener); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.add(toolBar, BorderLayout.NORTH); leftPanel.add(testPanel, BorderLayout.CENTER); JPanel inputPanel = setUpFieldListPanel(); // parse with FreeCite button parseWithFreeCiteButton.addActionListener(event -> { if (parseWithFreeCiteAndAddEntries()) { okPressed = false; // we do not want to have the super method to handle our entries, we do it on our own dispose(); } }); rawPanel.add(leftPanel, BorderLayout.CENTER); rawPanel.add(inputPanel, BorderLayout.EAST); JLabel desc = new JLabel("<html><h3>" + Localization.lang("Plain text import") + "</h3><p>" + Localization.lang("This is a simple copy and paste dialog. First load or paste some text into " + "the text input area.<br>After that, you can mark text and assign it to a BibTeX field.") + "</p></html>"); desc.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); rawPanel.add(desc, BorderLayout.SOUTH); }
From source file:canreg.client.gui.management.CanReg4MigrationInternalFrame.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 . co m */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jScrollPane2 = new javax.swing.JScrollPane(); taskOutput = new javax.swing.JTextArea(); ProgressBar = new javax.swing.JProgressBar(); tabbedPane = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jList1 = new javax.swing.JList(); jPanel2 = new javax.swing.JPanel(); browseCR4Button = new javax.swing.JButton(); cr4Label = new javax.swing.JLabel(); sysDefTextField = new javax.swing.JTextField(); okButton = new javax.swing.JButton(); cancelButton = new javax.swing.JButton(); TotalProgressBar = new javax.swing.JProgressBar(); doneButton = new javax.swing.JButton(); setClosable(true); setMaximizable(true); setResizable(true); org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application .getInstance(canreg.client.CanRegClientApp.class).getContext() .getResourceMap(CanReg4MigrationInternalFrame.class); setTitle(resourceMap.getString("Form.title")); // NOI18N setFrameIcon(resourceMap.getIcon("Form.frameIcon")); // NOI18N setName("Form"); // NOI18N jScrollPane2.setName("jScrollPane2"); // NOI18N taskOutput.setColumns(20); taskOutput.setFont(resourceMap.getFont("taskOutput.font")); // NOI18N taskOutput.setRows(5); taskOutput.setName("taskOutput"); // NOI18N jScrollPane2.setViewportView(taskOutput); ProgressBar.setName("ProgressBar"); // NOI18N ProgressBar.setStringPainted(true); tabbedPane.setName("tabbedPane"); // NOI18N jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Select Registry For Migration")); jPanel1.setName("jPanel1"); // NOI18N jScrollPane1.setName("jScrollPane1"); // NOI18N jList1.setFont(resourceMap.getFont("jList1.font")); // NOI18N jList1.setModel(dlm); jList1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jList1.setName("jList1"); // NOI18N jList1.setSelectedIndex(0); jList1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jList1MouseClicked(evt); } }); jScrollPane1.setViewportView(jList1); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout .setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 704, Short.MAX_VALUE)); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)); tabbedPane.addTab(resourceMap.getString("jPanel1.TabConstraints.tabTitle"), jPanel1); // NOI18N jPanel2.setName("jPanel2"); // NOI18N javax.swing.ActionMap actionMap = org.jdesktop.application.Application .getInstance(canreg.client.CanRegClientApp.class).getContext() .getActionMap(CanReg4MigrationInternalFrame.class, this); browseCR4Button.setAction(actionMap.get("browseDefAction")); // NOI18N browseCR4Button.setText(resourceMap.getString("browseCR4Button.text")); // NOI18N browseCR4Button.setName("browseCR4Button"); // NOI18N cr4Label.setText(resourceMap.getString("cr4Label.text")); // NOI18N cr4Label.setName("cr4Label"); // NOI18N sysDefTextField.setName("sysDefTextField"); // NOI18N javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(cr4Label).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addComponent(sysDefTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 623, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(browseCR4Button))) .addContainerGap())); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap() .addComponent(cr4Label, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(sysDefTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(browseCR4Button)) .addContainerGap(140, Short.MAX_VALUE))); tabbedPane.addTab(resourceMap.getString("jPanel2.TabConstraints.tabTitle"), jPanel2); // NOI18N okButton.setAction(actionMap.get("MigrationAction")); // NOI18N okButton.setText(resourceMap.getString("okButton.text")); // NOI18N okButton.setToolTipText(resourceMap.getString("okButton.toolTipText")); // NOI18N okButton.setActionCommand(resourceMap.getString("okButton.actionCommand")); // NOI18N okButton.setEnabled(false); okButton.setName("okButton"); // NOI18N cancelButton.setAction(actionMap.get("cancelAction")); // NOI18N cancelButton.setText(resourceMap.getString("cancelButton.text")); // NOI18N cancelButton.setEnabled(false); cancelButton.setName("cancelButton"); // NOI18N TotalProgressBar.setName("TotalProgressBar"); // NOI18N TotalProgressBar.setString(resourceMap.getString("TotalProgressBar.string")); // NOI18N TotalProgressBar.setStringPainted(true); doneButton.setAction(actionMap.get("DoneAction")); // NOI18N doneButton.setText(resourceMap.getString("doneButton.text")); // NOI18N doneButton.setEnabled(false); doneButton.setName("doneButton"); // NOI18N 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(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 721, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 721, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap() .addComponent(doneButton, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(cancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup().addGap(89, 89, 89).addComponent(ProgressBar, javax.swing.GroupLayout.DEFAULT_SIZE, 642, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGap(89, 89, 89).addComponent(TotalProgressBar, javax.swing.GroupLayout.DEFAULT_SIZE, 642, Short.MAX_VALUE))) .addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addComponent(tabbedPane, javax.swing.GroupLayout.PREFERRED_SIZE, 244, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(okButton).addComponent(cancelButton).addComponent(doneButton)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(ProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(TotalProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE) .addContainerGap())); pack(); }