Ejemplo n.º 1
0
 public void install() {
   classTable.setModel(this);
   classTable.setDefaultRenderer(Object.class, renderer);
   classTable.setDefaultRenderer(
       Integer.class, new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
   classTable.setDefaultEditor(Object.class, editor);
   classComboBox.addItemListener(this);
   classComboBox.addPropertyChangeListener("model", this);
 }
Ejemplo n.º 2
0
  public static void customize(JTable summariesTable) {

    summariesTable.setDefaultRenderer(Date.class, new DateCellRenderer());
    summariesTable.setDefaultRenderer(Piece.class, new PieceRenderer());
    BarCellRenderer.setForTable(summariesTable);

    final int preferredColWidths[] = {140, 35, 140, 100, 75, 50, 50, 50, 50, 40};
    final int maxColWidths[] = {0, 35, 150, 0, 75, 50, 50, 50, 50, 40};
    final int minColWidths[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    TableUtil.setColumnWidths(
        preferredColWidths, maxColWidths, minColWidths, summariesTable.getColumnModel(), null);
  }
Ejemplo n.º 3
0
  public TicketListView() {
    table = new TicketListTable();
    table.setModel(tableModel = new TicketListTableModel());
    table.setRowHeight(40);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    table.setDefaultRenderer(Object.class, new PosTableRenderer());
    table.setGridColor(Color.LIGHT_GRAY);

    TableColumnModel columnModel = table.getColumnModel();
    columnModel.getColumn(0).setPreferredWidth(20);
    columnModel.getColumn(1).setPreferredWidth(20);
    columnModel.getColumn(2).setPreferredWidth(200);
    columnModel.getColumn(3).setPreferredWidth(100);

    JScrollPane scrollPane =
        new JScrollPane(
            table,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    JScrollBar scrollBar = scrollPane.getVerticalScrollBar();
    scrollBar.setPreferredSize(new Dimension(30, 60));

    setLayout(new BorderLayout());

    add(scrollPane);
  }
Ejemplo n.º 4
0
  /**
   * Set the current open DarwinCSV. You should really, really, really setCurrentCSV(null) before
   * you load a new DarwinCSV.
   *
   * @param csv The new DarwinCSV object.
   */
  private void setCurrentCSV(DarwinCSV csv) {
    // Clear the old currentCSV object and matchAgainst object.
    currentCSV = null;
    matchAgainst(null);

    // Load the new currentCSV object.
    currentCSV = csv;
    table.removeAll();
    table.setDefaultRenderer(Name.class, this);

    // Set the currentCSV
    // TODO: This causes an exception occasionally, because we shouldn't
    // be calling setModel outside of the Event Queue thread; however, we're
    // currently in a worker thread, so dipping back into the Event thread
    // would just cause more problems. Sorry!
    if (csv != null) {
      table.setModel(currentCSV.getRowIndex());
    } else {
      table.setModel(blankDataModel);
    }

    columnInfoPanel.loadedFileChanged(csv);
    columnInfoPanel.columnChanged(-1);
    table.repaint();
  }
Ejemplo n.º 5
0
  /**
   * Initialisiere den unteren Bereichs des Benchmark-Panels mit einer Tabelle von Schätzungen und
   * Vorhersagen.
   */
  private void initTablePane() {
    JPanel tablePane = new JPanel(new GridLayout(1, 1));
    tablePane.add(new JScrollPane(benchmarkTable));
    benchmarkTable.setDefaultRenderer(Object.class, new BenchmarkTableCellRenderer());
    benchmarkTable.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);

            int selRowIndex = benchmarkTable.getSelectedRow();
            int selColIndex = benchmarkTable.getSelectedColumn();

            String user = (String) benchmarkTableModel.getValueAt(selRowIndex, 0);

            if (selColIndex == 0) {
              new UserStatsWindow(user).setVisible(true);
              return;
            }

            Object cellVal = benchmarkTableModel.getValueAt(selRowIndex, selColIndex);
            if (!(cellVal instanceof String)) {
              return;
            }
            String repoName = (String) cellVal;

            Project p = new Project(user, repoName);
            if (metricsData.containsKey(p)) {
              new ProjectMetricsWindow(metricsData.get(p)).setVisible(true);
            }
          }
        });
    add(tablePane, BorderLayout.CENTER);
  }
