예제 #1
0
  // </editor-fold>
  private void fillTable(JTable resultTable) {
    String col[] = {"ID", "Clave", "Nombre", "Estatus"};

    tableModel =
        new DefaultTableModel(col, 0) {
          @Override
          public boolean isCellEditable(int rowIndex, int mColIndex) {
            return false;
          }
        };

    // The 0 argument is number rows.

    resultList
        .stream()
        .forEach(
            (next) -> {
              tableModel.addRow(
                  new Object[] {
                    next.getProId(), next.getProCode(), next.getProName(), next.getProStatus()
                  });
            });

    resultTable.setModel(tableModel);
    resultTable.getColumn("ID").setMinWidth(0);
    resultTable.getColumn("ID").setMaxWidth(0);
    resultTable.setColumnSelectionAllowed(false);
    resultTable.setCellSelectionEnabled(false);
    resultTable.setRowSelectionAllowed(true);
    resultTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  }
예제 #2
0
  private void init(final EncodeTableModel model) {
    setModal(true);
    setTitle("Encode Production Data");

    table.setAutoCreateRowSorter(true);
    table.setModel(model);
    table.setRowSorter(model.getSorter());
    try {
      rowCountLabel.setText(numberFormatter.valueToString(table.getRowCount()) + " rows");
    } catch (ParseException e) {

    }

    table.setRowSelectionAllowed(false);
    table.setColumnSelectionAllowed(false);

    filterTextField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              public void changedUpdate(DocumentEvent e) {
                updateFilter();
              }

              public void insertUpdate(DocumentEvent e) {
                updateFilter();
              }

              public void removeUpdate(DocumentEvent e) {
                updateFilter();
              }
            });
  }
  /**
   * Constructor de la clase, crea la tabla y de da todas las propiedades para mostrarla en la
   * aplicacion.
   */
  public PanelHojaCalculo() {
    modelo = new ModeloTabla();
    columnasTabla = new ModeloColumnasTabla();
    tabla = new JTable(modelo, columnasTabla);
    tablaAux = new JTable(modelo, filasTabla);

    tabla.createDefaultColumnsFromModel();
    tablaAux.createDefaultColumnsFromModel();

    tabla.setColumnSelectionAllowed(true);
    tabla.setRowSelectionAllowed(true);

    tablaAux.setSelectionModel(tabla.getSelectionModel());
    tablaAux.setMaximumSize(new Dimension(40, 10000));
    tablaAux.setBackground(new Color(238, 238, 238));
    // Se puede pasar a true si se quiere seleccionar las filas
    tablaAux.setEnabled(false);
    tablaAux.setColumnSelectionAllowed(false);
    tablaAux.setCellSelectionEnabled(false);

    viewPort = new JViewport();
    viewPort.setView(tablaAux);
    viewPort.setPreferredSize(tablaAux.getMaximumSize());

    tabla.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    tablaAux.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    scrollPane = new JScrollPane(tabla);
    scrollPane.setRowHeader(viewPort);
    scrollPane.setPreferredSize(new Dimension(790, 500));
    add(scrollPane);
  }
