private void initWidget() {
   anchorTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
   anchorTable.setFillsViewportHeight(true);
   scrollPane = new JScrollPane(anchorTable);
   this.add(scrollPane);
   initWidgetListeners();
 }
Example #2
0
  void refreshCommunities() {
    removeAll();
    setLayout(new BorderLayout());
    String[] communityNames = myAgent.getCommunities();
    Object[][] data = new Object[communityNames.length][2];
    for (int i = 0; i < communityNames.length; i++) {
      data[i][0] = communityNames[i];
      data[i][1] = new Boolean(myAgent.connectedWith(communityNames[i]));
      // JCheckBox c = new JCheckBox(communityNames[i],myAgent.connectedWith(communityNames[i]));
      // c.addItemListener(this);
      // tmp.add(c);
    }
    // JPanel tmp = new JPanel();
    // tmp.setLayout(new GridLayout(communityNames.length,1,5,5));
    // tmp.setBorder(BorderFactory.createEmptyBorder(20,20,20,20));

    SitesTableModel sitesModel = new SitesTableModel(this, data);
    JTable table = new JTable(sitesModel);
    table.setPreferredScrollableViewportSize(new Dimension(200, 100));

    // Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    // Add the scroll pane to this window.
    add(scrollPane, BorderLayout.CENTER);

    add("North", new JLabel("Available communities"));
    // add("Center",tmp);
    validate();
  }
  public SimpleTableDemo() {
    super(new GridLayout(1, 0));

    String[] columnNames = {"First Name", "Last Name", "Sport", "# of Years", "Vegetarian"};

    Object[][] data = {
      {"Kathy", "Smith", "Snowboarding", new Integer(5), new Boolean(false)},
      {"John", "Doe", "Rowing", new Integer(3), new Boolean(true)},
      {"Sue", "Black", "Knitting", new Integer(2), new Boolean(false)},
      {"Jane", "White", "Speed reading", new Integer(20), new Boolean(true)},
      {"Joe", "Brown", "Pool", new Integer(10), new Boolean(false)}
    };

    final JTable table = new JTable(data, columnNames);
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);

    if (DEBUG) {
      table.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              printDebugData(table);
            }
          });
    }

    // Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    // Add the scroll pane to this panel.
    add(scrollPane);
  }