Ejemplo n.º 6
0
  /**
   * Constructs a <code>Table</code>.
   *
   * @param name the Name given to the main component.
   * @param latency the latency rate.
   */
  public Table(String name, long latency) {
    noInstances++;
    setName(name);

    // Creates the table model.
    model = new TableModel(this, latency);

    // Defines the DefaultTableCellRenderer.
    tableCellRenderer = new TableCellRenderer();

    // JTable settings.
    table = new JTable(model);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // Uses a scrollbar.
    table.setDefaultRenderer(Object.class, new TableCellRenderer());

    // JScrollPane settings.
    setViewportView(table);
    setPreferredSize(new Dimension(20, 400));

    // Add a ColumnAddedListener.
    table.getColumnModel().addColumnModelListener(new ColumnAddedListener());

    // Add a RowAddedListener.
    table.addComponentListener(new RowAddedListener());

    // Adjusts the preferred size on the EndRun event.
    Listener<EndRun> endRunListener =
        new Listener<EndRun>() {

          public void onEvent(EndRun event) {
            Table.this.adjustPreferredSize();
          }
        };
    EventManager.getInstance().add(EndRun.class, endRunListener);
  }
  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);
  }
Ejemplo n.º 8
0
 public HostList() {
   table.setModel(tm);
   table.setDefaultRenderer(Object.class, tr);
   table.setFillsViewportHeight(true);
   table.setShowVerticalLines(false);
   setViewportView(table);
 }
Ejemplo n.º 9
0
 private JComponent createStatisticsComponent(StatisticsTableModel testStatisticsModel) {
   JTable statisticsTable = new JBTable(testStatisticsModel);
   statisticsTable.setDefaultRenderer(TestStatisticsRow.class, new StatisticsRowRenderer());
   JPanel tablePanel = new JPanel(new GridLayout(1, 1));
   tablePanel.add(new JBScrollPane(statisticsTable));
   return tablePanel;
 }
Ejemplo n.º 10
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);
  }
  private void init(String title) {
    diag = new JDialog(frame, title, false);

    preview = new PreviewPanel(null, new MetaData(), Globals.prefs.get("preview1"));

    sortedEntries =
        new SortedList<BibtexEntry>(entries, new EntryComparator(false, true, "author"));
    model = new EventTableModel<BibtexEntry>(sortedEntries, new EntryTableFormat());
    entryTable = new JTable(model);
    GeneralRenderer renderer = new GeneralRenderer(Color.white);
    entryTable.setDefaultRenderer(JLabel.class, renderer);
    entryTable.setDefaultRenderer(String.class, renderer);
    setWidths();
    TableComparatorChooser<BibtexEntry> tableSorter =
        new TableComparatorChooser<BibtexEntry>(
            entryTable, sortedEntries, TableComparatorChooser.MULTIPLE_COLUMN_KEYBOARD);
    setupComparatorChooser(tableSorter);
    JScrollPane sp = new JScrollPane(entryTable);

    EventSelectionModel<BibtexEntry> selectionModel =
        new EventSelectionModel<BibtexEntry>(sortedEntries);
    entryTable.setSelectionModel(selectionModel);
    selectionModel.getSelected().addListEventListener(new EntrySelectionListener());
    entryTable.addMouseListener(new TableClickListener());

    contentPane.setTopComponent(sp);
    contentPane.setBottomComponent(preview);

    // Key bindings:
    AbstractAction closeAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            diag.dispose();
          }
        };
    ActionMap am = contentPane.getActionMap();
    InputMap im = contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.prefs.getKey("Close dialog"), "close");
    am.put("close", closeAction);

    diag.addWindowListener(
        new WindowAdapter() {
          public void windowOpened(WindowEvent e) {
            contentPane.setDividerLocation(0.5f);
          }

          public void windowClosing(WindowEvent event) {
            Globals.prefs.putInt("searchDialogWidth", diag.getSize().width);
            Globals.prefs.putInt("searchDialogHeight", diag.getSize().height);
          }
        });

    diag.getContentPane().add(contentPane, BorderLayout.CENTER);
    // Remember and default to last size:
    diag.setSize(
        new Dimension(
            Globals.prefs.getInt("searchDialogWidth"), Globals.prefs.getInt("searchDialogHeight")));
    diag.setLocationRelativeTo(frame);
  }
