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);
  }
  private void myPostInit() {
    modelDataTypes = new HashMap<String, DataType>();
    List<DataType> dataTypes = ModelHelper.getModelDataTypes(diagramManager.getCurrentProject());
    for (DataType item : dataTypes) {
      modelDataTypes.put(item.getName(), item);
    }

    TableColumn typeColumn = table.getColumnModel().getColumn(1);
    typeColumn.setCellEditor(createEditor(modelDataTypes.keySet().toArray()));

    TableColumn typeColumn2 = table.getColumnModel().getColumn(2);
    typeColumn2.setCellEditor(createEditor(new String[] {"1", "0..1", "0..*", "1..*"}));

    table.setSurrendersFocusOnKeystroke(true);

    if (element instanceof DataType) {
      DataType dataType = (DataType) element;
      for (Property attribute : dataType.getAttribute()) {
        attributesTableModel.addEntry(attribute);
      }
    } else {
      Class umlclass = (Class) element;
      for (Property attribute : umlclass.getAttribute()) {
        attributesTableModel.addEntry(attribute);
      }
    }
  }
  @SuppressWarnings("static-access")
  public void componentesListaUsuario() {
    dados = new Vector<String>();
    dados.add("Código");
    dados.add("Nome do Serviço");
    dados.add("Valor");
    dtmListaTipoServico = new DefaultTableModel();
    dtmListaTipoServico.setColumnIdentifiers(dados);
    jttListaTipoServico = new JTable();
    jttListaTipoServico.setFont(new Font("Tahoma", Font.PLAIN, 12));
    jttListaTipoServico.setModel(dtmListaTipoServico);
    jttListaTipoServico.getColumnModel().getColumn(0).setResizable(false);
    jttListaTipoServico.getColumnModel().getColumn(0).setPreferredWidth(60);
    jttListaTipoServico.getColumnModel().getColumn(1).setResizable(false);
    jttListaTipoServico.getColumnModel().getColumn(1).setPreferredWidth(337);
    jttListaTipoServico.getColumnModel().getColumn(2).setResizable(false);
    jttListaTipoServico.getColumnModel().getColumn(2).setPreferredWidth(100);
    jspListaTipoServico = new JScrollPane(jttListaTipoServico);
    jttListaTipoServico.setAutoResizeMode(jttListaTipoServico.AUTO_RESIZE_OFF);
    jspListaTipoServico.setBounds(10, 10, 500, 300);
    jpnListaTipoServico.add(jspListaTipoServico);

    jbtSelecionarTipoServico = new JButton("Selecionar");
    jbtSelecionarTipoServico.setFont(new Font("Tahoma", Font.PLAIN, 12));
    jbtSelecionarTipoServico.setBounds(10, 338, 110, 23);
    jpnListaTipoServico.add(jbtSelecionarTipoServico);

    jbtCancelarPesquisa = new JButton("Cancelar");
    jbtCancelarPesquisa.setFont(new Font("Tahoma", Font.PLAIN, 12));
    jbtCancelarPesquisa.setBounds(130, 339, 110, 23);
    jpnListaTipoServico.add(jbtCancelarPesquisa);
  }
Exemplo n.º 4
0
  private void preecherJTable() {

    tbProdutos.getColumnModel().getColumn(0).setPreferredWidth(15);
    tbProdutos.getColumnModel().getColumn(1).setPreferredWidth(200);
    tbProdutos.getColumnModel().getColumn(2).setPreferredWidth(50);
    tbProdutos.getColumnModel().getColumn(3).setPreferredWidth(25);
    tbProdutos.getColumnModel().getColumn(4).setPreferredWidth(90);

    DefaultTableModel modelo = (DefaultTableModel) tbProdutos.getModel();
    modelo.setNumRows(0);
    int cont = 1;
    try {
      List<Itens> itens = controleOrcamento.getItens();
      for (Itens i : itens) {
        modelo.addRow(
            new Object[] {
              cont, i.getNome(), i.getQuant(), i.getValor(), (i.getQuant() * i.getValor())
            });
        ++cont;
      }
    } catch (Exception erro) {
      JOptionPane.showMessageDialog(null, "Não conseguiu carregar a tabela de clientes." + erro);
    }
    tfTotal.setText("" + controleOrcamento.getValorTotal());
  }