예제 #4
0
  // This handles the row, column, and cell selection buttons.
  public void actionPerformed(ActionEvent ie) {

    // See which button is selected.
    if (jrbRows.isSelected()) {
      // Enable row selection.
      jtabOrders.setColumnSelectionAllowed(false);
      jtabOrders.setRowSelectionAllowed(true);
    } else if (jrbColumns.isSelected()) {
      // Enable column selection.
      jtabOrders.setColumnSelectionAllowed(true);
      jtabOrders.setRowSelectionAllowed(false);
    } else {
      // Enable cell selection.
      jtabOrders.setCellSelectionEnabled(true);
    }
  }
  public CustomLeagueTable(String teamAmount) {

    model = new DefaultTableModel();
    table =
        new JTable(model) {
          @Override
          public boolean isCellEditable(int row, int column) {
            return true;
          }
        };
    model.setColumnIdentifiers(
        new String[] {
          "Team Name", "Points", "Goal Diff", "Wins", "Loses", "Draws", "Played", "League Verdict"
        });
    model.setRowCount(Integer.parseInt(teamAmount));

    JScrollPane pane =
        new JScrollPane(
            table,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    pane.setPreferredSize(INITIAL_SIZE);
    setVisible(true);
    setLayout(new FlowLayout());

    table.setRowSelectionAllowed(false);

    TableColumn colTeamName = table.getColumnModel().getColumn(0);
    colTeamName.setPreferredWidth(150);

    TableColumn colVerdict = table.getColumnModel().getColumn(4);
    colVerdict.setPreferredWidth(290);

    add(pane);
  }
  public TableCellRenderFrame() {
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    TableModel model = new PlanetTableModel();
    JTable table = new JTable(model);
    table.setRowSelectionAllowed(false);

    // set up renderers and editors

    table.setDefaultRenderer(Color.class, new ColorTableCellRenderer());
    table.setDefaultEditor(Color.class, new ColorTableCellEditor());

    JComboBox<Integer> moonCombo = new JComboBox<>();
    for (int i = 0; i <= 20; i++) moonCombo.addItem(i);

    TableColumnModel columnModel = table.getColumnModel();
    TableColumn moonColumn = columnModel.getColumn(PlanetTableModel.MOONS_COLUMN);
    moonColumn.setCellEditor(new DefaultCellEditor(moonCombo));
    moonColumn.setHeaderRenderer(table.getDefaultRenderer(ImageIcon.class));
    moonColumn.setHeaderValue(new ImageIcon(getClass().getResource("Moons.gif")));

    // show table

    table.setRowHeight(100);
    add(new JScrollPane(table), BorderLayout.CENTER);
  }
예제 #7
0
  private void createandAddTable(String[][] rowData2, String[] columnNames2) {

    jtNotenAnzeige =
        new JTable(rowData2, columnNames2) {

          private static final long serialVersionUID = 1L;

          public boolean isCellEditable(int row, int column) {
            // set table column uneditable
            return false;
          }
        };
    jtNotenAnzeige.setRowSelectionAllowed(false);
    jtNotenAnzeige.getTableHeader().setReorderingAllowed(false);

    // / scrollPane removen weil dann tabelle !
    if (scrollPane != null) {
      tablePanel.remove(scrollPane);
    }

    scrollPane = new JScrollPane(jtNotenAnzeige);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBounds(10, 21, 525, 261);
    tablePanel.add(scrollPane);
  }
예제 #8
0
  /**
   * This method initializes jTableTitular
   *
   * @return javax.swing.JTable
   */
  private JTable getJTableTitular() {
    if (jTableTitular == null) {
      jTableTitular = new JTable();

      tablepersonamodel = new TablePersonaModel();

      TableSorted tblSorted = new TableSorted(tablepersonamodel);
      tblSorted.setTableHeader(jTableTitular.getTableHeader());
      jTableTitular.setModel(tblSorted);
      jTableTitular.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      jTableTitular.setCellSelectionEnabled(false);
      jTableTitular.setColumnSelectionAllowed(false);
      jTableTitular.setRowSelectionAllowed(true);
      jTableTitular.getTableHeader().setReorderingAllowed(false);

      ArrayList lst = new ArrayList();
      lst.add(new Persona());
      ((TablePersonaModel) ((TableSorted) jTableTitular.getModel()).getTableModel()).setData(lst);

      /*
      EdicionOperations oper = new EdicionOperations();
      try
      {
          ArrayList lstVias = oper.obtenerViasCatastro();
          ((TableViasCatastroModel)((TableSorted)jTableViasCatastro.getModel()).getTableModel()).setData(lstVias);

      } catch (DataException e1)
      {
          e1.printStackTrace();
      }
      */
    }
    return jTableTitular;
  }
예제 #9
0
  private void createAndMarkAndAddTable(String[][] rowData2, String[] columnNames2) {

    jtNotenAnzeige =
        new JTable(rowData2, columnNames2) {

          private static final long serialVersionUID = 1L;

          public boolean isCellEditable(int row, int column) {
            return true;
          }
        };

    jtNotenAnzeige.setRowSelectionAllowed(false);
    jtNotenAnzeige.getTableHeader().setReorderingAllowed(false);
    jtNotenAnzeige.setDefaultRenderer(Object.class, new ColorTableCellRenderer());

    if (scrollPane != null) {
      tablePanel.remove(scrollPane);
    }

    scrollPane = new JScrollPane(jtNotenAnzeige);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBounds(10, 21, 525, 261);
    tablePanel.add(scrollPane);
  }
예제 #10
0
  private JTable createTabla(DefaultTableModel tableModel) {
    JTable table = new JTable();
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setCellSelectionEnabled(false);
    table.setColumnSelectionAllowed(false);
    table.setModel(tableModel);
    table.setRowSelectionAllowed(true);

    table.getColumnModel().getColumn(0).setResizable(false);
    table.getColumnModel().getColumn(0).setPreferredWidth(75);
    table.getColumnModel().getColumn(0).setMinWidth(75);
    table.getColumnModel().getColumn(0).setMaxWidth(75);
    table.getColumnModel().getColumn(1).setResizable(false);
    table.getColumnModel().getColumn(1).setPreferredWidth(125);
    table.getColumnModel().getColumn(1).setMinWidth(125);
    table.getColumnModel().getColumn(1).setMaxWidth(125);
    table.getColumnModel().getColumn(2).setPreferredWidth(50);
    table.getColumnModel().getColumn(2).setMinWidth(50);
    table.getColumnModel().getColumn(2).setMaxWidth(50);
    table.getColumnModel().getColumn(3).setPreferredWidth(85);
    table.getColumnModel().getColumn(3).setMinWidth(85);
    table.getColumnModel().getColumn(3).setMaxWidth(85);
    table.setBounds(10, 420, 350, 125);
    return table;
  }
예제 #11
0
  /**
   * Default constructor/Create the frame of kick player window
   *
   * @param lobby the given lobby associated with the frame
   * @param table the table the player current on
   */
  public KickPlayerWindow(final ILobby lobby, final Table table) {
    this.setResizable(false);
    this.isAlwaysOnTop();
    List<Player> playerList = table.getPlayers();
    // get to delete the moderator from the list to make sure
    // the moderator doesn't kick himself
    playerList.remove(table.getModerator());
    playerTable = new JTable();
    players = new HashMap<Integer, Player>();
    setTitle("Kick player");
    setBounds(100, 100, 400, 300);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JScrollPane scrollPane = new JScrollPane(playerTable);
    scrollPane.setBounds(10, 10, 363, 200);
    contentPane.add(scrollPane, BorderLayout.CENTER);

    model = new DefaultTableModel();
    model.addColumn("ID");
    model.addColumn("Display Name");
    model.addColumn("Rating");
    playerTable.setModel(model);
    playerTable.setColumnSelectionAllowed(false);
    playerTable.setRowSelectionAllowed(true);

    JTableHeader header = playerTable.getTableHeader();
    header.setFont(new Font(header.getFont().getFontName(), Font.BOLD, header.getFont().getSize()));
    updatePlayers(playerList);

    JButton btnCancel = new JButton("Cancel");
    btnCancel.setBounds(280, 228, 89, 23);
    contentPane.add(btnCancel);
    btnCancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent evt) {
            dispose();
          }
        });

    JButton btnKick = new JButton("Kick");
    btnKick.setBounds(180, 228, 89, 23);
    contentPane.add(btnKick);
    btnKick.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent evt) {
            for (Integer row : playerTable.getSelectedRows()) {
              Player selected = players.get(model.getValueAt(row, 0));
              new LeaveRequest(table, selected).send(lobby);
            }
            dispose();
          }
        });
  }