Ejemplo n.º 12
0
 private JTable getImagesTable() {
   if (imagesTable == null) {
     imagesTable = new JTable(this.getImagesTableModel());
     imagesTable.setDefaultRenderer(
         String.class, getImagesTableModel().new StatusBrokenResourceWarningCellRenderer());
   }
   return imagesTable;
 }
Ejemplo n.º 13
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());
 }
Ejemplo n.º 14
0
  public ClassExpTable(
      AxiomIndexer indexer,
      ConcisePlainVisitor visitor,
      HashedCounts classExpCounts,
      Hashtable classExpDepths) {
    this.myIndexer = indexer;
    String[] colNames = {"Class Expression", "#Occurences", "Depth", "Score"};

    Object[][] data = new Object[classExpCounts.keySet().size()][4];

    int i = 0;
    for (Iterator it = classExpCounts.keySet().iterator(); it.hasNext(); ) {
      OWLDescription desc = (OWLDescription) it.next();
      if (desc == null) System.out.println("description is null at " + i);
      Integer count = new Integer(classExpCounts.getCount(desc));
      Integer depth = (Integer) classExpDepths.get(desc);
      try {
        if (depth == null) {
          System.out.println(" depth is null at " + i);
          desc.accept(visitor);
          String str = visitor.result();
          System.out.println("        [" + str + "]");
          visitor.reset();
        }
      } catch (Exception e) {
        e.printStackTrace();
      }

      data[i][0] = desc;
      data[i][1] = count;
      data[i][2] = depth;
      data[i][3] = new Double(Math.pow(count.intValue(), (depth.intValue() + 1)));
      i++;
    }
    myDataModel = new ClassExpTableModel(colNames, data);
    myManipModel = new TableSorter(myDataModel);
    myTable = new JTable(myManipModel);
    myManipModel.setTableHeader(myTable.getTableHeader());

    /*
    for ( int vColIndex = 0; vColIndex < 3; vColIndex++ )
    {
    	TableColumn col = myTable.getColumnModel().getColumn(vColIndex);
    	col.setHeaderRenderer(new RichHeaderRenderer());
    }
    */

    myTable.setDefaultRenderer(OWLObjectImpl.class, new ClassExpRenderer(visitor));

    setupUI();

    this.addWindowListener(this);
    this.addComponentListener(this);
    myTable.addMouseListener(this);
    this.setSize(300, 600);
    this.setVisible(true);
  }
Ejemplo n.º 15
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());
  }
Ejemplo n.º 16
0
 void init() {
   updateTableContent();
   table.setModel(myTable);
   table.setDefaultRenderer(JButton.class, new ComboBoxCellRenderer());
   JScrollPane scrollPane = new JScrollPane(table);
   setLayout(new BorderLayout());
   add(scrollPane, BorderLayout.CENTER);
   table.setVisible(true);
   addHandler();
 }
Ejemplo n.º 17
0
  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;
  }
Ejemplo n.º 18
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);
          }
        });
  }