Exemplo n.º 5
0
  private JScrollPane legendChart(int width, int height, List<String> rows) {
    JScrollPane jcp = new JScrollPane();
    DefaultTableModel dtm =
        new DefaultTableModel(
            new Object[][] {}, new String[] {"File", "Bar", "Type Query", "Time(ms)"});
    JTable jt = new JTable();
    jt.setModel(dtm);

    for (String s : rows) {
      if (s != null) {
        String[] vals = s.split("\\|");
        dtm.addRow(new String[] {vals[0], vals[3], vals[1], vals[2]});
      }
    }
    jt.getColumnModel().getColumn(0).setPreferredWidth(200);
    jt.getColumnModel().getColumn(1).setPreferredWidth(50);
    jt.getColumnModel().getColumn(2).setPreferredWidth(50);
    jt.getColumnModel().getColumn(3).setPreferredWidth(50);
    // jt.setEnabled(false);

    jcp.setViewportView(jt);
    jcp.setPreferredSize(new Dimension(width, height));
    jcp.setBackground(Color.WHITE);
    jcp.createHorizontalScrollBar();
    return jcp;
  }
Exemplo n.º 6
0
  private void iniciarTabela() {

    tblCliente.setAutoCreateRowSorter(true);
    tblCliente.setRowHeight(35);

    TableColumn colunaDoc = tblCliente.getColumnModel().getColumn(DOCUMENTO);
    TableColumn colunaNome = tblCliente.getColumnModel().getColumn(NOME);
    TableColumn colunaEnd = tblCliente.getColumnModel().getColumn(ENDERECO);
    TableColumn colunaTel = tblCliente.getColumnModel().getColumn(TELEFONE);
    TableColumn colunaEdit = tblCliente.getColumnModel().getColumn(EDITAR);
    TableColumn colunaExcl = tblCliente.getColumnModel().getColumn(EXCLUIR);

    colunaDoc.setPreferredWidth(20);
    colunaNome.setPreferredWidth(200);
    colunaEnd.setPreferredWidth(200);
    colunaTel.setPreferredWidth(20);

    colunaEdit.setMaxWidth(50);
    colunaEdit.setMinWidth(35);
    colunaEdit.setCellRenderer(AbstractTableCrud.getIconCellRenderer());

    colunaExcl.setMaxWidth(50);
    colunaExcl.setMinWidth(35);
    colunaExcl.setCellRenderer(AbstractTableCrud.getIconCellRenderer());
  }
Exemplo n.º 7
0
  /**
   * Restore table column positions and sizes. Note, the table must have its auto resize mode set to
   * off, i.e.
   *
   * @param table
   * @param registry prefix
   * @param table name
   * @param default column widths
   */
  public void restoreTableMetrics(JTable table, String propertyName, int[] defaultWidths) {
    if (table.getAutoResizeMode() != JTable.AUTO_RESIZE_OFF)
      throw new IllegalArgumentException("Table AutoResizeMode must be JTable.AUTO_RESIZE_OFF");
    for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) {
      try {
        table.moveColumn(
            table.convertColumnIndexToView(
                Integer.parseInt(
                    context.getPreference(
                        propertyName + ".column." + i + ".position", String.valueOf(i)))),
            i);

        int w =
            Integer.parseInt(
                context.getPreference(
                    propertyName + ".column." + i + ".width",
                    String.valueOf(
                        (defaultWidths == null)
                            ? table.getColumnModel().getColumn(i).getPreferredWidth()
                            : defaultWidths[i])));
        table.getColumnModel().getColumn(i).setPreferredWidth(w);
      } catch (NumberFormatException nfe) {
      }
    }
  }