예제 #12
0
  protected void addWidgets(DescriptorQueryList list, ActionMap actions, boolean captionsOnly) {
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createTitledBorder(caption));
    setBackground(AmbitColors.BrightClr);
    setForeground(AmbitColors.DarkClr);

    tableModel = new DescriptorQueryTableModel(list, captionsOnly);
    JTable table = new JTable(tableModel, createTableColumnModel(tableModel, captionsOnly));
    table.setSurrendersFocusOnKeystroke(true);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setRowSelectionAllowed(false);
    table.getTableHeader().setReorderingAllowed(false);
    table.setRowHeight(24);

    TableColumn col;

    int[] pSize = {32, 240, 32, 32, 64, 32, 32, 32};
    int[] mSize = {24, 120, 32, 32, 64, 32, 32, 32};
    for (int i = 0; i < table.getColumnCount(); i++) {
      col = table.getColumnModel().getColumn(i);
      col.setPreferredWidth(pSize[i]);
      col.setMinWidth(mSize[i]);
    }
    // table.setShowGrid(false);
    table.setShowHorizontalLines(true);
    table.setShowVerticalLines(false);

    scrollPane = new JScrollPane(table);
    scrollPane.setPreferredSize(new Dimension(420, 360));
    scrollPane.setMinimumSize(new Dimension(370, 120));
    scrollPane.setAutoscrolls(true);

    // tPane.addTab("Search descriptors",scrollPane);
    add(scrollPane, BorderLayout.CENTER);
    /*
    JToolBar t = new JToolBar();
    //t.setBackground(Color.white);
    t.setFloatable(false);
    //t.setBorder(BorderFactory.createTitledBorder("Search by descriptors and distance between atoms"));
    Object[] keys = actions.allKeys();
    if (keys != null) {
     for (int i=0; i < keys.length;i++)
     	t.add(actions.get(keys[i]));
     add(t,BorderLayout.SOUTH);
    }
    */
    if (actions != null) {
      Object[] keys = actions.allKeys();
      if (keys != null) {
        for (int i = 0; i < keys.length; i++) {
          add(
              new DescriptorSearchActionPanel(list, actions.get(keys[i]), keys[i].toString()),
              BorderLayout.SOUTH);
          break;
        }
      }
    }
  }