Example #4
0
  private Component table() {
    String[] titles = {
      "Year",
      "Starting Balance",
      "Starting Principal",
      "Withdrawals",
      "Appreciation",
      "Deposits",
      "Ending Balance"
    };
    tableModel = new DefaultTableModel(titles, 0);
    for (int i = 0; i < 12800; i++) {
      tableModel.addRow(
          new Integer[] {1900 + i, 10000 + i, 8000 + i, 50 + i, 905 + i, 2000 + i, 12000 + i});
    }

    JTable table = new CustomTable(tableModel);

    int preferredWidth = 0;
    for (int i = 0; i < table.getColumnCount(); i++) {
      int width = packColumn(table, i, 2);
      preferredWidth += width;
    }
    Dimension preferredSize = new Dimension(preferredWidth, 400);
    table.setPreferredScrollableViewportSize(preferredSize);
    this.setMinimumSize(preferredSize);

    JScrollPane scrollPane = new JScrollPane(table);
    return scrollPane;
  }
  /**
   * Luo tilikarttataulukon.
   *
   * @param container taulukon sƤiliƶ
   */
  private void createTable() {
    tableModel = new DocumentTypeTableModel();
    tableModel.setModel(model);

    table = new JTable(tableModel);
    table.setFillsViewportHeight(true);
    table.setPreferredScrollableViewportSize(new Dimension(400, 250));
    table.setRowHeight(24);

    TableColumn column;
    int[] widths = new int[] {80, 140, 80, 80};

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

    /* Muutetaan enter-nƤppƤimen toiminta. */
    table
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "nextCell");

    table.getActionMap().put("nextCell", nextCellAction);

    add(
        new JScrollPane(
            table,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER),
        BorderLayout.CENTER);
  }
  /** Main visualizer setup. */
  private void init() {
    this.setLayout(new BorderLayout());

    // MAIN PANEL
    JPanel mainPanel = new JPanel();
    Border margin = new EmptyBorder(10, 10, 5, 10);

    mainPanel.setBorder(margin);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

    mainPanel.add(JMeterPluginsUtils.addHelpLinkToPanel(makeTitlePanel(), WIKIPAGE));

    // SortFilterModel mySortedModel =
    // new SortFilterModel(myStatTableModel);
    myJTable = new JTable(model);
    myJTable
        .getTableHeader()
        .setDefaultRenderer(new JMeterHeaderAsPropertyRenderer(COLUMNS_MSG_PARAMETERS));
    myJTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
    RendererUtils.applyRenderers(myJTable, RENDERERS);
    myScrollPane = new JScrollPane(myJTable);
    this.add(mainPanel, BorderLayout.NORTH);
    this.add(myScrollPane, BorderLayout.CENTER);
    saveTable.addActionListener(this);
    JPanel opts = new JPanel();
    opts.add(useGroupName, BorderLayout.WEST);
    opts.add(saveTable, BorderLayout.CENTER);
    opts.add(saveHeaders, BorderLayout.EAST);
    this.add(opts, BorderLayout.SOUTH);
  }
  /**
   * Generates a JTable using results from Assessment data
   *
   * @param assessment - Assessment object
   */
  public void makeTable(Assessment assessment) {
    DefaultTableModel model =
        new DefaultTableModel() {
          @Override
          public boolean isCellEditable(int row, int column) {
            // Disables all cells from being editable
            return false;
          }
        };

    // Assigns column headings
    boolean isAnonymised = !assessment.getResults().get(0).getCandKey().contains("#");
    if (isAnonymised) {
      model.addColumn("Name");
      model.addColumn("Student Number");
    } else {
      model.addColumn("Anon Codes");
    }

    model.addColumn("#Ass");
    model.addColumn("Module Code");
    model.addColumn("Mark");
    model.addColumn("Grade");

    table = new JTable(model);
    table.setFont(new Font("Calibri", Font.BOLD, 14));

    // Sets column header look
    JTableHeader header = table.getTableHeader();
    header.setFont(new Font("Calibri", Font.BOLD, 16));
    header.setBackground(Color.black);
    header.setForeground(Color.WHITE);

    // Sets cell selection to single so only one cell is selected
    table.setCellSelectionEnabled(true);
    System.out.println("Making JTable");
    // Fetches first assessment and adds results data to model
    for (Result r : assessment.getResults()) {
      String name = r.getName();
      if (r.getName().equals("")) {
        name = r.getCandKey();
      }
      if (isAnonymised) {
        model.addRow(
            new Object[] {
              name, r.getCandKey(), r.getAssessment(), r.getModuleCode(), r.getMark(), r.getGrade()
            });
      } else {
        model.addRow(
            new Object[] {
              r.getCandKey(), r.getAssessment(), r.getModuleCode(), r.getMark(), r.getGrade()
            });
      }
    }

    table.setPreferredScrollableViewportSize(new Dimension(200, 300));
    table.setFillsViewportHeight(true);
    table.setShowGrid(false);
  }
 private JTable getTableNumberDeliveries() {
   if (tableNumberDeliveries == null) {
     tableNumberDeliveries = new JTable();
     tableNumberDeliveries.setModel(new ModelTableDeliveries());
     tableNumberDeliveries.setPreferredScrollableViewportSize(new Dimension(800, 470));
   }
   return tableNumberDeliveries;
 }
Example #9
0
 private Component getTable() {
   if (tableView == null) {
     JTable table = new JTable(getTableModel(), getTableColumnModel());
     JScrollPane scrollPane = new JScrollPane(table);
     table.setPreferredScrollableViewportSize(new Dimension(500, 70));
     tableView = scrollPane;
   }
   return tableView;
 }
  private JComponent createTable(DataModel aMod) {
    JTable tab = new JTable(aMod);
    tab.setPreferredScrollableViewportSize(new Dimension(500, 70));
    tab.setFillsViewportHeight(true);
    tab.setAutoscrolls(true);
    tab.setDefaultRenderer(Object.class, new TableRenderBD());
    JScrollPane scrollPane = new JScrollPane(tab);

    return scrollPane;
  }