Exemplo n.º 8
0
    private void initListeners() {
      // install a listener to cause the whole table to repaint when
      // a column is resized. we do this because the extended grid
      // lines may need to be repainted. this could be cleaned up,
      // but for now, it works fine.
      fTable
          .getColumnModel()
          .addColumnModelListener(
              new TableColumnModelListener() {
                @Override
                public void columnMarginChanged(ChangeEvent e) {
                  repaint();
                }

                @Override
                public void columnAdded(TableColumnModelEvent e) {}

                @Override
                public void columnRemoved(TableColumnModelEvent e) {}

                @Override
                public void columnMoved(TableColumnModelEvent e) {}

                @Override
                public void columnSelectionChanged(ListSelectionEvent e) {}
              });
      PropertyChangeListener listener = createTableColumnWidthListener();
      for (int i = 0; i < fTable.getColumnModel().getColumnCount(); i++) {
        fTable.getColumnModel().getColumn(i).addPropertyChangeListener(listener);
      }
    }
  /**
   * This method initializes crudTable
   *
   * @return javax.swing.JTable
   */
  private JTable getCrudTable() {
    if (crudTable == null) {
      String[] columnNames = {
        M17N.get("CRUDViewFrame.columnName.table"),
        M17N.get("CRUDViewFrame.columnName.create"),
        M17N.get("CRUDViewFrame.columnName.read"),
        M17N.get("CRUDViewFrame.columnName.update"),
        M17N.get("CRUDViewFrame.columnName.delete")
      };
      this.tableData = createTableData();

      crudTable = new JTable(this.tableData, columnNames);

      // CRUD列のセルを右寄せにする
      DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
      renderer.setHorizontalAlignment(SwingConstants.RIGHT);
      crudTable.getColumnModel().getColumn(1).setCellRenderer(renderer);
      crudTable.getColumnModel().getColumn(2).setCellRenderer(renderer);
      crudTable.getColumnModel().getColumn(3).setCellRenderer(renderer);
      crudTable.getColumnModel().getColumn(4).setCellRenderer(renderer);

      // テーブル名列の幅
      crudTable.getColumnModel().getColumn(0).setPreferredWidth(270);
      // シングルクリックで編集できないようにする
      crudTable.putClientProperty("JTable.autoStartsEdit", Boolean.FALSE);
    }
    return crudTable;
  }
  private void refreshMotionTable() {
    final int COL_MOTION = 0;
    final int COL_START_FRAME = 1;
    final int COL_END_FRAME = 2;
    motionTable.setModel(
        new DefaultTableModel() {
          private static final long serialVersionUID = 1L;

          @Override
          public int getRowCount() {
            return project.getMotions().size();
          }

          @Override
          public int getColumnCount() {
            return 3;
          }

          @Override
          public String getColumnName(int columnIndex) {
            switch (columnIndex) {
              case COL_MOTION:
                return "Motion";
              case COL_START_FRAME:
                return "Start";
              case COL_END_FRAME:
                return "End";
            }
            return null;
          }

          @Override
          public Object getValueAt(int rowIndex, int columnIndex) {
            Motion motion =
                rowIndex < project.getMotions().size() ? project.getMotions().get(rowIndex) : null;
            if (motion != null) {
              switch (columnIndex) {
                case COL_MOTION:
                  return motion.getDisplayLabel();
                case COL_START_FRAME:
                  return (motion.getStartFrame() != null)
                      ? String.valueOf(motion.getStartFrame())
                      : "";
                case COL_END_FRAME:
                  return (motion.getEndFrame() != null) ? String.valueOf(motion.getEndFrame()) : "";
              }
            }
            return null;
          }

          @Override
          public boolean isCellEditable(int row, int column) {
            return false;
          }
        });
    motionTable.getTableHeader().setFont(motionTable.getFont());
    motionTable.getColumnModel().getColumn(COL_MOTION).setWidth(120);
    motionTable.getColumnModel().getColumn(COL_START_FRAME).setPreferredWidth(10);
    motionTable.getColumnModel().getColumn(COL_END_FRAME).setWidth(10);
  }
Exemplo n.º 11
0
  BindToNewBeanStep(@NotNull final WizardData data) {
    myData = data;
    myTableModel = new MyTableModel();
    myTable.setModel(myTableModel);
    myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    myScrollPane.getViewport().setBackground(myTable.getBackground());
    myTable.setSurrendersFocusOnKeystroke(true);

    // Customize "Form Property" column
    {
      final TableColumn column = myTable.getColumnModel().getColumn(0 /*Form Property*/);
      column.setCellRenderer(new FormPropertyTableCellRenderer(myData.myProject));
    }

    // Customize "Bean Property" column
    {
      final TableColumn column = myTable.getColumnModel().getColumn(1 /*Bean Property*/);
      column.setCellRenderer(new BeanPropertyTableCellRenderer());
      column.setCellEditor(new BeanPropertyTableCellEditor());

      final DefaultCellEditor editor = (DefaultCellEditor) myTable.getDefaultEditor(Object.class);
      editor.setClickCountToStart(1);
    }

    myChkGetData.setSelected(true);
    myChkGetData.setEnabled(false);
    myChkSetData.setSelected(true);
    myChkSetData.setEnabled(false);
    myChkIsModified.setSelected(myData.myGenerateIsModified);
  }