예제 #13
0
 /**
  * Return the table.
  *
  * @return JTable
  */
 protected JTable getTable() {
   if (table == null) {
     table = new JTable();
     table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
     table.setColumnSelectionAllowed(true);
     table.setRowSelectionAllowed(true);
     table.getTableHeader().setReorderingAllowed(false);
   }
   return table;
 }
예제 #14
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();
 }
예제 #15
0
  public void createviewPanel() {

    viewPanel = new JPanel();
    viewPanel.setLayout(new BorderLayout());
    // viewPanel.setPreferredSize( new Dimension(500,500 ));
    // viewPanel.setMinimumSize( new Dimension(100,50));
    // viewPanel.add( new JLabel("Notes:"),BorderLayout.NORTH );
    //		viewPanel.add( new JTextArea(), BorderLayout.CENTER );
    viewPanel.setPreferredSize(new Dimension(200, 520));
    viewPanel.setMinimumSize(new Dimension(100, 100));
    // Create columns
    CreateColumns(colcnt);
    CreateData(rowcnt, colcnt);
    setSize(300, 200);

    table =
        new JTable(dataValues, columnNames) {

          public boolean isCellEditable(int rowIndex, int vColIndex) {
            return false;
          }
        };

    table
        .getModel()
        .addTableModelListener(
            new TableModelListener() {

              public void tableChanged(TableModelEvent e) {
                System.out.println("........" + e);
              }
            });
    // table.setValueAt("1,2",0,0);

    System.out.println("Row   :" + rowcnt);
    System.out.println("Col  :" + colcnt);

    // Configure some of JTable's paramters
    table.setShowHorizontalLines(false);
    table.setShowVerticalLines(false);
    table.setRowSelectionAllowed(false);
    table.setColumnSelectionAllowed(false);

    // Change the selection colour
    table.setSelectionForeground(Color.white);
    table.setSelectionBackground(Color.red);

    // Add the table to a scrolling pane
    scrollPaneTable = JTable.createScrollPaneForTable(table);
    viewPanel.add(scrollPaneTable, BorderLayout.CENTER);
    viewPanel.add(table, BorderLayout.CENTER);
  }
예제 #16
0
  /**
   * Creates a panel to display the meta-server.
   *
   * @param freeColClient The <code>FreeColClient</code> for the game.
   * @param connectController The controller responsible for creating new connections.
   */
  public ServerListPanel(FreeColClient freeColClient, ConnectController connectController) {
    super(freeColClient, new MigLayout("", "", ""));

    this.connectController = connectController;

    JButton cancel = new JButton("Cancel");
    JScrollPane tableScroll;

    setCancelComponent(cancel);

    connect = new JButton(Messages.message("connect"));

    tableModel = new ServerListTableModel(new ArrayList<ServerInfo>());
    table = new JTable(tableModel);

    DefaultTableCellRenderer dtcr =
        new DefaultTableCellRenderer() {
          public Component getTableCellRendererComponent(
              JTable t, Object o, boolean isSelected, boolean hasFocus, int row, int column) {
            setOpaque(isSelected);
            return super.getTableCellRendererComponent(t, o, isSelected, hasFocus, row, column);
          }
        };
    for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) {
      table.getColumnModel().getColumn(i).setCellRenderer(dtcr);
    }

    table.setRowHeight(22);

    table.setCellSelectionEnabled(false);
    table.setRowSelectionAllowed(true);
    table.setColumnSelectionAllowed(false);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    tableScroll = new JScrollPane(table);
    table.addNotify();
    tableScroll.getViewport().setOpaque(false);
    tableScroll.getColumnHeader().setOpaque(false);

    connect.setActionCommand(String.valueOf(CONNECT));
    connect.addActionListener(this);

    cancel.setActionCommand(String.valueOf(CANCEL));
    cancel.addActionListener(this);

    add(tableScroll, "width 400:, height 350:");
    add(connect, "newline 20, split 2");
    add(cancel, "tag cancel");

    setSize(getPreferredSize());
  }
