示例#1
0
 public static void main(String[] args) {
   /*
   构造函数有很多下面先介绍几个:
   JTable()
   JTable(int numRows, int numColumns)
   JTable(Object[][] rowData, Object[] columnNames)
   */
   JTable example1 = new JTable(); // 看不到但存在
   JTable example2 = new JTable(8, 6);
   final Object[] columnNames = {
     "姓名", "性别", "家庭地址", // 列名最好用final修饰
     "电话号码", "生日", "工作", "收入", "婚姻状况", "恋爱状况"
   };
   Object[][] rowData = {
     {"ddd", "男", "江苏南京", "1378313210", "03/24/1985", "学生", "寄生中", "未婚", "没"},
     {"eee", "女", "江苏南京", "13645181705", "xx/xx/1985", "家教", "未知", "未婚", "好象没"},
     {"fff", "男", "江苏南京", "13585331486", "12/08/1985", "汽车推销员", "不确定", "未婚", "有"},
     {"ggg", "女", "江苏南京", "81513779", "xx/xx/1986", "宾馆服务员", "确定但未知", "未婚", "有"},
     {"hhh", "男", "江苏南京", "13651545936", "xx/xx/1985", "学生", "流放中", "未婚", "无数次分手后没有"}
   };
   JTable friends = new JTable(rowData, columnNames);
   friends.setPreferredScrollableViewportSize(new Dimension(600, 100)); // 设置表格的大小
   friends.setRowHeight(30); // 设置每行的高度为20
   friends.setRowHeight(0, 20); // 设置第1行的高度为15
   friends.setRowMargin(5); // 设置相邻两行单元格的距离
   friends.setRowSelectionAllowed(true); // 设置可否被选择.默认为false
   friends.setSelectionBackground(Color.white); // 设置所选择行的背景色
   friends.setSelectionForeground(Color.red); // 设置所选择行的前景色
   friends.setGridColor(Color.black); // 设置网格线的颜色
   friends.selectAll(); // 选择所有行
   friends.setRowSelectionInterval(0, 2); // 设置初始的选择行,这里是1到3行都处于选择状态
   friends.clearSelection(); // 取消选择
   friends.setDragEnabled(false); // 不懂这个
   friends.setShowGrid(false); // 是否显示网格线
   friends.setShowHorizontalLines(false); // 是否显示水平的网格线
   friends.setShowVerticalLines(true); // 是否显示垂直的网格线
   friends.setValueAt("tt", 0, 0); // 设置某个单元格的值,这个值是一个对象
   friends.doLayout();
   friends.setBackground(Color.lightGray);
   JScrollPane pane1 = new JScrollPane(example1); // JTable最好加在JScrollPane上
   JScrollPane pane2 = new JScrollPane(example2);
   JScrollPane pane3 = new JScrollPane(friends);
   JPanel panel = new JPanel(new GridLayout(0, 1));
   panel.setPreferredSize(new Dimension(600, 400));
   panel.setBackground(Color.black);
   panel.add(pane1);
   panel.add(pane2);
   panel.add(pane3);
   JFrame frame = new JFrame("JTableDemo");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setContentPane(panel);
   frame.pack();
   frame.show();
 }
示例#2
0
  public TargetTablePanel(String[] targetData, String delim, int id_colIdx, int length_colIdx)
      throws Exception { // exception when there are data format problem in targetData
    JTextArea jta_desc =
        new JTextArea(
            "Pick the primary and secondary targets. siRNA oligos will be enumerated from the primary target"
                + " and their occurrence in secondary targets (orthologs) will be reported. By default, the longest human transcript is selected"
                + " as the primary target. Any other transcripts longer than half the length of the primary transcript are selected as secondary transcripts\n");

    jta_desc.setEditable(false);
    jta_desc.setWrapStyleWord(true);

    jta_desc.setLineWrap(true);
    jta_desc.setBackground(new JLabel().getBackground());

    this.setLayout(new BorderLayout());
    this.add(jta_desc, BorderLayout.NORTH);

    model = new TargetTableModel(targetData, delim, id_colIdx, length_colIdx);
    model.addTableModelListener(this);
    sorter = new SimpleTableSorter(model);
    targetTable.setDragEnabled(true);
    targetTable.setModel(sorter);
    targetTable.createDefaultColumnsFromModel();
    targetTable.addMouseListener(new TargetTableMouseAdaptor());

    sorter.setTableHeader(targetTable.getTableHeader());
    jsp_center = new JScrollPane(targetTable);
    Dimension d = jsp_center.getViewport().getViewSize();
    d.height = 300;
    jsp_center.getViewport().setViewSize(d);
    this.add(jsp_center, BorderLayout.CENTER);

    setupCellRenderer();

    JPanel bttn_pane = new JPanel();
    bttn_pane.setLayout(new FlowLayout(FlowLayout.TRAILING));
    bttn_addTranscript = new JButton("Add Transcripts");
    bttn_pane.add(bttn_addTranscript);
    bttn_addTranscript.addActionListener(this);
    bttn_deleteTranscript = new JButton("Delete Selected");
    bttn_deleteTranscript.addActionListener(this);
    bttn_pane.add(bttn_deleteTranscript);
    this.add(bttn_pane, BorderLayout.SOUTH);
    this.setPreferredSize(d);
  }
  protected JTable buildPropertiesTable() {
    propertiesModel = getPropertyHolderTableModel();
    propertiesTable = new PropertiesHolderJTable();
    propertiesTable.setName(PROPERTIES_HOLDER_TABLE_NAME);
    propertiesTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    propertiesTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                int selectedRow = propertiesTable.getSelectedRow();
                if (removePropertyAction != null) {
                  removePropertyAction.setEnabled(selectedRow != -1);
                }

                if (movePropertyUpAction != null) {
                  movePropertyUpAction.setEnabled(selectedRow > 0);
                }

                if (movePropertyDownAction != null) {
                  movePropertyDownAction.setEnabled(
                      selectedRow >= 0 && selectedRow < propertiesTable.getRowCount() - 1);
                }
              }
            });

    propertiesTable.setDragEnabled(true);
    propertiesTable.setTransferHandler(new TransferHandler("testProperty"));

    if (getHolder().getModelItem() != null) {
      DropTarget dropTarget =
          new DropTarget(propertiesTable, new PropertyHolderTablePropertyExpansionDropTarget());
      dropTarget.setDefaultActions(DnDConstants.ACTION_COPY_OR_MOVE);
    }

    // Set render this only for value column. In this cell render we handle password shadowing.
    propertiesTable
        .getColumnModel()
        .getColumn(1)
        .setCellRenderer(new PropertiesTableCellRenderer());
    return propertiesTable;
  }