Exemplo n.º 12
0
  private void initialize() {
    dialogListener = new FindPluginListener();
    tableResults =
        new JTable(
            new DefaultTableModel(
                new String[] {"Plugin Name", "Author", "Date", "Description", "Access"},
                TABLE_ROW_COUNT));
    tableResults.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    tableResults.getColumnModel().getColumn(4).setCellRenderer(new TableRenderer());
    tableResults.getColumnModel().getColumn(0).setPreferredWidth(148);
    tableResults.getColumnModel().getColumn(3).setPreferredWidth(248);
    tableResults.getColumnModel().getColumn(4).setPreferredWidth(43);
    tableResults.getSelectionModel().addListSelectionListener(dialogListener);

    fieldKeywords = new JTextField(35);
    fieldKeywords.setActionCommand("FIND");
    fieldKeywords.addActionListener(dialogListener);

    areaComments = new JTextArea(10, 20);
    areaComments.setEditable(false);

    areaKeywords = new JTextArea(10, 20);
    areaKeywords.setEditable(false);

    labelName = new JLabel("Name:");
    labelCategory = new JLabel("Category:");

    pluginHits = new HashMap<Integer, File>();
  }
 @Override
 protected void customizeParametersTable(
     TableView<ParameterTableModelItemBase<ParameterInfoImpl>> table) {
   final JTable t = table.getComponent();
   final TableColumn defaultValue = t.getColumnModel().getColumn(2);
   final TableColumn varArg = t.getColumnModel().getColumn(3);
   t.removeColumn(defaultValue);
   t.removeColumn(varArg);
   t.getModel()
       .addTableModelListener(
           new TableModelListener() {
             @Override
             public void tableChanged(TableModelEvent e) {
               if (e.getType() == TableModelEvent.INSERT) {
                 t.getModel().removeTableModelListener(this);
                 final TableColumnAnimator animator = new TableColumnAnimator(t);
                 animator.setStep(48);
                 animator.addColumn(defaultValue, (t.getWidth() - 48) / 3);
                 animator.addColumn(varArg, 48);
                 animator.startAndDoWhenDone(
                     new Runnable() {
                       @Override
                       public void run() {
                         t.editCellAt(t.getRowCount() - 1, 0);
                       }
                     });
                 animator.start();
               }
             }
           });
 }
  public GUIRendWorkspace() {
    super("GUIRenderer");

    createMenu();
    workspaceModel.setTableFrame(this);
    add(new JScrollPane(workspaceTable));
    workspaceTable
        .getColumnModel()
        .getColumn(0)
        .setCellEditor(new DefaultCellEditor(componentTypeEditor));
    workspaceTable
        .getColumnModel()
        .getColumn(7)
        .setCellEditor(new DefaultCellEditor(componentFillEditor));
    workspaceTable
        .getColumnModel()
        .getColumn(8)
        .setCellEditor(new DefaultCellEditor(componentAnchorEditor));
    workspaceModel.addNewComponentEntry();
    JButton newButton = new JButton();
    newButton.addActionListener(new newComponent());

    workspaceToolbar.add(newButton);
    add(workspaceToolbar, BorderLayout.NORTH);
    pack();
  }