예제 #17
0
  /**
   * Inicializa la tabla que se utiliza para mostrar los resultados de la bsqueda
   *
   * @return
   */
  public JTable getJTable() {
    if (jTable == null) {
      // TODO: Poner los titulos de las columnas correspondientes
      String[] columnNames = {
        PluginServices.getText(this, "codigo"),
        PluginServices.getText(this, "nombre"),
        PluginServices.getText(this, "projected"),
        PluginServices.getText(this, "datum")
      };
      Object[][] data = {};
      dtm =
          new DefaultTableModel(data, columnNames) {
            private static final long serialVersionUID = 1L;

            public boolean isCellEditable(int row, int column) {
              return false;
            }
            /*
             * metodo necesario para cuando utilizamos tablas ordenadas
             * ya que sino al ordenar por algun campo no se queda con el orden
             * actual al seleccionar una fila (non-Javadoc)
             * @see javax.swing.table.TableModel#getColumnClass(int)
             */
            public Class getColumnClass(int column) {
              return getValueAt(0, column).getClass();
            }
          };
      sorter = new TableSorter(dtm);

      jTable = new JTable(sorter);
      sorter.setTableHeader(jTable.getTableHeader());
      jTable.setCellSelectionEnabled(false);
      jTable.setRowSelectionAllowed(true);
      jTable.setColumnSelectionAllowed(false);
      jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      TableColumn column = null;
      for (int i = 0; i < columnNames.length; i++) {
        column = jTable.getColumnModel().getColumn(i);
        if (i == 0) {
          column.setPreferredWidth(80); // code column is shorter
        } else if (i == 2) {
          column.setPreferredWidth(50);
        } else {
          column.setPreferredWidth(175);
        }
      }
      initializeTable();
    }

    return jTable;
  }
예제 #18
0
  private void jbInit() {
    Vector<Object> data = new Vector<Object>();

    tableModel =
        new BaseTableModel(
            data, new Vector<String>(Arrays.asList(new String[] {"COL_A", "COL_B", "COL_C"})));
    table = new JTable(tableModel);
    table.setRowSelectionAllowed(false);
    table.setColumnSelectionAllowed(false);
    this.setLayout(new BorderLayout());
    this.add(table, BorderLayout.CENTER);
    table.getTableHeader().getColumnModel().getColumn(1).setMaxWidth(30);
    table.getTableHeader().getColumnModel().getColumn(2).setMaxWidth(30);
  }
예제 #19
0
  public TableFeedBody() {
    this.setOrientation(JSplitPane.VERTICAL_SPLIT);
    this.setOneTouchExpandable(false);
    this.setContinuousLayout(true);
    // the top component (the list) takes the extra space
    this.setResizeWeight(1);

    JScrollPane scroll = new JScrollPane();
    feedTable = new JTable();
    feedTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    feedTable.setRowSelectionAllowed(true);
    feedTable.changeSelection(0, 0, false, false);
    feedTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    feedTable.addMouseListener(this);
    feedTable.setRowHeight(25);
    feedTable.addKeyListener(this);
    scroll.setViewportView(feedTable);

    this.setTopComponent(scroll);

    feedItemDetail = new JEditorPane();
    feedItemDetail.setContentType("text/html");
    feedItemDetail.addHyperlinkListener(this);
    feedItemDetail.setBackground(Color.WHITE);
    feedItemDetail.setEditable(false);
    HTMLEditorKit kit = (HTMLEditorKit) feedItemDetail.getEditorKit();
    StyleSheet sheet = kit.getStyleSheet();
    Font font = UIManager.getFont("Label.font");
    sheet.addRule(
        "body {font-family: " + font.getFamily() + "; font-size: " + font.getSize() + "pt;}");

    JScrollPane detailScroll = new JScrollPane();
    Dimension minDetailSize = detailScroll.getMinimumSize();
    minDetailSize.height = 100;
    detailScroll.setMinimumSize(minDetailSize);
    Dimension prefDetailSize = detailScroll.getPreferredSize();
    prefDetailSize.height = 200;
    detailScroll.setPreferredSize(prefDetailSize);
    detailScroll.setViewportView(feedItemDetail);

    this.setBottomComponent(detailScroll);

    this.setDividerSize(2);
    this.setDividerLocation(-1);
  }