Ejemplo n.º 19
0
  private void setupTab() {

    // The chat area
    BorderLayout chatLayout = new BorderLayout();
    JPanel chatWrapper = new JPanel(chatLayout);

    chatLog = new JTextPane();
    chatLog.setEditable(false);
    chatLog.setDocument(new ChatDocument());
    chatLogScrollPane = new JScrollPane(chatLog);
    chatLogScrollPane.addMouseListener(this);

    chatWrapper.add(chatLogScrollPane, BorderLayout.CENTER);

    // The send message panel
    message = new JTextArea();
    message.addMouseListener(this);
    message.addKeyListener(this);
    messageScrollPane = new JScrollPane(message);
    message.setLineWrap(true);
    message.setWrapStyleWord(true);
    message.requestFocus();
    message.setDocument(new JTextFieldLimit(512));

    sendMessage = new JButton("Send", frame.getGui().getUtil().getImage("sendmessage"));
    sendMessage.addMouseListener(this);
    sendMessage.addActionListener(this);

    chatMessagePanel = new JPanel();
    chatMessagePanel.setLayout(new BoxLayout(chatMessagePanel, BoxLayout.X_AXIS));
    chatMessagePanel.add(messageScrollPane);
    chatMessagePanel.add(sendMessage);

    chatWrapper.add(chatMessagePanel, BorderLayout.PAGE_END);

    // Setup the avatars
    avatarTable = new JTable(new AvatarTableModel(indexNode));
    avatarTable.addMouseListener(this);
    avatarTable.setTableHeader(null);
    avatarTable.setDefaultRenderer(Object.class, new AvatarRenderer(frame));
    avatarTable.setRowHeight(70);
    avatarScrollPane = new JScrollPane(avatarTable);
    avatarScrollPane.setMaximumSize(new Dimension(200, -1));
    avatarScrollPane.setPreferredSize(new Dimension(200, -1));

    // Add all to parent
    BorderLayout pageLayout = new BorderLayout();

    this.setLayout(pageLayout);
    this.add(avatarScrollPane, BorderLayout.LINE_END);
    this.add(chatWrapper, BorderLayout.CENTER);

    // Set the status
    active = true;
  }
Ejemplo n.º 20
0
  public static void refreshCalendar(int month, int year) {
    // instantiation
    String[] months = {
      "January",
      "February",
      "March",
      "April",
      "May",
      "June",
      "July",
      "August",
      "September",
      "October",
      "November",
      "December"
    };
    int numoday, startom; // Number Of Days, Start Of Month

    // Allow/disallow buttons
    prev.setEnabled(true);
    next.setEnabled(true);
    if (month == 0 && year <= ryear) {
      prev.setEnabled(false);
    } // Cannot set an appointment back in time
    if (month == 11 && year >= ryear + 50) {
      next.setEnabled(false);
    } // Too early to set an appointment
    lmonth.setText(months[month]); // Refresh the month label (at the top)
    lmonth.setBounds(
        160 - lmonth.getPreferredSize().width / 2, 25, 180, 25); // Re-align label with calendar
    cyear.setSelectedItem(String.valueOf(year)); // Select the correct year in the combo box

    // deletes current table
    for (int i = 0; i < 6; i++) {
      for (int j = 0; j < 7; j++) {
        mcal.setValueAt(null, i, j);
      }
    }

    // Get first day of month and number of days
    GregorianCalendar cal = new GregorianCalendar(year, month, 1);
    numoday = cal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH);
    startom = cal.get(GregorianCalendar.DAY_OF_WEEK);

    // Create calendar
    for (int i = 1; i <= numoday; i++) {
      int row = new Integer((i + startom - 2) / 7);
      int column = (i + startom - 2) % 7;
      mcal.setValueAt(i, row, column);
    }

    // Apply renderers
    Cal.setDefaultRenderer(Cal.getColumnClass(0), new tblCalendarRenderer());
  }
Ejemplo n.º 21
0
  public COptionsPanel(final DebuggerOptions options) {
    super(new BorderLayout());

    add(new JLabel("Debugger options overview"), BorderLayout.NORTH);

    final JTable table = new JTable(new CMissingOptionsTableModel(options));

    table.setDefaultRenderer(Object.class, new COptionRenderer());

    add(new JScrollPane(table), BorderLayout.CENTER);
  }