示例#4
0
  public SwingDnDFrame() {
    setTitle("SwingDnDTest");
    JTabbedPane tabbedPane = new JTabbedPane();

    JList list = SampleComponents.list();
    tabbedPane.addTab("List", list);
    JTable table = SampleComponents.table();
    tabbedPane.addTab("Table", table);
    JTree tree = SampleComponents.tree();
    tabbedPane.addTab("Tree", tree);
    JFileChooser fileChooser = new JFileChooser();
    tabbedPane.addTab("File Chooser", fileChooser);
    JColorChooser colorChooser = new JColorChooser();
    tabbedPane.addTab("Color Chooser", colorChooser);

    final JTextArea textArea = new JTextArea(4, 40);
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setBorder(new TitledBorder(new EtchedBorder(), "Drag text here"));

    JTextField textField = new JTextField("Drag color here");
    textField.setTransferHandler(new TransferHandler("background"));

    tabbedPane.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            textArea.setText("");
          }
        });

    tree.setDragEnabled(true);
    table.setDragEnabled(true);
    list.setDragEnabled(true);
    fileChooser.setDragEnabled(true);
    colorChooser.setDragEnabled(true);
    textField.setDragEnabled(true);

    add(tabbedPane, BorderLayout.NORTH);
    add(scrollPane, BorderLayout.CENTER);
    add(textField, BorderLayout.SOUTH);
    pack();
  }
示例#5
0
  /** Make pick table, DND enabled */
  public JTable makePickTable() {
    this.init();
    try { // following might fail due to a missing method on Mac Classic
      _sorter = new TableSorter(this);
      _table = jmri.util.JTableUtil.sortableDataModel(_sorter);
      _sorter.setTableHeader(_table.getTableHeader());
      _sorter.setColumnComparator(String.class, new jmri.util.SystemNameComparator());
      _table.setModel(_sorter);
    } catch (Throwable e) { // NoSuchMethodError, NoClassDefFoundError and others on early JVMs
      log.error("makePickTable: Unexpected error: " + e);
      _table = new JTable(this);
    }

    _table.setRowSelectionAllowed(true);
    _table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    _table.setPreferredScrollableViewportSize(
        new java.awt.Dimension(250, _table.getRowHeight() * 7));
    _table.setDragEnabled(true);
    _table.setTransferHandler(new jmri.util.DnDTableExportHandler());

    _table.getTableHeader().setReorderingAllowed(true);
    _table.setColumnModel(new XTableColumnModel());
    _table.createDefaultColumnsFromModel();
    TableColumnModel columnModel = _table.getColumnModel();

    TableColumn sNameColumnT = columnModel.getColumn(SNAME_COLUMN);
    sNameColumnT.setResizable(true);
    sNameColumnT.setMinWidth(50);
    // sNameColumnT.setMaxWidth(200);

    TableColumn uNameColumnT = columnModel.getColumn(UNAME_COLUMN);
    uNameColumnT.setResizable(true);
    uNameColumnT.setMinWidth(100);
    // uNameColumnT.setMaxWidth(300);

    addMouseListenerToHeader(_table);

    return _table;
  }
示例#6
0
文件: UI.java 项目: bkdwei/DBViewer
  // 设置UI元素的属性
  public void compose() {
    frame.setSize(954, 750);
    frame.setLocation(200, 50);
    frame.setResizable(true);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new BorderLayout());

    // 工具栏
    toolBar.add(btDeleteTableData);
    toolBar.add(tfSqlCommand);
    toolBar.add(btExecuteSql);
    toolBar.add(btAbout);
    frame.add("North", toolBar);

    // 数据管理层

    westJPanel.setLayout(new BorderLayout());
    westJPanel.add("North", search);
    westJPanel.add("Center", awtList);
    frame.add("West", westJPanel);

    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setShowGrid(true);
    table.setAutoscrolls(true);
    table.setDragEnabled(true);
    table.setCellSelectionEnabled(true);
    table.setSelectionBackground(new Color(233, 223, 233));
    scrollPane.setViewportView(table);

    frame.add("Center", scrollPane);

    statusBar.setAlignmentX(JLabel.RIGHT);
    frame.add("South", statusBar);

    frame.setVisible(true);
  }