예제 #20
0
  /**
   * Constructs a Panel with a line-number, breakpoint, source-text
   *
   * @param dataComm the datacomm object for interaction with the ToolBus
   * @param scriptName the name of the script that is used by the ToolBus
   * @param source the source of an toolbus file
   */
  public SourceFilePanel(DataComm dataComm, String scriptName, String source) {
    super();

    m_dataComm = dataComm;
    setLayout(new BorderLayout());
    m_scriptName = scriptName;
    m_sourceModel = new SourceFileTableModel(source);
    m_sourceCode = new JTable(m_sourceModel);
    m_sourceCode.setSelectionBackground(SELECTED_ROW_COLOR);
    m_sourceCode.setSelectionForeground(Color.BLACK);
    m_sourceCode.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // to set the background color back to default
    m_sourceCode.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            if (e.getClickCount() == MouseEvent.BUTTON1) {
              m_sourceCode.setSelectionBackground(SELECTED_ROW_COLOR);
            }
          }
        });

    m_sourceCode.getModel().addTableModelListener(this);
    m_sourceCode.setShowGrid(false);
    m_sourceCode.setColumnSelectionAllowed(false);
    m_sourceCode.setRowSelectionAllowed(true);

    m_sourceCode.getColumnModel().getColumn(0).setCellRenderer(new CheckBoxCellRenderer());
    m_sourceCode.getColumnModel().getColumn(0).setCellEditor(new CheckBoxCellRenderer());

    TableColumn firstColumn = m_sourceCode.getColumnModel().getColumn(FIRST_COLUMN_INDEX);
    firstColumn.setMaxWidth(FIRST_COLUMN_WIDTH);

    TableColumn secondColumn = m_sourceCode.getColumnModel().getColumn(SECOND_COLUMN_INDEX);
    DefaultTableCellRenderer tcrColumn = new DefaultTableCellRenderer();
    tcrColumn.setHorizontalAlignment(SwingConstants.LEFT);
    secondColumn.setCellRenderer(tcrColumn);
    secondColumn.setMaxWidth(SECOND_COLUMN_WIDTH);

    JScrollPane sourceScrollPane = new JScrollPane(m_sourceCode);
    sourceScrollPane.getViewport().setBackground(Color.WHITE);
    add(sourceScrollPane, BorderLayout.CENTER);
    setVisible(true);
  }
예제 #21
0
  /*
   * Returns a JTable which displays information from all
   * .xml files in the Children/ directory.
   */
  private JTable employeeTable() {
    model = new DefaultTableModel(employeeData(), employeeColumnNames); // Rows, Columns
    table =
        new JTable(model) {
          private static final long serialVersionUID = 1L;

          @Override
          public Component prepareRenderer(
              TableCellRenderer renderer, int rowIndex, int vColIndex) {
            Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
            if (rowIndex % 2 == 0 && !isCellSelected(rowIndex, vColIndex)) {
              c.setBackground(new Color(220, 220, 220));
            } else {
              // If not shaded, match the table's background
              c.setBackground(getBackground());
            }
            return c;
          }
        };
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    TableColumn header;
    for (int i = 0; i < employeeColumnNames.length; i++) {
      header = table.getColumnModel().getColumn(i);
      header.setPreferredWidth(150);
    }

    /*
     * The column index on the table that we want to change
     */
    int[] column = {2, 4, 5, 8, 9, 11};
    /*
     * The new width that we want to set the column to be
     */
    int[] cwidth = {25, 60, 100, 50, 60, 65}; // width to set the column

    for (int i = 0; i < column.length; i++) {
      header = table.getColumnModel().getColumn(column[i]);
      header.setPreferredWidth(cwidth[i]);
    }

    table.setRowSelectionAllowed(true);
    return table;
  }
  /** build the form */
  public void initForm() {

    this.setLayout(new BorderLayout());
    // and the table
    _myTableModel = new javax.swing.table.DefaultTableModel();
    _myTable = new JTable(_myTableModel);

    // format the table
    _myTable.setAutoCreateColumnsFromModel(true);
    _myTable.setRowSelectionAllowed(false);
    _myTable.setColumnSelectionAllowed(false);

    _myTable.setMinimumSize(new Dimension(200, 400));

    // and store the table
    this.add(_myTable, BorderLayout.CENTER);

    // sort out the table header
    this.add(_myTable.getTableHeader(), BorderLayout.NORTH);
  }