Ejemplo n.º 22
0
  final TableModel refreshImageTable() {

    final ScreenshotComponent screenshotter = new ScreenshotComponent();
    final Window window = SwingUtilities.getWindowAncestor(jpc);
    final List<JComponent> comps =
        GraphicsUtil.getComponentsBeneath(
            (JComponent) (((JFrame) window).getContentPane()), (Class<?>) JParCoord.class, true);
    comps.addAll(
        GraphicsUtil.getComponentsBeneath(
            (JComponent) (((JFrame) window).getContentPane()),
            (Class<?>) JScatterPlotPanel.class,
            true));

    final DefaultTableModel tModel =
        new DefaultTableModel() {
          /** */
          private static final long serialVersionUID = -5784412665270634785L;

          final Class<?>[] classArray = {
            JComponent.class, String.class, BufferedImage.class, Boolean.class
          };

          public Class<?> getColumnClass(final int columnIndex) {
            if (columnIndex >= 0 && columnIndex < classArray.length) {
              return classArray[columnIndex];
            }
            return Object.class;
          }
        };

    final String[] imageTableColumnNames = new String[4];
    imageTableColumnNames[0] = "Comp Hidden";
    for (int imageCol = 1; imageCol < imageTableColumnNames.length; imageCol++) {
      imageTableColumnNames[imageCol] = Messages.getString("ImageTableColumn" + imageCol);
    }
    tModel.setColumnIdentifiers(imageTableColumnNames);
    for (int index = 0; index < comps.size(); index++) {
      final BufferedImage image = screenshotter.captureComponentImage(comps.get(index), 0.25f);
      final Object[] rowData =
          new Object[] {
            comps.get(index),
            comps.get(index).getName(),
            new EdgeInstance(null, null, image),
            Boolean.TRUE
          };
      tModel.addRow(rowData);
    }

    imageTable.setModel(tModel);
    imageTable.removeColumn(imageTable.getColumnModel().getColumn(0));
    imageTable.setDefaultRenderer(BufferedImage.class, new ImageRenderer());

    return tModel;
  }
Ejemplo n.º 23
0
  public static void refreshCalendar(int month, int year) {
    // Variables
    String[] months = {
      "January",
      "February",
      "March",
      "April",
      "May",
      "June",
      "July",
      "August",
      "September",
      "October",
      "November",
      "December"
    };
    int nod, som; // Number Of Days, Start Of Month

    // Allow/disallow buttons
    btnPrev.setEnabled(true);
    btnNext.setEnabled(true);
    if (month == 0 && year <= realYear - 10) {
      btnPrev.setEnabled(false);
    } // Too early
    if (month == 11 && year >= realYear + 100) {
      btnNext.setEnabled(false);
    } // Too late
    lblMonth.setText(months[month]); // Refresh the month label (at the top)
    lblMonth.setBounds(
        160 - lblMonth.getPreferredSize().width / 2, 25, 180, 25); // Re-align label with calendar
    cmbYear.setSelectedItem(String.valueOf(year)); // Select the correct year in the combo box

    // Clear table
    for (int i = 0; i < 6; i++) {
      for (int j = 0; j < 7; j++) {
        mtblCalendar.setValueAt(null, i, j);
      }
    }

    // Get first day of month and number of days
    GregorianCalendar cal = new GregorianCalendar(year, month, 1);
    nod = cal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH);
    som = cal.get(GregorianCalendar.DAY_OF_WEEK);

    // Draw calendar
    for (int i = 1; i <= nod; i++) {
      int row = new Integer((i + som - 2) / 7);
      int column = (i + som - 2) % 7;
      mtblCalendar.setValueAt(i, row, column);
    }

    // Apply renderers
    tblCalendar.setDefaultRenderer(tblCalendar.getColumnClass(0), new tblCalendarRenderer());
  }
Ejemplo n.º 24
0
  NodeStatusTableModel(SpauldingApp spauldingGUI, JTable table) {
    assert (spauldingGUI != null && table != null);
    this.table = table;
    this.spauldingApp = spauldingGUI;

    // set custom renderers
    table.setDefaultRenderer(
        new LastRequestCellRendererClass().getClass(), new LastRequestCellRenderer());

    this.initColumnWidths(table);
    updateNodes();
  }