示例#7
0
  public InputPanel(
      final TreeSpaceFrame parent, final TreeSpaceDocument document, final Action addDataAction) {

    this.frame = parent;
    this.document = document;

    dataTableModel = new DataTableModel();
    dataTable = new JTable(dataTableModel);

    dataTable.getTableHeader().setReorderingAllowed(false);
    //        dataTable.getTableHeader().setDefaultRenderer(
    //                new HeaderRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4)));

    TableColumn col = dataTable.getColumnModel().getColumn(0);
    col.setCellRenderer(new MultiLineTableCellRenderer());

    dataTable.setRowHeight(dataTable.getRowHeight() * 2);

    dataTable.setDragEnabled(false);
    dataTable.setTransferHandler(new FSTransfer());

    TableEditorStopper.ensureEditingStopWhenTableLosesFocus(dataTable);

    dataTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent evt) {
                selectionChanged();
              }
            });

    dataTable.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
              editSelection();
            }
          }
        });

    scrollPane =
        new JScrollPane(
            dataTable,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane.setOpaque(false);

    //        JToolBar toolBar1 = new JToolBar();
    //        toolBar1.setFloatable(false);
    //        toolBar1.setOpaque(false);
    //        toolBar1.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));

    //        JButton button = new JButton(unlinkModelsAction);
    //        unlinkModelsAction.setEnabled(false);
    //        PanelUtils.setupComponent(button);
    //        toolBar1.add(button);

    ActionPanel actionPanel1 = new ActionPanel(true);
    actionPanel1.setAddAction(addDataAction);
    actionPanel1.setRemoveAction(removeAction);

    removeAction.setEnabled(false);

    JPanel controlPanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    controlPanel1.setOpaque(false);
    controlPanel1.add(actionPanel1);

    setOpaque(false);
    setBorder(new BorderUIResource.EmptyBorderUIResource(new Insets(12, 12, 12, 12)));
    setLayout(new BorderLayout(0, 0));
    //        add(toolBar1, BorderLayout.NORTH);
    add(scrollPane, BorderLayout.CENTER);
    add(controlPanel1, BorderLayout.SOUTH);

    document.addListener(
        new TreeSpaceDocument.Listener() {
          public void dataChanged() {
            dataTableModel.fireTableDataChanged();
          }

          public void settingsChanged() {}
        });
  }
  public JComponent createComponentImpl() {
    final DefaultTableModel tableModel = createModel();
    myTable = new JBTable(tableModel);
    myTable.setIntercellSpacing(new Dimension(0, 0));
    myTable.setDefaultRenderer(TableItem.class, new MyRenderer());
    myTable.setShowGrid(false);
    myTable.setDragEnabled(false);
    myTable.setShowHorizontalLines(false);
    myTable.setShowVerticalLines(false);
    myTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    JPanel tablePanel =
        ToolbarDecorator.createDecorator(myTable)
            .setAddAction(
                new AnActionButtonRunnable() {
                  @Override
                  public void run(AnActionButton button) {
                    FileChooserDescriptor myDescriptor =
                        FileChooserDescriptorFactory.createSingleFolderDescriptor();
                    myDescriptor.setTitle(
                        ProjectBundle.message("add.external.annotations.path.title"));
                    myDescriptor.setDescription(
                        ProjectBundle.message("add.external.annotations.path.description"));
                    VirtualFile[] files =
                        FileChooser.chooseFiles(myDescriptor, myTable, myProject, null);
                    final MyTableModel tableModel = (MyTableModel) myTable.getModel();
                    boolean changes = false;
                    for (final VirtualFile file : files) {
                      if (file != null) {
                        tableModel.addTableItem(new TableItem(file));
                        changes = true;
                      }
                    }
                    if (changes) {
                      saveData();
                      TableUtil.selectRows(myTable, new int[] {tableModel.getRowCount() - 1});
                    }
                  }
                })
            .setRemoveAction(
                new AnActionButtonRunnable() {
                  @Override
                  public void run(AnActionButton button) {
                    final List removedItems = TableUtil.removeSelectedItems(myTable);
                    if (removedItems.size() > 0) {
                      saveData();
                    }
                  }
                })
            .createPanel();

    final JPanel mainPanel = new JPanel(new BorderLayout());

    mainPanel.add(tablePanel, BorderLayout.CENTER);
    mainPanel.add(
        new JBLabel(
            ProjectBundle.message("project.roots.external.annotations.description"),
            UIUtil.ComponentStyle.SMALL,
            UIUtil.FontColor.BRIGHTER),
        BorderLayout.NORTH);
    return mainPanel;
  }
  public MemoryPanel(final Debugger debugger, boolean is64Bit) {
    super();
    this.debugger = debugger;
    this.is64Bit = is64Bit;
    if (is64Bit) {
      addressSize = 8;
      unmappedAddrString = "??????????????????";
    } else {
      addressSize = 4;
      unmappedAddrString = "??????????";
    }
    setLayout(new BorderLayout());
    setupScrollBar();
    add(scrollBar, BorderLayout.EAST);

    model =
        new AbstractTableModel() {
          public int getRowCount() {
            return numVisibleRows;
          }

          public int getColumnCount() {
            return 2;
          }

          public Object getValueAt(int row, int column) {
            switch (column) {
              case 0:
                return bigIntToHexString(
                    startVal.add(new BigInteger(Integer.toString((row * addressSize)))));
              case 1:
                {
                  try {
                    Address addr =
                        bigIntToAddress(
                            startVal.add(new BigInteger(Integer.toString((row * addressSize)))));
                    if (addr != null) {
                      return addressToString(addr.getAddressAt(0));
                    }
                    return unmappedAddrString;
                  } catch (UnmappedAddressException e) {
                    return unmappedAddrString;
                  }
                }
              default:
                throw new RuntimeException("Column " + column + " out of bounds");
            }
          }

          public boolean isCellEditable(int row, int col) {
            return false;
          }
        };

    // View with JTable with no header
    table = new JTable(model);
    table.setTableHeader(null);
    table.setShowGrid(false);
    table.setIntercellSpacing(new Dimension(0, 0));
    table.setCellSelectionEnabled(true);
    table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    table.setDragEnabled(true);
    Font font = GraphicsUtilities.lookupFont("Courier");
    if (font == null) {
      throw new RuntimeException("Error looking up monospace font Courier");
    }
    table.setFont(font);

    // Export proper data.
    // We need to keep our own notion of the selection in order to
    // properly export data, since the selection can go beyond the
    // visible area on the screen (and since the table's model doesn't
    // back all of those slots).
    // Code thanks to Shannon.Hickey@sfbay
    table.setTransferHandler(
        new TransferHandler() {
          protected Transferable createTransferable(JComponent c) {
            JTable table = (JTable) c;
            if (haveSelection()) {
              StringBuffer buf = new StringBuffer();
              int iDir = (getRowAnchor() < getRowLead() ? 1 : -1);
              int jDir = (getColAnchor() < getColLead() ? 1 : -1);

              for (int i = getRowAnchor(); i != getRowLead() + iDir; i += iDir) {
                for (int j = getColAnchor(); j != getColLead() + jDir; j += jDir) {
                  Object val = model.getValueAt(i, j);
                  buf.append(val == null ? "" : val.toString());
                  if (j != getColLead()) {
                    buf.append("\t");
                  }
                }
                if (i != getRowLead()) {
                  buf.append("\n");
                }
              }

              return new StringTransferable(buf.toString());
            }
            return null;
          }

          public int getSourceActions(JComponent c) {
            return COPY;
          }

          public boolean importData(JComponent c, Transferable t) {
            if (canImport(c, t.getTransferDataFlavors())) {
              try {
                String str = (String) t.getTransferData(DataFlavor.stringFlavor);
                handleImport(c, str);
                return true;
              } catch (UnsupportedFlavorException ufe) {
              } catch (IOException ioe) {
              }
            }

            return false;
          }

          public boolean canImport(JComponent c, DataFlavor[] flavors) {
            for (int i = 0; i < flavors.length; i++) {
              if (DataFlavor.stringFlavor.equals(flavors[i])) {
                return true;
              }
            }
            return false;
          }

          private void handleImport(JComponent c, String str) {
            // do whatever you want with the string here
            try {
              makeVisible(debugger.parseAddress(str));
              clearSelection();
              table.clearSelection();
            } catch (NumberFormatException e) {
              System.err.println("Unable to parse address \"" + str + "\"");
            }
          }
        });

    // Supporting keyboard scrolling
    // See src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java,
    // search for Table.AncestorInputMap

    // Actions to override:
    // selectPreviousRow, selectNextRow,
    // scrollUpChangeSelection, scrollDownChangeSelection,
    // selectPreviousRowExtendSelection, selectNextRowExtendSelection,
    // scrollDownExtendSelection, scrollUpExtendSelection (Shift-PgDn/PgUp)

    ActionMap map = table.getActionMap();

    // Up arrow
    installActionWrapper(
        map,
        "selectPreviousRow",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            clearSelection();
            if (table.getSelectedRow() == 0) {
              scrollBar.scrollUpOrLeft();
              table.setRowSelectionInterval(0, 0);
            } else {
              super.actionPerformed(e);
            }
            maybeGrabSelection();
            endUpdate();
          }
        });
    // Down arrow
    installActionWrapper(
        map,
        "selectNextRow",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            clearSelection();
            int row = table.getSelectedRow();
            if (row >= numUsableRows) {
              scrollBar.scrollDownOrRight();
              table.setRowSelectionInterval(row, row);
            } else {
              super.actionPerformed(e);
            }
            maybeGrabSelection();
            endUpdate();
          }
        });
    // Page up
    installActionWrapper(
        map,
        "scrollUpChangeSelection",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            clearSelection();
            int row = table.getSelectedRow();
            scrollBar.pageUpOrLeft();
            if (row >= 0) {
              table.setRowSelectionInterval(row, row);
            }
            maybeGrabSelection();
            endUpdate();
          }
        });
    // Page down
    installActionWrapper(
        map,
        "scrollDownChangeSelection",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            clearSelection();
            int row = table.getSelectedRow();
            scrollBar.pageDownOrRight();
            if (row >= 0) {
              table.setRowSelectionInterval(row, row);
            }
            maybeGrabSelection();
            endUpdate();
          }
        });
    // Shift + Up arrow
    installActionWrapper(
        map,
        "selectPreviousRowExtendSelection",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            if (!haveAnchor()) {
              setAnchorFromTable();
              setLeadFromTable();
              //            setAnchor(table.getSelectedRow());
              //            setLead(table.getSelectedRow());
            }
            int newLead = getRowLead() - 1;
            int newAnchor = getRowAnchor();
            if (newLead < 0) {
              scrollBar.scrollUpOrLeft();
              ++newLead;
              ++newAnchor;
            }
            setSelection(newAnchor, newLead, getColAnchor(), getColLead());
            //          printSelection();
            endUpdate();
          }
        });
    // Shift + Left arrow
    installActionWrapper(
        map,
        "selectPreviousColumnExtendSelection",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            if (!haveAnchor()) {
              setAnchorFromTable();
              setLeadFromTable();
            }
            int newLead = Math.max(0, getColLead() - 1);
            setSelection(getRowAnchor(), getRowLead(), getColAnchor(), newLead);
            //          printSelection();
            endUpdate();
          }
        });
    // Shift + Down arrow
    installActionWrapper(
        map,
        "selectNextRowExtendSelection",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            if (!haveAnchor()) {
              setAnchorFromTable();
              setLeadFromTable();
              //            setAnchor(table.getSelectedRow());
              //            setLead(table.getSelectedRow());
            }
            int newLead = getRowLead() + 1;
            int newAnchor = getRowAnchor();
            if (newLead > numUsableRows) {
              scrollBar.scrollDownOrRight();
              --newLead;
              --newAnchor;
            }
            setSelection(newAnchor, newLead, getColAnchor(), getColLead());
            //          printSelection();
            endUpdate();
          }
        });
    // Shift + Right arrow
    installActionWrapper(
        map,
        "selectNextColumnExtendSelection",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            if (!haveAnchor()) {
              setAnchorFromTable();
              setLeadFromTable();
            }
            int newLead = Math.min(model.getColumnCount() - 1, getColLead() + 1);
            setSelection(getRowAnchor(), getRowLead(), getColAnchor(), newLead);
            //          printSelection();
            endUpdate();
          }
        });
    // Shift + Page up
    installActionWrapper(
        map,
        "scrollUpExtendSelection",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            if (!haveAnchor()) {
              setAnchorFromTable();
              setLeadFromTable();
              //            setAnchor(table.getSelectedRow());
              //            setLead(table.getSelectedRow());
            }
            int newLead = getRowLead() - numUsableRows;
            int newAnchor = getRowAnchor();
            if (newLead < 0) {
              scrollBar.pageUpOrLeft();
              newLead += numUsableRows;
              newAnchor += numUsableRows;
            }
            setSelection(newAnchor, newLead, getColAnchor(), getColLead());
            //          printSelection();
            endUpdate();
          }
        });
    // Shift + Page down
    installActionWrapper(
        map,
        "scrollDownExtendSelection",
        new ActionWrapper() {
          public void actionPerformed(ActionEvent e) {
            beginUpdate();
            if (!haveAnchor()) {
              setAnchorFromTable();
              setLeadFromTable();
              //            setAnchor(table.getSelectedRow());
              //            setLead(table.getSelectedRow());
            }
            int newLead = getRowLead() + numUsableRows;
            int newAnchor = getRowAnchor();
            if (newLead > numUsableRows) {
              scrollBar.pageDownOrRight();
              newLead -= numUsableRows;
              newAnchor -= numUsableRows;
            }
            setSelection(newAnchor, newLead, getColAnchor(), getColLead());
            //          printSelection();
            endUpdate();
          }
        });

    // Clear our notion of selection upon mouse press
    table.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            if (shouldIgnore(e)) {
              return;
            }
            // Make shift-clicking work properly
            if (e.isShiftDown()) {
              maybeGrabSelection();
              return;
            }
            //          System.err.println("  Clearing selection on mouse press");
            clearSelection();
          }
        });

    // Watch for mouse going out of bounds
    table.addMouseMotionListener(
        new MouseMotionAdapter() {
          public void mouseDragged(MouseEvent e) {
            if (shouldIgnore(e)) {
              //            System.err.println("  (Ignoring consumed mouse event)");
              return;
            }

            // Look for drag events outside table and scroll if necessary
            Point p = e.getPoint();
            if (table.rowAtPoint(p) == -1) {
              // See whether we are above or below the table
              Rectangle rect = new Rectangle();
              getBounds(rect);
              beginUpdate();
              if (p.y < rect.y) {
                //              System.err.println("  Scrolling up due to mouse event");
                // Scroll up
                scrollBar.scrollUpOrLeft();
                setSelection(getRowAnchor(), 0, getColAnchor(), getColLead());
              } else {
                //              System.err.println("  Scrolling down due to mouse event");
                // Scroll down
                scrollBar.scrollDownOrRight();
                setSelection(getRowAnchor(), numUsableRows, getColAnchor(), getColLead());
              }
              //            printSelection();
              endUpdate();
            } else {
              maybeGrabSelection();
            }
          }
        });

    add(table, BorderLayout.CENTER);

    // Make sure we recompute number of visible rows
    addComponentListener(
        new ComponentAdapter() {
          public void componentResized(ComponentEvent e) {
            recomputeNumVisibleRows();
            constrain();
          }
        });
    addHierarchyListener(
        new HierarchyListener() {
          public void hierarchyChanged(HierarchyEvent e) {
            recomputeNumVisibleRows();
            constrain();
          }
        });
    updateFromScrollBar();
  }
  private void setupTables() throws Exception {

    templateTableModel =
        new ListTableModel<InFacilityLaboItem>(
            TEMPLATE_COL_NAME, START_NUM_ROW, TEMPLATE_COL_METHOD, null) {

          @Override
          public boolean isCellEditable(int row, int column) {
            return false;
          }
        };

    setTableModel =
        new ListTableModel<InFacilityLaboItem>(SET_COL_NAME, START_NUM_ROW, SET_COL_METHOD, null) {
          @Override
          public boolean isCellEditable(int row, int column) {
            if (column == VALUE_COL || column == NORMAL_COL || column == UNIT_COL) {
              return true;
            }
            return false;
          }

          @Override
          public void setValueAt(Object obj, int row, int column) {

            if (column != VALUE_COL && column != NORMAL_COL && column != UNIT_COL) {
              return;
            }
            InFacilityLaboItem item = (InFacilityLaboItem) setTableModel.getObject(row);
            String value = (String) obj;
            value = toHalfNumber(value).trim();
            switch (column) {
              case VALUE_COL:
                item.setItemValue(value);
                break;
              case NORMAL_COL:
                item.setNormalValue(value);
                break;
              case UNIT_COL:
                item.setUnit(value);
                break;
            }
            item.setAbnormalFlg(getAbnormalFlg(item));
          }
        };

    List<InFacilityLaboItem> defaultList = InFacilityLaboTable.createLaboItemList();
    templateTableModel.setDataProvider(defaultList);
    templateTable.setModel(templateTableModel);
    StripeTableCellRenderer renderer = new StripeTableCellRenderer(templateTable);
    renderer.setDefaultRenderer();
    templateTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    templateTable.getTableHeader().setReorderingAllowed(false);
    // 列幅を設定する
    int len = TEMPLATE_COL_NAME.length;
    TableColumn column;
    for (int i = 0; i < len; i++) {
      column = templateTable.getColumnModel().getColumn(i);
      column.setPreferredWidth(TEMPLATE_COL_WIDTH[i]);
    }
    templateTable.setDragEnabled(true);
    InFacilityLaboTransferHandler tHandler = new InFacilityLaboTransferHandler();
    tHandler.setEditable(false);
    templateTable.setTransferHandler(tHandler);

    MasudaDelegater del = MasudaDelegater.getInstance();
    List<InFacilityLaboItem> facilityList = del.getInFacilityLaboItemList();
    setTableModel.setDataProvider(facilityList);
    setTable.setModel(setTableModel);
    renderer = new StripeTableCellRenderer(setTable);
    renderer.setDefaultRenderer();
    setTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    setTable.getTableHeader().setReorderingAllowed(false);
    // 列幅を設定する
    len = SET_COL_NAME.length;
    for (int i = 0; i < len; i++) {
      column = setTable.getColumnModel().getColumn(i);
      column.setPreferredWidth(SET_COL_WIDTH[i]);
    }
    setTable.setDragEnabled(true);
    setTable.setDropMode(DropMode.INSERT_ROWS);
    setTable.setColumnSelectionAllowed(false);
    setTable.setCellSelectionEnabled(true);
    InFacilityLaboTransferHandler sHandler = new InFacilityLaboTransferHandler();
    sHandler.setEditable(true);
    setTable.setTransferHandler(sHandler);
    setTable.addMouseMotionListener(new SetTableMouseMotionListener());
  }