예제 #23
0
  /**
   * This method initializes jTableBienInmueble
   *
   * @return javax.swing.JTable
   */
  private JTable getJTableBienInmueble() {
    if (jTableBienInmueble == null) {
      jTableBienInmueble = new JTable();

      tablebimodel = new TableBienInmuebleCatastroModel();

      TableSorted tblSorted = new TableSorted(tablebimodel);
      tblSorted.setTableHeader(jTableBienInmueble.getTableHeader());
      jTableBienInmueble.setModel(tblSorted);
      jTableBienInmueble.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      jTableBienInmueble.setCellSelectionEnabled(false);
      jTableBienInmueble.setColumnSelectionAllowed(false);
      jTableBienInmueble.setRowSelectionAllowed(true);
      jTableBienInmueble.getTableHeader().setReorderingAllowed(false);

      ArrayList lst = new ArrayList();
      lst.add(new BienInmuebleCatastro());
      ((TableBienInmuebleCatastroModel)
              ((TableSorted) jTableBienInmueble.getModel()).getTableModel())
          .setData(lst);

      /*
      EdicionOperations oper = new EdicionOperations();


      try
      {

          ArrayList lst = oper.obtenerFincasExpediente(ex);
          ((TableBienInmuebleCatastroModel)((TableSorted)jTableBienInmueble.getModel()).
                  getTableModel()).setData(lst);


      } catch (DataException e1)
      {
          e1.printStackTrace();
      }
      */
    }
    return jTableBienInmueble;
  }
  /**
   * Inicializa todos los elementos del panel y los coloca en su posicion. Carga la tabla y le
   * asigna los modos que queremos.
   */
  private void inicializaPanel() {
    tablaRefCatasTabel = new JTable();
    identificadores = new String[6];
    modelo =
        new DefaultTableModel() {
          public boolean isCellEditable(int row, int column) {
            return false;
          }
        };
    tablaRefCatasTabel.setModel(modelo);
    tablaRefCatasTabel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tablaRefCatasTabel.setCellSelectionEnabled(false);
    tablaRefCatasTabel.setColumnSelectionAllowed(false);
    tablaRefCatasTabel.setRowSelectionAllowed(true);
    tablaScrollPanel = new JScrollPane(tablaRefCatasTabel);

    renombrarComponentes();

    this.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
    this.add(tablaScrollPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 20, 480, 270));
  }
예제 #25
0
  public LookCommodityType(ArrayList<CommodityTypeVO> type) {

    for (int t = 0; t < type.size(); t++) {
      data[t][0] = type.get(t).getFather().getName();
      ArrayList<CommodityTypeVO> child = type.get(t).getChild();
      for (int k = 0; k < child.size(); k++) {
        data[t][k + 1] = child.get(k).getName();
      }
    }

    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    table.setColumnSelectionAllowed(false);
    table.setRowSelectionAllowed(true);

    JScrollPane scroller = new JScrollPane(table);
    table.setPreferredScrollableViewportSize(new Dimension(460, 60));

    panelCommodityType.setLayout(null);
    scroller.setBounds(0, 35, 820, 500);

    panelCommodityType.add(scroller);
  }
예제 #26
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;
  }
예제 #27
0
  private void loadView() {
    // main views
    mTableModel = new SpreadsheetTableModel();

    mTableView = new JTable(mTableModel);
    mTableView.setRowSelectionAllowed(false);
    mTableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    mTableView.setFillsViewportHeight(true);
    mTableView.setDefaultRenderer(String.class, new ColorCellRenderer(TABLE_CELL_COLOR));
    mTableView.setDefaultEditor(
        String.class, new SpreadsheetCellEditor(mTableView.getDefaultEditor(String.class)));
    mTableView.getSelectionModel().addListSelectionListener(new SpreadsheetSelectionListener());
    mTableView
        .getColumnModel()
        .getSelectionModel()
        .addListSelectionListener(new SpreadsheetSelectionListener());

    JTable rowHeaderTable = new JTable(new RowHeaderTableModel());
    rowHeaderTable.setCellSelectionEnabled(false);
    rowHeaderTable.setPreferredScrollableViewportSize(new Dimension(50, Integer.MAX_VALUE));
    rowHeaderTable.setDefaultRenderer(Object.class, new ColorCellRenderer(ROW_HEADER_COLOR));

    mFormulaTextField = new BindableTextField();
    mFormulaTextField.setEditable(false);
    mFormulaTextField.setFocusable(false);

    JScrollPane scrollView = new JScrollPane(mTableView);
    scrollView.setRowHeaderView(rowHeaderTable);

    add(mFormulaTextField, BorderLayout.BEFORE_FIRST_LINE);
    add(scrollView, BorderLayout.CENTER);

    // helpers

    mFileChooser = new SingleExtensionFileChooser();
    String extension = SpreadsheetPersistenceManager.SPREADSHEET_FILE_EXTENSION;
    mFileChooser.setFileExtension(extension, "Spreadsheets file (." + extension + ")");
  }