Example #11
0
  /**
   * Add all the components for display the list of plots and which are showing the current spectra.
   */
  protected void initUI() {
    setBorder(BorderFactory.createTitledBorder("Views of current spectra:"));
    setLayout(new BorderLayout());
    setToolTipText("Select to add the current spectra to a plot, " + "deselect to remove them.");

    //  Set up the table to use a model based on the global lists
    //  of plots and spectra and to track the current spectrum
    //  when selected in list.
    table.setModel(tableModel);

    //  Hack the size of this so that it doesn't get too big for
    //  the values we know it's going to display, cell width
    //  control in JTable sucks (or I don't understand it!).
    table.setPreferredScrollableViewportSize(new Dimension(250, 0));

    //  Set the headers!
    TableColumnModel columns = table.getColumnModel();
    TableColumn column;
    column = columns.getColumn(table.convertColumnIndexToView(0));
    column.setHeaderValue("View");
    column = columns.getColumn(table.convertColumnIndexToView(1));
    column.setHeaderValue("Displayed");

    //  The table can have many rows selected.
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    //  Double click on a row raises the associated plot.
    table.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() >= 2) {
              raiseCurrentPlot();
            }
          }
        });

    //  Use a FuzzyBooleanCellRenderer for FuzzyBoolean objects in
    //  this table. This is tristate for dealing with partial
    //  spectra/plot relations.
    table.setDefaultRenderer(FuzzyBoolean.class, new FuzzyBooleanCellRenderer());
    table.setDefaultEditor(FuzzyBoolean.class, new FuzzyBooleanCellEditor());

    //  Add components.
    scroller.getViewport().add(table, null);
    add(scroller, BorderLayout.CENTER);

    //  Set up the listSelectionListener so that we can update
    //  when the selected spectra change.
    list.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            update(e);
          }
        });
  }
Example #12
0
  /** set column names; */
  public Stock_Check() {
    Vector<String> columnNames = new Vector<String>();
    columnNames.add("Ingredient_ID");
    columnNames.add("Ingredient_Name");
    columnNames.add("Ingredient_Stock");

    /** this select query from database in ingredient */
    String query = "SELECT ingrid, name, stock FROM ingredient";
    /**
     * connect to the Database using method in Database class. execute query and get the require
     * query for the table to show.
     */
    try {
      conn = Database.staticGetConnection();
      stmt = conn.createStatement();
      ResultSet rs = stmt.executeQuery(query);
      while (rs.next()) {
        Vector<String> vstring = new Vector<String>();
        vstring.add(rs.getString("ingrid"));
        vstring.add(rs.getString("name"));
        vstring.add(rs.getString("stock"));
        data.add(vstring);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (stmt != null) {
        try {
          stmt.close();
        } catch (SQLException ex) {
          Logger.getLogger(FlashBuilderGUI.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
    }

    /** this set up the model for table. such as size. */
    DefaultTableModel model = new DefaultTableModel(data, columnNames);
    final JTable table = new JTable(model);
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);

    if (DEBUG) {
      table.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              printDebugData(table);
            }
          });
    }

    /** Create a scroll pane and add table in it */
    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.setBounds(0, 0, 450, 300);
    add(scrollPane);
  }
Example #13
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();
 }
Example #14
0
  public Tabla() {
    super("Pilotos");

    MyTableModel myModel = new MyTableModel();
    JTable table = new JTable(myModel);

    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    // Creatamos un contenedor para la Tabla
    JScrollPane scrollPane = new JScrollPane(table);
    // Agregamos nuestra tabla al contenedor
    getContentPane().add(scrollPane, BorderLayout.CENTER);
  }
 public void init() {
   txt_sexo = new JTextField();
   txt_sexo.setColumns(10);
   txt_nombre = new JTextField();
   txt_nombre.setColumns(10);
   lbl_nombre = new JLabel("Nombre:");
   lbl_sexo = new JLabel("Sexo:");
   btn_modificar = new JButton("Modificar");
   btn_modificar.addActionListener(this);
   tbl_employees = new JTable(new MyTablemod(filastotales));
   tbl_employees.setPreferredScrollableViewportSize(new Dimension(500, 70));
   tbl_employees.setFillsViewportHeight(true);
 }
Example #16
0
  public SessionTable() {
    super(new GridLayout(1, 0));

    JTable table = new JTable(new MyTableModel());
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);

    // Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    // Add the scroll pane to this panel.
    add(scrollPane);
  }