示例#11
0
  /** Create the frame. */
  public GenXml() {
    setResizable(false);
    setTitle("XML生成向导");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 670, 500);
    contentPane = new JPanel();
    contentPane.setBorder(new LineBorder(Color.DARK_GRAY, 4));
    setContentPane(contentPane);
    contentPane.setLayout(new BorderLayout(0, 0));

    btnpanel = new JPanel();
    btnpanel.setBackground(Color.DARK_GRAY);
    btnpanel.setBorder(new LineBorder(Color.DARK_GRAY));
    btnpanel.setPreferredSize(new Dimension(10, 60));
    contentPane.add(btnpanel, BorderLayout.SOUTH);
    btnpanel.setLayout(null);

    prevBtn = new JButton("上一步");
    prevBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            prev();
          }
        });
    prevBtn.setEnabled(false);
    prevBtn.setBounds(294, 10, 113, 40);
    btnpanel.add(prevBtn);

    nextBtn = new JButton("下一步");
    nextBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            next();
          }
        });
    nextBtn.setBounds(417, 10, 113, 40);
    btnpanel.add(nextBtn);

    doneBtn = new JButton("完成");
    doneBtn.addActionListener(doneListener);
    doneBtn.setEnabled(false);
    doneBtn.setBounds(540, 10, 113, 40);
    btnpanel.add(doneBtn);

    card = new CardLayout(0, 0);
    pane = new JPanel(card);
    contentPane.add(pane, BorderLayout.CENTER);

    step1 = new JPanel();
    step1.setBackground(Color.LIGHT_GRAY);
    step1.setBorder(new LineBorder(new Color(0, 0, 0)));
    pane.add(step1, "name_287780550285180");
    step1.setLayout(null);

    JLabel label = new JLabel("请输入类名(全路径):");
    label.setFont(new Font("宋体", Font.PLAIN, 18));
    label.setBounds(10, 42, 344, 43);
    step1.add(label);

    classPath = new JTextField();
    classPath.setForeground(Color.BLACK);
    classPath.setBackground(Color.WHITE);
    classPath.setFont(new Font("宋体", Font.BOLD, 20));
    classPath.setBounds(10, 95, 636, 52);
    step1.add(classPath);
    classPath.setColumns(10);

    JLabel lblxml = new JLabel("保存xml路径(全路径):");
    lblxml.setFont(new Font("宋体", Font.PLAIN, 18));
    lblxml.setBounds(10, 218, 344, 43);
    step1.add(lblxml);

    filePath = new JTextField();
    // 默认使用当前路径
    String path = GenXml.class.getResource("/").getPath();
    if (path.startsWith("/")) {
      path = path.substring(1);
    }
    filePath.setText(path);
    filePath.setForeground(Color.BLACK);
    filePath.setFont(new Font("宋体", Font.BOLD, 20));
    filePath.setColumns(10);
    filePath.setBackground(Color.WHITE);
    filePath.setBounds(10, 271, 636, 52);
    step1.add(filePath);

    step2 = new JPanel();
    step2.setBackground(Color.LIGHT_GRAY);
    step2.setBorder(new LineBorder(new Color(0, 0, 0)));
    pane.add(step2, "name_287788958231594");
    step2.setLayout(new BorderLayout(0, 0));

    JScrollPane scrollPane = new JScrollPane();
    step2.add(scrollPane);

    table = new JTable();
    table.setRowHeight(30);
    table.setAutoCreateRowSorter(true);
    table.setDragEnabled(true);
    table.setFont(new Font("宋体", Font.PLAIN, 18));
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setForeground(Color.BLACK);
    table.setBackground(Color.WHITE);
    table.setModel(
        new DefaultTableModel(
            new Object[][] {},
            new String[] {"\u5B57\u6BB5\u540D", "\u7C7B\u578B", "\u5217\u540D"}));
    table.getColumnModel().getColumn(0).setPreferredWidth(120);
    table.getColumnModel().getColumn(1).setPreferredWidth(200);
    table.getColumnModel().getColumn(2).setPreferredWidth(120);
    scrollPane.setViewportView(table);

    panel_1 = new JPanel();
    panel_1.setPreferredSize(new Dimension(10, 40));
    step2.add(panel_1, BorderLayout.NORTH);
    panel_1.setLayout(null);

    label_1 = new JLabel("需要显示的属性:");
    label_1.setBounds(10, 10, 157, 22);
    panel_1.add(label_1);

    panel_2 = new JPanel();
    panel_2.setPreferredSize(new Dimension(100, 10));
    step2.add(panel_2, BorderLayout.EAST);
    panel_2.setLayout(null);

    reset = new JButton("重置");
    reset.setBounds(3, 0, 93, 25);
    panel_2.add(reset);

    mvT = new JButton("向上");
    mvT.setBounds(3, 30, 93, 25);
    panel_2.add(mvT);

    mvD = new JButton("向下");
    mvD.setBounds(3, 60, 93, 25);
    panel_2.add(mvD);

    delBtn = new JButton("删除");
    delBtn.setBounds(3, 90, 93, 25);
    panel_2.add(delBtn);
    delBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // 删除选中列
            DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
            int row = table.getSelectedRow();
            if (row > -1) {
              tableModel.removeRow(row);
              if (row < table.getRowCount()) {
                table.getSelectionModel().setSelectionInterval(row, row);
              } else if (row > 1) {
                table.getSelectionModel().setSelectionInterval(row, row);
              }
            }
          }
        });
    mvD.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // 移动选中列
            DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
            int row = table.getSelectedRow();
            if (row < table.getRowCount()) {
              tableModel.moveRow(row, row, ++row);
              table.getSelectionModel().setSelectionInterval(row, row);
            }
          }
        });
    mvT.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // 移动选中列
            DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
            int row = table.getSelectedRow();
            if (row > 0) {
              tableModel.moveRow(row, row, --row);
              table.getSelectionModel().setSelectionInterval(row, row);
            }
          }
        });
    reset.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ReadInTable(classPath.getText());
          }
        });

    step3 = new JPanel();
    step3.setBackground(Color.LIGHT_GRAY);
    step3.setBorder(new LineBorder(new Color(0, 0, 0)));
    pane.add(step3, "name_287798491067114");
    step3.setLayout(new BorderLayout(0, 0));

    JPanel panel = new JPanel();
    panel.setBackground(Color.LIGHT_GRAY);
    panel.setBorder(new LineBorder(new Color(0, 0, 0)));
    step3.add(panel);
    panel.setLayout(null);

    lblsheet = new JLabel("sheet序号:");
    lblsheet.setBounds(106, 226, 99, 15);
    panel.add(lblsheet);

    label_3 = new JLabel("开始行号:");
    label_3.setBounds(106, 291, 99, 24);
    panel.add(label_3);

    lblSheet = new JLabel("sheet名称:");
    lblSheet.setBounds(106, 261, 99, 15);
    panel.add(lblSheet);

    label_4 = new JLabel("是否缓存:");
    label_4.setBounds(106, 191, 99, 15);
    panel.add(label_4);

    cache = new JCheckBox("选中为缓存(不选为不缓存)");
    cache.setSelected(true);
    cache.setBounds(215, 184, 312, 30);
    panel.add(cache);

    sheet = new JTextField();
    sheet.setText("Sheet0");
    sheet.setColumns(10);
    sheet.setBounds(215, 254, 312, 30);
    panel.add(sheet);

    sheetNum = new JTextField();
    sheetNum.setHorizontalAlignment(SwingConstants.CENTER);
    sheetNum.setBackground(Color.DARK_GRAY);
    sheetNum.setForeground(Color.WHITE);
    sheetNum.setEnabled(false);
    sheetNum.setBounds(461, 219, 66, 30);
    panel.add(sheetNum);
    sheetNum.setColumns(10);

    startRow = new JTextField();
    startRow.setHorizontalAlignment(SwingConstants.CENTER);
    startRow.setForeground(Color.WHITE);
    startRow.setBackground(Color.DARK_GRAY);
    startRow.setEnabled(false);
    startRow.setColumns(10);
    startRow.setBounds(461, 289, 66, 30);
    panel.add(startRow);

    sliderRow = new JSlider();
    sliderRow.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            startRow.setText("" + sliderRow.getValue());
          }
        });
    sliderRow.setMaximum(10);
    sliderRow.setValue(0);
    sliderRow.setBounds(215, 289, 240, 30);
    panel.add(sliderRow);

    sliderSheet = new JSlider();
    sliderSheet.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            sheetNum.setText("" + sliderSheet.getValue());
          }
        });
    sliderSheet.setValue(0);
    sliderSheet.setMaximum(10);
    sliderSheet.setBounds(215, 219, 240, 30);
    panel.add(sliderSheet);

    label_2 = new JLabel("           基本信息:");
    label_2.setPreferredSize(new Dimension(60, 35));
    step3.add(label_2, BorderLayout.NORTH);
  }