예제 #28
0
  public ElementTableView(TableModel elementTableModel, String title, Icon icon) {
    this.target = new DummyGDE();
    this.name = title;
    this.icon = icon;

    setLayout(new BorderLayout());

    JTable table =
        new JTable(elementTableModel) {
          private static final long serialVersionUID = -2738230330859706440L;

          public boolean getScrollableTracksViewportWidth() {
            return getPreferredSize().width < getParent().getWidth();
          }
        };
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setAutoCreateRowSorter(true);
    table.setAutoscrolls(true);
    table.setCellSelectionEnabled(false);
    table.setRowSelectionAllowed(true);
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    add(new JScrollPane(table), BorderLayout.CENTER);
  }
  void tableInitialise(JTable table) {

    JScrollPane scroll;
    TableColumn column = null;

    int colunms = table.getColumnCount();
    for (int y = 0; y < colunms; y++) {
      column = table.getColumnModel().getColumn(y);
      /*将每一列的默认宽度设置为100*/
      column.setPreferredWidth(100);
    }
    /*
     * 设置JTable自动调整列表的状态,此处设置为关闭
     */
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

    table.setFont(new Font("Menu.font", Font.PLAIN, 14));
    table.getTableHeader().setFont(new Font("Menu.font", Font.BOLD, 15));
    /*用JScrollPane装载JTable,这样超出范围的列就可以通过滚动条来查看*/

    scroll = new JScrollPane(table);
    TablePanel.removeAll();

    TablePanel.setLayout(new BoxLayout(TablePanel, BoxLayout.Y_AXIS));
    TablePanel.add(scroll);

    TablePanel.revalidate();

    table.setRowSelectionAllowed(true); // 设置JTable可被选择
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // 设置JTable为单行选择
    table.getTableHeader().setBackground(new Color(206, 231, 255)); // 设置JTable表头颜色
    table.getTableHeader().setReorderingAllowed(false); // 设置JTable每个字段的顺序不可以改变
    table.getTableHeader().setResizingAllowed(false); // 设置JTable每个表头的大小不可以改变
    makeFace(table); // 设置JTable 颜色

    table.setVisible(true);
  }
예제 #30
0
 private void jbInit() throws Exception {
   panel1.setLayout(borderLayout1);
   okButton.setText("OK");
   okButton.addActionListener(new MimeTypeEditor_okButton_actionAdapter(this));
   filtersTable.setRowSelectionAllowed(true);
   filtersTable.setPreferredSize(new Dimension(418, 200));
   filtersTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
   filtersTable.setCellSelectionEnabled(true);
   filtersTable.setColumnSelectionAllowed(false);
   filtersTable.setModel(m_model);
   addButton.setToolTipText(
       "Add a new " + mimeTypeEditorBuilder.getValueName() + " for a MIME type");
   addButton.setText("Add");
   addButton.addActionListener(new MimeTypeEditor_addButton_actionAdapter(this));
   cancelButton.setText("Cancel");
   cancelButton.addActionListener(new MimeTypeEditor_cancelButton_actionAdapter(this));
   deleteButton.setToolTipText("Delete the currently selected item.");
   deleteButton.setText("Delete");
   deleteButton.addActionListener(new MimeTypeEditor_deleteButton_actionAdapter(this));
   upButton.setText("Up");
   upButton.addActionListener(new MimeTypeEditor_upButton_actionAdapter(this));
   dnButton.setText("Down");
   dnButton.addActionListener(new MimeTypeEditor_dnButton_actionAdapter(this));
   panel1.setPreferredSize(new Dimension(418, 200));
   jScrollPane1.setMinimumSize(new Dimension(200, 80));
   jScrollPane1.setOpaque(true);
   buttonPanel.add(dnButton, null);
   buttonPanel.add(upButton, null);
   buttonPanel.add(addButton, null);
   buttonPanel.add(deleteButton, null);
   buttonPanel.add(okButton, null);
   buttonPanel.add(cancelButton, null);
   getContentPane().add(panel1);
   panel1.add(buttonPanel, BorderLayout.SOUTH);
   panel1.add(jScrollPane1, BorderLayout.CENTER);
   jScrollPane1.getViewport().add(filtersTable, null);
 }