Exemplo n.º 15
0
 private void init_tbl_chats() {
   tbl_chats_ALM = new ArrayListModel();
   tbl_chats_M = new TblchatsModel(tbl_chats_ALM);
   tbl_chats.setModel(tbl_chats_M);
   tbl_chats.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
   int[] tbl_widths_chats = {58, 100, 0, 0, 0};
   for (int i = 0, n = tbl_widths_chats.length; i < n; i++) {
     if (i == 1) {
       continue;
     }
     TableWidthUtilities.setColumnWidth(tbl_chats, i, tbl_widths_chats[i]);
   }
   Dimension d = tbl_chats.getTableHeader().getPreferredSize();
   d.height = 0;
   tbl_chats.getTableHeader().setPreferredSize(d);
   tbl_chats.getTableHeader().setFont(new java.awt.Font("Arial", 0, 12));
   tbl_chats.setRowHeight(65);
   tbl_chats.setFont(new java.awt.Font("Arial", 0, 12));
   tbl_chats.getColumnModel().getColumn(0).setCellRenderer(new TableRender.set2());
   tbl_chats.getColumnModel().getColumn(1).setCellRenderer(new TableRender.set3());
   tbl_chats.getTableHeader().setResizingAllowed(true);
   tbl_chats.setShowGrid(false);
   tbl_chats.setShowHorizontalLines(true);
   tbl_chats.setShowVerticalLines(false);
   tbl_chats.getColumnModel().getColumn(1).setCellRenderer(new Html());
 }
Exemplo n.º 16
0
  /** This is a protected constructor called game console. */
  protected GameConsole() {

    _model = new DefaultTableModel();
    _model.addColumn("Round");
    _model.addColumn("Actor");
    _model.addColumn("Message");
    _table = new JTable(_model);
    setSize(800, 300);
    // _table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    _scrollPane = new JScrollPane(_table);

    _table.setSize(1250, 300);
    _table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    int vColIndex = 0;
    TableColumn col = _table.getColumnModel().getColumn(vColIndex);
    int width = 50;
    col.setPreferredWidth(width);

    vColIndex = 1;
    col = _table.getColumnModel().getColumn(vColIndex);
    width = 100;
    col.setPreferredWidth(width);

    vColIndex = 2;
    col = _table.getColumnModel().getColumn(vColIndex);
    width = 1500;
    col.setPreferredWidth(width);

    this.setTitle("Game Console");
    _scrollPane.setAutoscrolls(true);
    // _scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    // Add the scroll pane to this panel.
    add(_scrollPane);
  }
Exemplo n.º 17
0
 public CenterPanel(RegisterPanel rp) {
   super();
   setLayout(new BorderLayout());
   this.rp = rp;
   rp.setJT(jt);
   JScrollPane jsp = new JScrollPane(jt);
   setBackground(Color.BLACK);
   add(jsp, BorderLayout.CENTER);
   tm = (DefaultTableModel) jt.getModel();
   tm.addColumn("ID");
   tm.addColumn("Barcode");
   tm.addColumn("Name");
   tm.addColumn("Qty");
   tm.addColumn("Price");
   tm.addColumn("Tax");
   tm.addColumn("Total");
   // tm.setRowCount(50);
   // jt.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
   jt.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
   jt.getColumnModel().getColumn(0).setPreferredWidth(20);
   jt.getColumnModel().getColumn(1).setPreferredWidth(150);
   jt.getColumnModel().getColumn(2).setPreferredWidth(300);
   jt.getColumnModel().getColumn(3).setPreferredWidth(20);
   jt.setFont(new Font("Arial", Font.BOLD, 18));
   jt.setRowHeight(30);
 }
  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

    if (row % 2 == 1) {
      Color CorLinhas = new Color(225, 233, 255);
      setBackground(CorLinhas);
    } else {
      setBackground(null);
    }

    if (isSelected) {
      Color CorSelect = new Color(0, 152, 255);
      Color CorTexto = new Color(255, 255, 255);
      setBackground(CorSelect);
      setForeground(CorTexto);
    } else {
      setForeground(null);
    }

    DefaultTableCellRenderer esquerda = new DefaultTableCellRenderer();
    DefaultTableCellRenderer centralizado = new DefaultTableCellRenderer();
    DefaultTableCellRenderer direita = new DefaultTableCellRenderer();

    esquerda.setHorizontalAlignment(SwingConstants.LEFT);
    centralizado.setHorizontalAlignment(SwingConstants.CENTER);
    direita.setHorizontalAlignment(SwingConstants.RIGHT);

    table.getColumnModel().getColumn(0).setMaxWidth(141);
    table.getColumnModel().getColumn(0).setMinWidth(141);
    table.getColumnModel().getColumn(1).setMaxWidth(415);
    table.getColumnModel().getColumn(1).setMinWidth(415);
    return this;
  }