Example #17
0
  protected JTable createDefaultsTable() {
    JTable table = new JTable(new UIDefaultsTableModel());
    table.setRowHeight(rowHeight);
    table.setShowHorizontalLines(false);
    table.setShowVerticalLines(false);
    table.setIntercellSpacing(new Dimension(0, 0));
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    initFilters(table);

    DefaultTableColumnModel columnModel = new DefaultTableColumnModel();

    Color rowColors[] = new Color[2];
    rowColors[0] = UIManager.getColor("Table.background");
    rowColors[1] =
        new Color(
            (int) (rowColors[0].getRed() * .90),
            (int) (rowColors[0].getGreen() * .95),
            (int) (rowColors[0].getBlue() * .95));

    int width = 0;

    TableColumn column = new TableColumn();
    column.setCellRenderer(new KeyRenderer(rowColors));
    column.setModelIndex(UIDefaultsTableModel.KEY_COLUMN);
    column.setHeaderValue("Key");
    column.setPreferredWidth(250);
    columnModel.addColumn(column);
    width += column.getPreferredWidth();

    column = new TableColumn();
    column.setCellRenderer(new RowRenderer(rowColors));
    column.setModelIndex(UIDefaultsTableModel.TYPE_COLUMN);
    column.setHeaderValue("Type");
    column.setPreferredWidth(250);
    columnModel.addColumn(column);
    width += column.getPreferredWidth();

    column = new TableColumn();
    column.setCellRenderer(new ValueRenderer(rowColors));
    column.setModelIndex(UIDefaultsTableModel.VALUE_COLUMN);
    column.setHeaderValue("Value");
    column.setPreferredWidth(300);
    columnModel.addColumn(column);
    width += column.getPreferredWidth();

    table.setColumnModel(columnModel);

    table.setPreferredScrollableViewportSize(new Dimension(width, 12 * rowHeight));

    return table;
  }
  // Panel que muestra la tabla
  private Container tabla() {
    JPanel pnl = new JPanel(new GridLayout(2, 0));
    String[] columnNames = {
      "Marca",
      "Modelo",
      "Color",
      "Precio",
      "Clave",
      "Procesador",
      "RAM",
      "HDD",
      "Tarjeta de video",
      "Tarjeta de audio"
    };

    final JTable table = new JTable(getModeloDatos(), columnNames);
    table.setPreferredScrollableViewportSize(new Dimension(470, 340));
    table.setFillsViewportHeight(true);

    JScrollPane scrollPane = new JScrollPane(table);
    pnl.add(scrollPane);
    // Se aƱaden los botones al panel
    regresar = new JButton("Regresar");
    comprar = new JButton("Comprar");
    buscar = new JButton("Buscar");
    add(regresar);
    add(comprar);
    add(buscar);
    // Event-handles para los botones de Regresar, Comprar y Buscar
    regresar.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            sistema.mostrarPanel(PanelBase.PANEL_INICIO);
          }
        });
    comprar.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            comprar(table);
          }
        });
    buscar.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            buscarComputadora(table);
          }
        });
    return pnl;
  }
  @SuppressWarnings("serial")
  public JPanel listStudentPanel() {
    JPanel stdnAdd = new JPanel();

    jt =
        new JTable(model) {
          public Component prepareRenderer(TableCellRenderer r, int rows, int columns) {
            Component c = super.prepareRenderer(r, rows, columns);

            if (rows % 2 == 0) {
              c.setBackground(new Color(208, 208, 208));
            } else {
              c.setBackground(new Color(192, 192, 192));
            }

            if (isCellSelected(rows, columns)) {
              c.setBackground(new Color(150, 150, 150));
            }

            return c;
          }
        };

    DefaultTableCellRenderer rdr = new DefaultTableCellRenderer();
    rdr.setHorizontalAlignment(SwingConstants.CENTER);
    //		for(int i = 0; i < 8; i++){
    //			jt.getColumnModel().getColumn(i).setCellRenderer(rdr);
    //		}

    jt.setPreferredScrollableViewportSize(new Dimension(730, 260));
    jt.setFillsViewportHeight(true);
    // enable selection to only
    jt.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    jt.getTableHeader().setBackground(Color.BLUE);
    jt.getTableHeader().setForeground(Color.BLUE);

    jt.setAutoCreateRowSorter(true);
    jt.setRowHeight(25);

    JScrollPane jps = new JScrollPane(jt);
    stdnAdd.add(jps);

    return stdnAdd;
  }