示例#12
0
  public JComponent createComponentImpl() {
    final JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
    mainPanel.setPreferredSize(new Dimension(-1, 200));
    final DefaultTableModel tableModel = createModel();
    myTable = new Table(tableModel);
    myTable.setIntercellSpacing(new Dimension(0, 0));
    myTable.setDefaultRenderer(TableItem.class, new MyRenderer());
    myTable.setShowGrid(false);
    myTable.setDragEnabled(false);
    myTable.setShowHorizontalLines(false);
    myTable.setShowVerticalLines(false);
    myTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    myAddPathButton = new JButton(ProjectBundle.message("module.javadoc.add.path.button"));
    myAddPathButton.addActionListener(new AddPathActionListener());

    myRemoveButton = new JButton(ProjectBundle.message("module.javadoc.remove.button"));
    myRemoveButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            final List removedItems = TableUtil.removeSelectedItems(myTable);
            if (removedItems.size() > 0) {
              saveData();
            }
          }
        });

    final JPanel panel = new JPanel(new GridBagLayout());
    panel.add(
        myAddPathButton,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 6, 0, 0),
            0,
            0));
    panel.add(
        myRemoveButton,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL,
            new Insets(6, 6, 0, 0),
            0,
            0));

    mainPanel.add(ScrollPaneFactory.createScrollPane(myTable), BorderLayout.CENTER);
    mainPanel.add(panel, BorderLayout.EAST);
    final PanelWithText panelWithText =
        new PanelWithText(ProjectBundle.message("project.roots.external.annotations.description"));
    panelWithText.setBorder(null);
    mainPanel.add(panelWithText, BorderLayout.NORTH);

    myTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                if (e.getValueIsAdjusting()) {
                  return;
                }
                final int selectedIndex = myTable.getSelectedRow();
                myRemoveButton.setEnabled(selectedIndex >= 0);
              }
            });
    if (tableModel.getRowCount() > 0) {
      TableUtil.selectRows(myTable, new int[] {0});
    } else {
      myRemoveButton.setEnabled(false);
    }
    return mainPanel;
  }