Ejemplo n.º 25
0
 /**
  * Service method to setup a column so that it will hold a button for it's values
  *
  * @param table {@link JTable} to use
  * @param column Column to setup
  * @param sample Typical button, used for size
  */
 protected void setColumnToHoldButton(JTable table, int column, JButton sample) {
   // install a button renderer & editor
   ButtonRenderer buttonRenderer = new ButtonRenderer();
   table.setDefaultRenderer(JButton.class, buttonRenderer);
   TableCellEditor buttonEditor = new ButtonEditor(new JButton());
   table.setDefaultEditor(JButton.class, buttonEditor);
   // ensure the table rows, columns have enough room for buttons
   table.setRowHeight(sample.getPreferredSize().height);
   table
       .getColumnModel()
       .getColumn(column)
       .setPreferredWidth((sample.getPreferredSize().width) + 4);
 }
Ejemplo n.º 26
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 + ")");
  }
Ejemplo n.º 27
0
  protected JTable createTable() {
    JTable table = new JTable();

    table.setUI(new ITunesTableUI());
    TableCellRenderer defaultRenderer = table.getDefaultRenderer(Object.class);

    MessageFormatTableCell intValueCell =
        new MessageFormatTableCell(new DecimalFormat("#,##0"), defaultRenderer);
    intValueCell.getRendererView().setHorizontalAlignment(SwingConstants.RIGHT);
    table.setDefaultRenderer(Integer.class, intValueCell);
    table.getTableHeader().setReorderingAllowed(true);

    return table;
  }
  public void init() {
    setTitle("Expression Property Metadata Editor");
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    expressionsTableModel = new EditableMetaDataTableModel();
    expressionsTable = new JTable(expressionsTableModel);
    expressionsTable.setDefaultRenderer(String.class, new EditableMetaDataRenderer());

    final JPanel contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(new JScrollPane(expressionsTable), BorderLayout.CENTER);
    setContentPane(contentPane);
    setSize(800, 600);
  }
Ejemplo n.º 29
0
  private void init() {
    setLayout(new BorderLayout());

    tableModel = new NotesTableModel(getCharacter());
    table = new JTable(tableModel);
    table.setRowHeight(50);
    tableModel.updateColumns(table);
    table.setDefaultRenderer(String.class, new NotesCellRenderer());
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                updateControls();
              }
            });

    add(new JScrollPane(table), "Center");

    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    addNoteButton = new JButton("Add Custom");
    addNoteButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            String note = JOptionPane.showInputDialog("Custom Note");
            getCharacter().addNote(getGameHandler().getClient().getClientName(), "Custom", note);
            updatePanel();
          }
        });
    box.add(addNoteButton);
    box.add(Box.createHorizontalGlue());
    deleteNoteButton = new JButton("Delete Custom");
    deleteNoteButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            Note note = getSelectedNote();
            if (note != null) {
              getCharacter().deleteNote(note.getId());
              updatePanel();
            }
          }
        });
    box.add(deleteNoteButton);
    box.add(Box.createHorizontalGlue());
    add(box, "South");

    updateControls();
  }
Ejemplo n.º 30
0
  // Initializing this component.
  private void jbInit() {
    callStackTable.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            callStackTable_focusGained(e);
          }

          public void focusLost(FocusEvent e) {
            callStackTable_focusLost(e);
          }
        });
    callStackTable.setTableHeader(null);
    callStackTable.setDefaultRenderer(callStackTable.getColumnClass(0), getCellRenderer());
    scrollPane = new JScrollPane(callStackTable);
    setVisibleRows(DEFAULT_VISIBLE_ROWS);
    scrollPane.setLocation(0, 27);
    setBorder(BorderFactory.createEtchedBorder());
    // this.setLayout(null);
    this.setLayout(new GridBagLayout());
    nameLbl.setText("Call Stack");
    nameLbl.setBounds(new Rectangle(3, 4, 70, 23));
    nameLbl.setFont(Utilities.labelsFont);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 7;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.PAGE_END;
    c.gridx = 0;
    c.gridy = 2;
    this.add(scrollPane, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 0.0;
    c.gridwidth = 3;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(5, 0, 0, 0);
    this.add(nameLbl, c);
  }