Example #20
0
    public SymbolPanel() {
      setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

      mainPanel = new JPanel();
      mainPanel.setBorder(BorderFactory.createLineBorder(Color.black));
      mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

      Box box = Box.createHorizontalBox();
      box.add(new JLabel("Items"));
      mainPanel.add(box);

      model = new SymbolTableModel();
      table = new JTable(model);
      table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      if (getValueList() != null && getValueList().size() > 0) {
        table.getSelectionModel().setSelectionInterval(0, 0);
      }
      ListSelectionModel rowSM = table.getSelectionModel();
      rowSM.addListSelectionListener(
          new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
              if (e.getValueIsAdjusting()) return;

              ListSelectionModel lsm = (ListSelectionModel) e.getSource();
              if (lsm.isSelectionEmpty()) {
                showItem(NO_CURRENT_ITEM);
              } else {
                int selectedRow = lsm.getMinSelectionIndex();
                showItem(selectedRow);
              }
            }
          });

      scrollPane = new ScrollPane(table);
      table.setPreferredScrollableViewportSize(new Dimension(300, 100));
      mainPanel.add(scrollPane);

      detailPanel = new JPanel();
      mainPanel.add(new ScrollPane(detailPanel));

      add(mainPanel);

      showItem(0);
    }
  public TableRenderDemo() {
    // super(new GridLayout(1,0));

    JTable table = new JTable(new MyTableModel());
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);

    // Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    // Set up column sizes.
    initColumnSizes(table);

    // Fiddle with the Sport column's cell editors/renderers.
    setUpSportColumn(table, table.getColumnModel().getColumn(2));

    // Add the scroll pane to this panel.
    add(scrollPane);
  }
  public static void main(String[] args) {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
      e.printStackTrace();
    }

    Action action = new GloballyContextSensitiveAction("selectAll", "selectAll", "selectAll");
    JMenuBar menubar = new JMenuBar();
    JMenu menu = new JMenu("Actions");
    menu.add(action);
    menubar.add(menu);

    JToolBar toolbar = new JToolBar();
    toolbar.setRollover(true);
    toolbar.setFloatable(true);
    toolbar.add(action);

    JPanel contents = new JPanel();

    String[] listData = new String[] {"item1", "item2", "item3", "item4", "item5            "};
    JList list = new JList(listData);
    contents.add(new JScrollPane(list));

    JTree tree = new JTree();
    tree.setVisibleRowCount(10);
    contents.add(new JScrollPane(tree));

    JTable table = new JTable(new DefaultTableModel(new String[] {"Name", "Type", "Modified"}, 10));
    table.setPreferredScrollableViewportSize(new Dimension(100, 5 * table.getRowHeight()));
    contents.add(new JScrollPane(table));
    contents.add(new JPanel());

    JFrame frame = new JFrame("Globally Context Sensitive Actions - [email protected]");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(menubar);
    frame.getContentPane().add(contents);
    frame.getContentPane().add(toolbar, BorderLayout.NORTH);

    frame.pack();
    frame.show();
  }
Example #23
0
  /**
   * Return the scroll pane
   *
   * @return JScrollPane
   */
  protected JScrollPane getScrollPane() {
    if (scrollPane == null) {
      scrollPane = new JScrollPane();
      scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
      scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      scrollPane.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE);
      scrollPane.setViewportView(getTable());
      scrollPane.setColumnHeaderView(table.getTableHeader());
      scrollPane.addComponentListener(eventHandler);

      tableSize =
          new Dimension(
              getTable().getColumnModel().getTotalColumnWidth(),
              getTable().getModel().getRowCount() * (getTable().getRowHeight()));
      table.setPreferredScrollableViewportSize(tableSize);
      table.setPreferredSize(tableSize);
      table.setMinimumSize(tableSize);
    }
    return scrollPane;
  }
 public InstallationInfo(Configuration configuration, String message) {
   setLayout(new BorderLayout());
   JLabel label = new JLabel(message);
   label.setHorizontalAlignment(SwingConstants.CENTER);
   add(label, BorderLayout.NORTH);
   String[] columns = {"Parameter", "Value"};
   String[][] data = {
     {"Installation Directory", configuration.getParameterValue(Parameter.SERVER_PREFIX)},
     {"Data Directory", configuration.getParameterValue(Parameter.DATA_PREFIX)},
     {"Log Directory", configuration.getParameterValue(Parameter.LOG_PREFIX)},
     {"Hostame", configuration.getParameterValue(Parameter.HOSTNAME)}
   };
   JTable table = new JTable(data, columns);
   JScrollPane container = new JScrollPane(table);
   Dimension size = new Dimension();
   size.width = 600;
   size.height = table.getRowCount() * table.getRowHeight();
   table.setPreferredScrollableViewportSize(size);
   add(container, BorderLayout.CENTER);
   validate();
 }
  // constructor
  public ClassTableInstance(JFrame jframe) {
    super(new BorderLayout(0, 0));

    this.frame = jframe;

    model = new MyTableModel();
    table = new JTable(model);
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));

    // Create the scroll pane and add the table to it.
    scrollPane = new JScrollPane(table);

    // Enable tool tips.
    ToolTipManager.sharedInstance().registerComponent(table);

    // set up colour manager
    table.setDefaultRenderer(String.class, new ColorRenderer(true));

    // Listen for when the selection changes.
    table.addMouseListener(this);

    // Custom cell weight
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    // frame resize listener
    frame.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentResized(ComponentEvent e) {
            double a =
                e.getComponent().getSize().getWidth()
                    - scrollPane.getVerticalScrollBar().getSize().getWidth();
            setTableDimensions((a - 15) * 0.3);
          }
        });

    // Add the scroll pane to this panel.
    add(scrollPane, BorderLayout.CENTER);
  }