示例#13
0
  public DefaultDnDSupport() {
    JFrame fen = new JFrame("DnD et CCP");
    fen.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER));
    fen.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Panel gauche
    JPanel panelgauche = new JPanel();
    panelgauche.setLayout(new BoxLayout(panelgauche, BoxLayout.Y_AXIS));

    // JTextField
    JTextField textField = new JTextField(10);
    textField.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JTextField"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    textField.setDragEnabled(true);

    // JPasswordField
    JPasswordField passwordField = new JPasswordField(10);
    passwordField.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JPasswordField"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    passwordField.setDragEnabled(true);

    // JFormattedTextField
    JFormattedTextField ftf = new JFormattedTextField("Universite de Lille 1");
    ftf.setFont(new Font("Courier", Font.ITALIC, 12));
    ftf.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JFormattedTextField"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    ftf.setDragEnabled(true);

    // JTextArea
    JTextArea jta = new JTextArea("Master 1 informatique");
    jta.setFont(new Font("Arial", Font.BOLD, 12));
    jta.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JTextArea"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    jta.setDragEnabled(true);

    // JEditorPane
    JEditorPane editorPane = createEditorPane();
    editorPane.setDragEnabled(true);
    JScrollPane editorScrollPane = new JScrollPane(editorPane);
    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPane.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JEditorPane"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // JColorChooser
    JColorChooser cc = new JColorChooser();
    cc.setDragEnabled(true);
    cc.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JColorChooser"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Panel droit
    JPanel paneldroit = new JPanel();
    paneldroit.setLayout(new BoxLayout(paneldroit, BoxLayout.Y_AXIS));

    // JList
    String[] data = {
      "AAC", "AEV", "ANG", "ASE", "COA", "PJE", "CAR", "PJI", "AeA", "BDA", "CALP", "FDD", "HECI",
      "IHM", "M3DS", "PAC", "PPD", "RdF", "SVL", "TI"
    };
    JList liste = new JList(data);
    JScrollPane jscrollListe = new JScrollPane(liste);
    jscrollListe.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JList"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    // liste.setDragEnabled(true);

    // JTree
    DefaultMutableTreeNode m1 = new DefaultMutableTreeNode("M1");
    DefaultMutableTreeNode s1 = new DefaultMutableTreeNode("S1");
    m1.add(s1);
    s1.add(new DefaultMutableTreeNode("AAC"));
    s1.add(new DefaultMutableTreeNode("AEV"));
    s1.add(new DefaultMutableTreeNode("ANG"));
    s1.add(new DefaultMutableTreeNode("ASE"));
    s1.add(new DefaultMutableTreeNode("COA"));
    s1.add(new DefaultMutableTreeNode("PJE"));
    DefaultMutableTreeNode s2 = new DefaultMutableTreeNode("S2");
    m1.add(s2);
    s2.add(new DefaultMutableTreeNode("CAR"));
    s2.add(new DefaultMutableTreeNode("PJI"));
    s2.add(new DefaultMutableTreeNode("AeA"));
    s2.add(new DefaultMutableTreeNode("BDA"));
    s2.add(new DefaultMutableTreeNode("CALP"));
    s2.add(new DefaultMutableTreeNode("FDD"));
    s2.add(new DefaultMutableTreeNode("HECI"));
    s2.add(new DefaultMutableTreeNode("IHM"));
    s2.add(new DefaultMutableTreeNode("M3DS"));
    s2.add(new DefaultMutableTreeNode("PAC"));
    s2.add(new DefaultMutableTreeNode("PPD"));
    s2.add(new DefaultMutableTreeNode("RdF"));
    s2.add(new DefaultMutableTreeNode("SVL"));
    s2.add(new DefaultMutableTreeNode("TI"));
    JTree tree = new JTree(m1);
    // tree.setDragEnabled(true);
    JScrollPane jscrollTree = new JScrollPane(tree);
    jscrollTree.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JTree"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    jscrollTree.setPreferredSize(new Dimension(200, 200));

    // JTable
    String[] columnNames = {"S1", "S2"};
    Object[][] data2 = {
      {"AAC", "CAR"},
      {"AEV", "PJI"},
      {"ANG", "AeA"},
      {"ASE", "BDA"},
      {"COA", "CALP"},
      {"PJE", "FDD"},
      {"", "HECI"},
      {"", "IHM"},
      {"", "M3DS"},
      {"", "PAC"},
      {"", "PPD"},
      {"", "RdF"},
      {"", "SVL"},
      {"", "TI"}
    };

    JTable table = new JTable(data2, columnNames);
    JScrollPane scrollPaneTable = new JScrollPane(table);
    table.setDragEnabled(true);

    // JFileChooser
    JFileChooser fc = new JFileChooser();
    fc.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JFileChooser"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    fc.setDragEnabled(true);

    panelgauche.add(textField);
    panelgauche.add(passwordField);
    panelgauche.add(ftf);
    panelgauche.add(jta);
    panelgauche.add(cc);
    panelgauche.add(editorScrollPane);
    fen.getContentPane().add(panelgauche);

    paneldroit.add(fc);
    paneldroit.add(jscrollListe);
    paneldroit.add(jscrollTree);
    paneldroit.add(scrollPaneTable);

    fen.getContentPane().add(paneldroit);

    fen.pack();
    fen.setVisible(true);
  }