Exemplo n.º 19
0
  private void initTableVisualProperties(JTable table) {

    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    table.setIntercellSpacing(new java.awt.Dimension(0, 0));
    // set the color of the table's JViewport
    table.getParent().setBackground(table.getBackground());

    // we'll get the parents width so we can use that to set the column sizes.
    double pw = table.getParent().getParent().getPreferredSize().getWidth();

    // #88174 - Need horizontal scrollbar for library names
    // ugly but I didn't find a better way how to do it
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    TableColumn column = table.getColumnModel().getColumn(0);
    column.setMinWidth(226);
    column.setWidth(((int) pw / 2) - 1);
    column.setPreferredWidth(((int) pw / 2) - 1);
    column.setMinWidth(75);
    column = table.getColumnModel().getColumn(1);
    column.setMinWidth(226);
    column.setWidth(((int) pw / 2) - 1);
    column.setPreferredWidth(((int) pw / 2) - 1);
    column.setMinWidth(75);
    this.addComponentListener(new TableColumnSizeComponentAdapter(table));
  }
Exemplo n.º 20
0
  public void initialize() {
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    getContentPane().setLayout(gridbag);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(2, 2, 2, 2);

    int col = 0;
    Utility.buildConstraints(c, col, 0, 1, 1, 100, 20);
    JLabel label =
        new JLabel(LanguageBundle.getFormattedString("in_SolverView_Perspective")); // $NON-NLS-1$
    gridbag.setConstraints(label, c);
    getContentPane().add(label);

    Utility.buildConstraints(c, col++, 1, 1, 1, 0, 20);
    gridbag.setConstraints(identifierChooser, c);
    getContentPane().add(identifierChooser);

    Utility.buildConstraints(c, col++, 1, 1, 1, 0, 20);
    gridbag.setConstraints(scopeChooser, c);
    getContentPane().add(scopeChooser);

    Utility.buildConstraints(c, col++, 1, 1, 1, 0, 20);
    gridbag.setConstraints(objectChooser, c);
    getContentPane().add(objectChooser);

    Utility.buildConstraints(c, col++, 1, 1, 1, 0, 20);
    label =
        new JLabel(
            LanguageBundle.getFormattedString("in_SolverView_VarName") // $NON-NLS-1$
            );
    gridbag.setConstraints(label, c);
    getContentPane().add(label);

    Utility.buildConstraints(c, col++, 1, 1, 1, 0, 20);
    gridbag.setConstraints(varName, c);
    getContentPane().add(varName);

    tableModel = new SolverTableModel();
    viewTable = new JTable(tableModel);

    viewTable.getColumnModel().getColumn(0).setPreferredWidth(25);
    viewTable.getColumnModel().getColumn(1).setPreferredWidth(50);
    viewTable.getColumnModel().getColumn(2).setPreferredWidth(25);
    viewTable.getColumnModel().getColumn(3).setPreferredWidth(50);

    Utility.buildConstraints(c, 0, 2, col, 1, 0, 1000);
    JScrollPane pane = new JScrollPane(viewTable);
    viewTable.setFillsViewportHeight(true);
    pane.setPreferredSize(new Dimension(500, 300));
    gridbag.setConstraints(pane, c);
    getContentPane().add(pane);

    setTitle("Core Variable Debug View");
    getContentPane().setSize(500, 400);
    pack();
    Utility.centerFrame(this, true);
  }