Example #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;
  }
  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);
  }
Example #28
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 + ")");
  }
  /**
   * Create the panel
   *
   * @throws Exception if error occures during creation of the panel
   */
  private void init() throws Exception {

    // create objects to display
    this.setLayout(new BorderLayout());
    model = new MyTableModel();
    table = new JTable(model);
    table.setShowGrid(true);
    table.setAutoscrolls(true);
    table.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
    JScrollPane scrollpane = new JScrollPane(table);
    table.setPreferredScrollableViewportSize(new Dimension(800, 200));
    table.setFont(GuiFactory.defaultTableFont);
    table.getTableHeader().setFont(GuiFactory.defaultTableHeaderFont);

    table.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent event) {
            if (event.getClickCount() == 2) {
              try {
                ExplorerUtil.getSyncAdminController()
                    .getPrincipalsController()
                    .startLastTimestampsProcess(getSelectedPrincipal());

              } catch (AdminException e) {
                String description = Bundle.getMessage(Bundle.EDITING);
                Log.error(
                    MessageFormat.format(
                        Bundle.getMessage(Bundle.ERROR_HANDLING_PRINCIPAL),
                        new String[] {description}),
                    e);
              }
            }
          }
        });

    this.add(scrollpane, BorderLayout.CENTER);
  }
  public OpenDecisionsPanel() {
    odList_ = new Vector<List<String>>();
    snList_ = new Vector<Integer>();
    ledList_ = new Vector<String>();

    currentIdx_ = -1;

    labelTotal_ = new JLabel(makeLabelTotal(), SwingConstants.CENTER);
    labelCurrent_ = new JLabel(makeLabelCurrent(), SwingConstants.CENTER);
    JPanel btnPanel = new JPanel(new FlowLayout());

    btnPrev_ = new JButton("<<");
    btnPrev_.addActionListener(this);
    btnPrev_.setActionCommand("prev");
    btnNext_ = new JButton(">>");
    btnNext_.addActionListener(this);
    btnNext_.setActionCommand("next");
    checkButtons();
    JButton btn;
    btn = new JButton("Go To Step");
    btn.addActionListener(this);
    btn.setActionCommand("goto");

    gotoIdx_ = new JTextField(6);
    btnPanel.add(btnPrev_);
    btnPanel.add(btnNext_);
    btnPanel.add(btn);
    btnPanel.add(gotoIdx_);

    lastExecutedDecision_ = new JTextArea(5, 10);
    lastExecutedDecision_.setLineWrap(true);

    JPanel topPanel = new JPanel(new BorderLayout());
    JPanel p = new JPanel(new GridLayout(3, 1));
    p.add(labelTotal_);
    p.add(btnPanel);
    p.add(new JLabel("Last Executed Decision", SwingConstants.CENTER));

    ledTable_ = new JTable();
    ledTable_.setTableHeader(null);
    ledTable_.setPreferredScrollableViewportSize(new Dimension(500, 70));

    JTabbedPane tp = new JTabbedPane();
    tp.addTab("As Table", new JScrollPane(ledTable_));
    tp.addTab("As Text", new JScrollPane(lastExecutedDecision_));

    topPanel.add(BorderLayout.NORTH, p);
    topPanel.add(BorderLayout.CENTER, tp);
    odTable_ = new JTable(Util.makeTableModel(odList_, new String[] {"toString"}));
    odTable_.setTableHeader(null);
    odTable_.setPreferredScrollableViewportSize(new Dimension(500, 70));

    setLayout(new BorderLayout());
    add(BorderLayout.NORTH, topPanel);

    JPanel odPanel = new JPanel(new BorderLayout());
    odPanel.add(BorderLayout.NORTH, labelCurrent_);
    odPanel.add(BorderLayout.CENTER, new JScrollPane(odTable_));
    add(BorderLayout.CENTER, odPanel);
  }