Exemplo n.º 21
0
  private void prepareComponent() {
    CloseEventHandler closeEventHandler = new CloseEventHandler();
    addWindowListener(closeEventHandler);

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    JPanel contentPanel = new JPanel();
    // JPanel contentPanel = new FormDebugPanel();
    contentPane.add(contentPanel, BorderLayout.CENTER);

    CellConstraints cc = new CellConstraints();
    FormLayout layout =
        new FormLayout(
            "4dlu, d:grow, 4dlu", // columns
            "4dlu, p, 2dlu, fill:100dlu:grow, 4dlu, "
                + // rows
                "p, 2dlu, p, 4dlu"); // btn rows
    PanelBuilder contentPB = new PanelBuilder(layout, contentPanel);
    int columnCount = layout.getColumnCount();
    int rowCount = layout.getRowCount();

    JLabel label = new JLabel(Localizer.getString("MediaTypeCondEditor_ConditionToAdd"));
    contentPB.add(label, cc.xywh(2, 2, 1, 1));

    mediaTypeModel = new MediaTypeModel();
    mediaTypeTable = new JTable(mediaTypeModel);
    JTableHeader tableHeader = mediaTypeTable.getTableHeader();
    tableHeader.setResizingAllowed(false);
    tableHeader.setReorderingAllowed(false);
    // adjust column witdh of checkbox
    JCheckBox box = (JCheckBox) mediaTypeTable.getDefaultRenderer(Boolean.class);
    TableColumn column = mediaTypeTable.getColumnModel().getColumn(0);
    column.setMaxWidth(box.getPreferredSize().width + 2);
    column.setMinWidth(box.getPreferredSize().width + 2);
    mediaTypeTable.getColumnModel().getColumn(1).setCellRenderer(new MediaTypeCellRenderer());
    // ToolTipManager.sharedInstance().registerComponent( mediaTypeTable );
    contentPB.add(new JScrollPane(mediaTypeTable), cc.xywh(2, 4, 1, 1));

    // button bar
    contentPB.add(new JSeparator(), cc.xywh(1, rowCount - 3, columnCount, 1));

    JButton okBtn = new JButton(Localizer.getString("OK"));
    okBtn.addActionListener(new OkBtnListener());
    okBtn.setDefaultCapable(true);
    okBtn.setRequestFocusEnabled(true);

    JButton cancelBtn = new JButton(Localizer.getString("Cancel"));
    cancelBtn.addActionListener(closeEventHandler);

    JPanel btnPanel = ButtonBarFactory.buildOKCancelBar(okBtn, cancelBtn);
    contentPB.add(btnPanel, cc.xywh(2, rowCount - 1, columnCount - 2, 1));

    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    getRootPane().setDefaultButton(okBtn);

    pack();
    setLocationRelativeTo(getParent());
  }
Exemplo n.º 22
0
 public void montarTbProduto(JTable tb_produto) {
   String[] colunas = {"Código", "Nome", "Unidade"};
   dadosProd = new DefaultTableModel(colunas, 0);
   tb_produto.setModel(dadosProd);
   tb_produto.getColumnModel().getColumn(0).setPreferredWidth(5);
   tb_produto.getColumnModel().getColumn(1).setPreferredWidth(200);
   tb_produto.getColumnModel().getColumn(2).setPreferredWidth(50);
 }
Exemplo n.º 23
0
 public void setModel(LogItemTableModel model) {
   this.model = model;
   logItemTable.setModel(model);
   logItemTable.getColumnModel().getColumn(0).setMinWidth(180);
   logItemTable.getColumnModel().getColumn(0).setMaxWidth(200);
   logItemTable.getColumnModel().getColumn(1).setMinWidth(50);
   logItemTable.getColumnModel().getColumn(1).setMaxWidth(80);
   logItemTable.setDefaultRenderer(Object.class, new LogEntryRenderer());
 }
Exemplo n.º 24
0
 private void setTableColumnWidths() {
   table.sizeColumnsToFit(JTable.AUTO_RESIZE_NEXT_COLUMN);
   TableColumn column = null;
   column = table.getColumnModel().getColumn(0);
   column.setMinWidth(KEY_COL_WIDTH);
   column.setPreferredWidth(KEY_COL_WIDTH);
   column = table.getColumnModel().getColumn(1);
   column.setPreferredWidth(VAL_COL_WIDTH);
 }
Exemplo n.º 25
0
 /**
  * Save table column positions and sizes. Note, the table must have its auto resize mode set to
  * off, i.e.
  *
  * @param table
  * @param registry prefix
  * @param table name
  */
 private void saveTableMetrics(JTable table, String propertyName) {
   for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) {
     int w = table.getColumnModel().getColumn(i).getWidth();
     context.putPreference(propertyName + ".column." + i + ".width", String.valueOf(w));
     context.putPreference(
         propertyName + ".column." + i + ".position",
         String.valueOf(table.convertColumnIndexToModel(i)));
   }
 }
Exemplo n.º 26
0
  /**
   * This method initializes jTable
   *
   * @return javax.swing.JTable
   */
  JTable getJTable() {
    if (jTable == null) {
      Event event = new Event();
      AdministrateEventController controller = new AdministrateEventController();
      event = controller.processRetrieve();

      int colWidth = 100;
      Object[] colNames = {"Event ID", "Event Date", "Event Time", "Event Name", "Status"};
      Object[][] data = new Object[event.getEventID_list().size()][colSize];

      for (int i = 0; i < event.getEventID_list().size(); i++) {
        data[i][0] = event.getEventID_list().get(i);
        data[i][1] = controller.calendarToString(event.getEventDate_list().get(i));
        data[i][2] = event.getEventTime_list().get(i);
        data[i][3] = event.getEventName_list().get(i);
        data[i][4] = event.getEventStatus_list().get(i);
      }

      model.setDataVector(data, colNames);
      jTable = new JTable(model);

      if (viewModel != null) {
        jTable.setModel(viewModel);
        viewModel = null;
      }

      jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

      for (int i = 0; i < colSize; i++) {
        jTable.getColumnModel().getColumn(i).setCellRenderer(new Renderer());
        jTable.getColumnModel().getColumn(i).setPreferredWidth(colWidth);
      }

      jTable.getColumnModel().getColumn(3).setPreferredWidth(250);
      jTable.getColumnModel().getColumn(4).setPreferredWidth(172);

      jTable.setAutoCreateColumnsFromModel(false);
      sortAllRowsBy(model, 0, true);
      jTable.setEnabled(false);

      JTableHeader header = jTable.getTableHeader();
      header.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              JTableHeader h = (JTableHeader) e.getSource();
              int nColumn = h.columnAtPoint(e.getPoint());
              if (nColumn != -1) sortAllRowsBy(model, nColumn, true);
            }
          });

      etbml = new EventTableButtonMouseListener(jTable, source, crudFf);
      etbml.setSelection(selection);
      jTable.addMouseListener(etbml);
    }
    return jTable;
  }
Exemplo n.º 27
0
  protected void setupTable(JTable table) {

    table.setFillsViewportHeight(true);
    table.getColumnModel().getColumn(2).setMaxWidth(150);
    table.getColumnModel().getColumn(1).setMaxWidth(150);
    table.getColumnModel().getColumn(0).setMaxWidth(150);
    //   table.getColumnModel().getColumn(0).setPreferredWidth(10);

    table.setDefaultRenderer(Color.class, new ColorTableCellRenderer());
  }
Exemplo n.º 28
0
 {
   table = new JTable();
   model.setErrors(errors);
   table.setModel(model);
   TableColumn detailsColumn = table.getColumnModel().getColumn(1);
   detailsColumn.setCellEditor(new DetailRenderer());
   detailsColumn.setCellRenderer(new DetailRenderer());
   detailsColumn.setPreferredWidth(15);
   table.getColumnModel().getColumn(0).setPreferredWidth(DEFAULT_FIRST_COMUMN_WIDTH);
 }
Exemplo n.º 29
0
 private void confColumnModel() {
   for (int row = 0; row < lifeModel.getRowCount(); row++) {
     for (int col = 0; col < lifeModel.getColumnCount(); col++) {
       lifeTable.getColumnModel().getColumn(col).setMaxWidth(CELL_SIZE);
       lifeTable.getColumnModel().getColumn(col).setMinWidth(CELL_SIZE);
       lifeTable.getColumnModel().getColumn(col).setPreferredWidth(CELL_SIZE);
       lifeTable.getColumnModel().getColumn(col).setResizable(false);
     }
   }
 }
Exemplo n.º 30
0
 public void componentResized(ComponentEvent evt) {
   double pw = table.getParent().getParent().getSize().getWidth();
   table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
   TableColumn column = table.getColumnModel().getColumn(0);
   column.setWidth(((int) pw / 2) - 1);
   column.setPreferredWidth(((int) pw / 2) - 1);
   column = table.getColumnModel().getColumn(1);
   column.setWidth(((int) pw / 2) - 1);
   column.setPreferredWidth(((int) pw / 2) - 1);
 }