Java Code Examples for javax.swing.JTable#setModel()

The following examples show how to use javax.swing.JTable#setModel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JtableUtils.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 6 votes vote down vote up
/**
 * Adding column is done by creating new model by modifying older one.<p>
 *
 * Insert new column if column is outside the <code>limit</code> Adds new
 * column if selected column inside the <code>limit</code>table@param _table
 * target table
 *
 * @param limit the range to avoid inserting
 */
static void addcol(JTable table, int limit) {
    try {
        int sc = table.getSelectedColumn();
        if (sc < limit - 1) {
            sc = table.getColumnCount() - 1;
        }

        DefaultTableModel tableM = (DefaultTableModel) table.getModel();
        DefaultTableModel tableM1 = new DefaultTableModel();
        TableModelListener[] listeners = tableM.getTableModelListeners();

        tableM1.setDataVector(newvectoraddcol(tableM.getDataVector(), sc), getColumnIdentifiersaddcol(sc + 1, table));
        table.setModel(tableM1);
        for (TableModelListener l : listeners) {
            tableM1.addTableModelListener(l);
        }

    } catch (Exception ex) {
        Logger.getLogger(JtableUtils.class.getName()).log(Level.SEVERE, null, ex);
    }

}
 
Example 2
Source File: AccountsListWindow.java    From ethereumj with MIT License 6 votes vote down vote up
public AccountsListWindow() {
	java.net.URL url = ClassLoader.getSystemResource("ethereum-icon.png");
       Toolkit kit = Toolkit.getDefaultToolkit();
       Image img = kit.createImage(url);
       this.setIconImage(img);
       setTitle("Accounts List");
       setSize(700, 500);
       setLocation(50, 180);
       setResizable(false);
       
       JPanel panel = new JPanel();
       getContentPane().add(panel);
       
       tblAccountsDataTable = new JTable();
       
       adapter = new AccountsDataAdapter(new ArrayList<DataClass>());
       tblAccountsDataTable.setModel(adapter);
       
       JScrollPane scrollPane = new JScrollPane(tblAccountsDataTable);
       scrollPane.setPreferredSize(new Dimension(680,490));
       panel.add(scrollPane);
    
       loadAccounts();
}
 
Example 3
Source File: TableUtils.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static JScrollPane createToggleButtonSelectionPane(JTable table, JTable rowheaderTable,
	JToggleButton button)
{
	rowheaderTable.setAutoCreateColumnsFromModel(false);
	// force the tables to share models
	rowheaderTable.setModel(table.getModel());
	rowheaderTable.setSelectionModel(table.getSelectionModel());
	rowheaderTable.setRowHeight(table.getRowHeight());
	rowheaderTable.setIntercellSpacing(table.getIntercellSpacing());
	rowheaderTable.setShowGrid(false);
	rowheaderTable.setFocusable(false);

	TableColumn column = new TableColumn(-1);
	column.setHeaderValue(new Object());
	column.setCellRenderer(new TableCellUtilities.ToggleButtonRenderer(button));
	rowheaderTable.addColumn(column);
	rowheaderTable.setPreferredScrollableViewportSize(new Dimension(20, 0));

	JScrollPane scrollPane = new JScrollPane();
	scrollPane.setViewportView(table);
	scrollPane.setRowHeaderView(rowheaderTable);
	return scrollPane;
}
 
Example 4
Source File: TableUtils.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public static void setupTable(JTable table, int selectionModel, TableModel model, MouseListener mouseListener,
                              int... colWidth) {
  table.setFillsViewportHeight(true);
  table.setFont(StyleConstants.FONT_MONOSPACE_LARGE);
  table.setRowHeight(StyleConstants.TABLE_ROW_HEIGHT_DEFAULT);
  table.setShowHorizontalLines(true);
  table.setShowVerticalLines(false);
  table.setGridColor(Color.lightGray);
  table.getColumnModel().setColumnMargin(StyleConstants.TABLE_COLUMN_MARGIN_DEFAULT);
  table.setRowMargin(StyleConstants.TABLE_ROW_MARGIN_DEFAULT);
  table.setSelectionMode(selectionModel);
  if (model != null) {
    table.setModel(model);
  } else {
    table.setModel(new DefaultTableModel());
  }
  if (mouseListener != null) {
    table.removeMouseListener(mouseListener);
    table.addMouseListener(mouseListener);
  }
  for (int i = 0; i < colWidth.length; i++) {
    table.getColumnModel().getColumn(i).setMinWidth(colWidth[i]);
    table.getColumnModel().getColumn(i).setMaxWidth(colWidth[i]);
  }
}
 
Example 5
Source File: ShowUsagesAction.java    From dagger-intellij-plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
private static MyModel setTableModel(@NotNull JTable table, @NotNull UsageViewImpl usageView,
    @NotNull final List<UsageNode> data) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  final int columnCount = calcColumnCount(data);
  MyModel model = table.getModel() instanceof MyModel ? (MyModel) table.getModel() : null;
  if (model == null || model.getColumnCount() != columnCount) {
    model = new MyModel(data, columnCount);
    table.setModel(model);

    ShowUsagesTableCellRenderer renderer = new ShowUsagesTableCellRenderer(usageView);
    for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) {
      TableColumn column = table.getColumnModel().getColumn(i);
      column.setCellRenderer(renderer);
    }
  }
  return model;
}
 
Example 6
Source File: TableUtils.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static JScrollPane createToggleButtonSelectionPane(JTable table, JTable rowheaderTable,
	JToggleButton button)
{
	rowheaderTable.setAutoCreateColumnsFromModel(false);
	// force the tables to share models
	rowheaderTable.setModel(table.getModel());
	rowheaderTable.setSelectionModel(table.getSelectionModel());
	rowheaderTable.setRowHeight(table.getRowHeight());
	rowheaderTable.setIntercellSpacing(table.getIntercellSpacing());
	rowheaderTable.setShowGrid(false);
	rowheaderTable.setFocusable(false);

	TableColumn column = new TableColumn(-1);
	column.setHeaderValue(new Object());
	column.setCellRenderer(new TableCellUtilities.ToggleButtonRenderer(button));
	rowheaderTable.addColumn(column);
	rowheaderTable.setPreferredScrollableViewportSize(new Dimension(20, 0));

	JScrollPane scrollPane = new JScrollPane();
	scrollPane.setViewportView(table);
	scrollPane.setRowHeaderView(rowheaderTable);
	return scrollPane;
}
 
Example 7
Source File: PurchaseModeFrame.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void renewAbilityScoreCostTable()
{
	JTable abilityScoreCostTable = new JTable();

	abilityScoreCostTable.setBorder(new BevelBorder(BevelBorder.LOWERED));
	abilityScoreCostTable.setModel(purchaseModel);
	abilityScoreCostTable.setToolTipText(LanguageBundle.getString("in_Prefs_setCost")); //$NON-NLS-1$
	jScrollPane1.setViewportView(abilityScoreCostTable);
}
 
Example 8
Source File: RegistrationExplorerPanel.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
public void initComponent( final ViewRegistrations viewRegistrations )
{
	tableModel = new RegistrationTableModel( viewRegistrations, this );

	table = new JTable();
	table.setModel( tableModel );
	table.setSurrendersFocusOnKeystroke( true );
	table.setSelectionMode( ListSelectionModel.SINGLE_INTERVAL_SELECTION );
	
	final DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
	centerRenderer.setHorizontalAlignment( JLabel.CENTER );
	
	// center all columns
	for ( int column = 0; column < tableModel.getColumnCount(); ++column )
		table.getColumnModel().getColumn( column ).setCellRenderer( centerRenderer );

	table.setPreferredScrollableViewportSize( new Dimension( 1020, 300 ) );
	table.getColumnModel().getColumn( 0 ).setPreferredWidth( 300 );
	for ( int i = 1; i < table.getColumnCount(); ++i )
		table.getColumnModel().getColumn( i ).setPreferredWidth( 100 );
	final Font f = table.getFont();
	
	table.setFont( new Font( f.getName(), f.getStyle(), 11 ) );
	
	this.setLayout( new BorderLayout() );
	this.label = new JLabel( "View Description --- " );
	this.add( label, BorderLayout.NORTH );
	this.add( new JScrollPane( table ), BorderLayout.CENTER );
	
	addPopupMenu( table );
}
 
Example 9
Source File: TableDisplayer.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public JBundleTable()
{
  setLayout(new BorderLayout());

  table = new JTable() {
    private static final long serialVersionUID = 1L;

    @Override
    public Color getGridColor()
    {
      return getBackground().darker();
    }
  };

  modelSorted.addMouseListenerToHeaderInTable(table);
  table.setModel(modelSorted);
  table.setSelectionModel(rowSM);

  // Dimension size = new Dimension(500, 300);
  // scroll.setPreferredSize(size);

  final DefaultTableCellRenderer rightAlign =
    new DefaultTableCellRenderer();
  rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);

  table.getColumnModel().getColumn(COL_ID).setCellRenderer(rightAlign);
  table.getColumnModel().getColumn(COL_STARTLEVEL)
      .setCellRenderer(rightAlign);

  setColumnWidth();

  final JScrollPane scroll = new JScrollPane(table);
  add(scroll, BorderLayout.CENTER);
}
 
Example 10
Source File: ScoresRankingFrame.java    From StudentSystem with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param owner ���ĸ�����
 * @param title ������
 * @param modal ָ����ģʽ���ڣ����з�ģʽ����
 */
public ScoresRankingFrame(JDialog owner, String title, boolean modal,ScoreAnalyzeModel model){
	super(owner, title, modal);
	jt = new JTable();
	jsp = new JScrollPane(jt);
	jt.setModel(model);
	jsp.setBounds(20, 20, 860, 460);
	this.add(jsp);
	
	this.setSize(1000,500);
	WindowUtil.setFrameCenter(this);
	this.setResizable(false);
	this.setVisible(true);
}
 
Example 11
Source File: TreeConnectorsView.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
private void addTab(JTabbedPane tabs, String title, TargetsTableModel model) {
	JTable table = new Table();
	table.setModel(model);
	JScrollPane jsp = new JScrollPane(table);
	jsp.setPreferredSize(new Dimension(500, 500));
	tabs.addTab(title, jsp);
}
 
Example 12
Source File: AppFrame.java    From HBaseClient with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 初始化查询结果集列表的数据模型
 */
public void initTableModel()
{
    List<?> v_Titles = (List<?>)XJava.getObject("titles");
    this.tableModel = new DefaultTableModel();
    
    for (int v_ColIndex=0; v_ColIndex<v_Titles.size(); v_ColIndex++)
    {
        this.tableModel.addColumn(v_Titles.get(v_ColIndex));
    }
    
    
    JTable v_xtDataList = (JTable)XJava.getObject("xtDataList");
    v_xtDataList.setModel(this.tableModel);
    
    
    List<?> v_Titles_Size    = (List<?>)XJava.getObject("titles_Size");
    List<?> v_Titles_MaxSize = (List<?>)XJava.getObject("titles_MaxSize");
    for (int v_ColIndex=0; v_ColIndex<v_Titles_Size.size(); v_ColIndex++)
    {
        int v_Size    = Integer.parseInt(v_Titles_Size   .get(v_ColIndex).toString());
        int v_MaxSize = Integer.parseInt(v_Titles_MaxSize.get(v_ColIndex).toString());
        
        v_xtDataList.getColumnModel().getColumn(v_ColIndex).setMinWidth(v_Size);
        if ( v_MaxSize >= 0 )
        {
            v_xtDataList.getColumnModel().getColumn(v_ColIndex).setPreferredWidth(v_MaxSize);
        }
        
        v_xtDataList.getColumnModel().getColumn(v_ColIndex).setCellRenderer(new ResultCellRenderer());
    }
}
 
Example 13
Source File: VendorOptionInfoPanel.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/** Creates the UI. */
private void createUI() {
    setLayout(new BorderLayout());

    JScrollPane scrollPane = new JScrollPane();
    add(scrollPane, BorderLayout.CENTER);

    vendorOptionTable = new JTable();
    scrollPane.setViewportView(vendorOptionTable);
    vendorOptionTable.setModel(model);
    vendorOptionTable
            .getColumnModel()
            .getColumn(0)
            .setCellRenderer(new VendorOptionInfoCellRenderer(model));
    vendorOptionTable
            .getColumnModel()
            .getColumn(1)
            .setCellRenderer(new VendorOptionInfoCellRenderer(model));
    vendorOptionTable
            .getSelectionModel()
            .addListSelectionListener(
                    new ListSelectionListener() {

                        @Override
                        public void valueChanged(ListSelectionEvent e) {
                            displayDescription(vendorOptionTable.getSelectedRow());
                        }
                    });

    descriptionArea = new JTextArea();
    descriptionArea.setEditable(false);
    descriptionArea.setRows(5);
    descriptionArea.setLineWrap(true);
    descriptionArea.setWrapStyleWord(true);
    descriptionArea.setFont(vendorOptionTable.getFont());
    JScrollPane descriptionAreaScrollPane = new JScrollPane(descriptionArea);
    add(descriptionAreaScrollPane, BorderLayout.EAST);
    descriptionAreaScrollPane.setPreferredSize(new Dimension(200, 100));
}
 
Example 14
Source File: PurchaseModeFrame.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void renewAbilityScoreCostTable()
{
	JTable abilityScoreCostTable = new JTable();

	abilityScoreCostTable.setBorder(new BevelBorder(BevelBorder.LOWERED));
	abilityScoreCostTable.setModel(purchaseModel);
	abilityScoreCostTable.setToolTipText(LanguageBundle.getString("in_Prefs_setCost")); //$NON-NLS-1$
	jScrollPane1.setViewportView(abilityScoreCostTable);
}
 
Example 15
Source File: TableUISupport.java    From jeddict with Apache License 2.0 4 votes vote down vote up
public static void connectClassNames(JTable table, SelectedTables selectedTables) {
    table.setModel(new TableClassNamesModel(selectedTables));
    setRenderer(table.getColumnModel().getColumn(0));
    setRenderer(table.getColumnModel().getColumn(1));
}
 
Example 16
Source File: ResultWindow.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
public ResultWindow(PeakListRow peakListRow, double searchedMass, Task searchTask) {

    super("");

    this.peakListRow = peakListRow;
    this.searchTask = searchTask;

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setBackground(Color.white);

    JPanel pnlLabelsAndList = new JPanel(new BorderLayout());
    pnlLabelsAndList.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    pnlLabelsAndList.add(new JLabel("List of possible identities"), BorderLayout.NORTH);

    listElementModel = new ResultTableModel(searchedMass);
    IDList = new JTable();
    IDList.setModel(listElementModel);
    IDList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    IDList.getTableHeader().setReorderingAllowed(false);

    TableRowSorter<ResultTableModel> sorter =
        new TableRowSorter<ResultTableModel>(listElementModel);
    IDList.setRowSorter(sorter);

    JScrollPane listScroller = new JScrollPane(IDList);
    listScroller.setPreferredSize(new Dimension(350, 100));
    listScroller.setAlignmentX(LEFT_ALIGNMENT);
    JPanel listPanel = new JPanel();
    listPanel.setLayout(new BoxLayout(listPanel, BoxLayout.PAGE_AXIS));
    listPanel.add(listScroller);
    listPanel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    pnlLabelsAndList.add(listPanel, BorderLayout.CENTER);

    JPanel pnlButtons = new JPanel();
    pnlButtons.setLayout(new BoxLayout(pnlButtons, BoxLayout.X_AXIS));
    pnlButtons.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    GUIUtils.addButton(pnlButtons, "Add identity", null, this, "ADD");
    GUIUtils.addButton(pnlButtons, "View structure", null, this, "VIEWER");
    GUIUtils.addButton(pnlButtons, "View isotope pattern", null, this, "ISOTOPE_VIEWER");
    GUIUtils.addButton(pnlButtons, "Open browser", null, this, "BROWSER");

    setLayout(new BorderLayout());
    setSize(500, 200);
    add(pnlLabelsAndList, BorderLayout.CENTER);
    add(pnlButtons, BorderLayout.SOUTH);
    pack();

  }
 
Example 17
Source File: LibraryPanel.java    From HubPlayer with GNU General Public License v3.0 4 votes vote down vote up
/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.
 */
@SuppressWarnings({ "unchecked", "serial" })
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

	aScrollPanel = new JScrollPane();
	dataTable = new JTable();
	libraryTableModel = new LibraryTableModel();
	libraryOperation = new LibraryOperation();

	aToolBar = new JToolBar();
	moreSearch = new JButton();

	setLayout(new BorderLayout());

	aScrollPanel
			.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
	aScrollPanel
			.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
	aScrollPanel.setMaximumSize(new Dimension(615, 481));

	// 设置20行空数据
	dataTable.setModel(libraryTableModel);
	libraryTableModel.setLibraryOperation(libraryOperation);

	// 定义"操作栏"的渲染器 显示按钮
	dataTable.getColumn("操作").setCellRenderer(
			new DefaultTableCellRenderer() {

				@Override
				public Component getTableCellRendererComponent(
						JTable table, Object value, boolean isSelected,
						boolean hasFocus, int row, int column) {

					return value instanceof JPanel ? (JPanel) value : super
							.getTableCellRendererComponent(table, value,
									isSelected, hasFocus, row, column);
				}
			});
	// 定义"操作栏"的编辑器 响应按钮事件
	dataTable.getColumn("操作").setCellEditor(new CellEditor());

	dataTable.setColumnSelectionAllowed(true);
	dataTable.setRowHeight(23);
	aScrollPanel.setViewportView(dataTable);
	dataTable.getColumnModel().getSelectionModel()
			.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

	add(aScrollPanel, BorderLayout.CENTER);

	aToolBar.setFloatable(false);
	aToolBar.setRollover(true);
	aToolBar.setOpaque(false);

	moreSearch.setText("更多数据");
	moreSearch.setFocusable(false);
	moreSearch.setHorizontalTextPosition(SwingConstants.CENTER);
	moreSearch.setVerticalTextPosition(SwingConstants.BOTTOM);
	// moreSearch.setEnabled(false);
	aToolBar.add(moreSearch);

	Box box = Box.createVerticalBox();
	box.setBorder(BorderFactory.createLineBorder(Color.BLACK));
	box.setOpaque(true);
	box.add(aToolBar);

	add(box, BorderLayout.SOUTH);

}
 
Example 18
Source File: TaxaEditor.java    From beast-mcmc with GNU Lesser General Public License v2.1 4 votes vote down vote up
public TaxaEditor(MainFrame frame, PartitionDataList dataList, int row) {

		this.frame = frame;
		this.dataList = dataList;
		this.row = row;

		// taxonList = new Taxa();
		taxaEditorTableModel = new TaxaEditorTableModel();

		// Setup Main Menu buttons
		load = new JButton("Load", Utils.createImageIcon(Utils.TEXT_FILE_ICON));
		save = new JButton("Save", Utils.createImageIcon(Utils.SAVE_ICON));
		done = new JButton("Done", Utils.createImageIcon(Utils.CHECK_ICON));
		cancel = new JButton("Cancel", Utils.createImageIcon(Utils.CLOSE_ICON));

		// Add Main Menu buttons listeners
		load.addActionListener(new ListenLoadTaxaFile());
		save.addActionListener(new ListenSaveTaxaFile());
		done.addActionListener(new ListenOk());
		cancel.addActionListener(new ListenCancel());

		// Setup menu
		menu = new JMenuBar();
		menu.setLayout(new BorderLayout());
		JPanel buttonsHolder = new JPanel();
		buttonsHolder.setOpaque(false);
		buttonsHolder.add(load);
		buttonsHolder.add(save);
		buttonsHolder.add(done);
		buttonsHolder.add(cancel);
		menu.add(buttonsHolder, BorderLayout.WEST);

		// Setup table
		table = new JTable();
		table.setModel(taxaEditorTableModel);
		table.setSurrendersFocusOnKeystroke(true);

		JScrollPane scrollPane = new JScrollPane(table,
				ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
				ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		RowNumberTable rowNumberTable = new RowNumberTable(table);
		scrollPane.setRowHeaderView(rowNumberTable);
		scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER,
				rowNumberTable.getTableHeader());

		ActionPanel actionPanel = new ActionPanel(false);
		actionPanel.setAddAction(addTaxonAction);
		actionPanel.setRemoveAction(removeTaxonAction);

		// Setup window
		owner = Utils.getActiveFrame();
		window = new JDialog(owner, "Edit taxa set...");
		window.getContentPane().add(menu, BorderLayout.NORTH);
		window.getContentPane().add(scrollPane);
		window.getContentPane().add(actionPanel, BorderLayout.SOUTH);

		window.pack();
		window.setLocationRelativeTo(owner);

		setTaxa();

	}
 
Example 19
Source File: SequencePanel.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new instance of the Sequence Panel.
 *
 * @param extensionScript the extension used to obtain the Sequence scripts.
 */
public SequencePanel(ExtensionScript extensionScript) {
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] {0, 0};
    gridBagLayout.rowHeights = new int[] {0, 0, 0, 0, 0, 0, 0, 0};
    gridBagLayout.columnWeights = new double[] {1.0, Double.MIN_VALUE};
    gridBagLayout.rowWeights =
            new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
    setLayout(gridBagLayout);

    JLabel labelTop = new JLabel(PANEL_DESCRIPTION_LABEL);
    GridBagConstraints gbc_labelTop = new GridBagConstraints();
    gbc_labelTop.anchor = GridBagConstraints.NORTHWEST;
    gbc_labelTop.insets = new Insets(15, 15, 5, 0);
    gbc_labelTop.gridx = 0;
    gbc_labelTop.gridy = 0;
    add(labelTop, gbc_labelTop);

    btnInclude = new JButton(BTNINCLUDESELECT);
    btnInclude.addActionListener(
            new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    boolean selectScripts;
                    if (btnInclude.getText().equals(BTNINCLUDESELECT)) {
                        selectScripts = true;
                        btnInclude.setText(BTNINCLUDEDESELECT);
                    } else {
                        selectScripts = false;
                        btnInclude.setText(BTNINCLUDESELECT);
                    }
                    scriptsTableModel.setAllSelected(selectScripts);
                }
            });
    GridBagConstraints gbc_btnInclude = new GridBagConstraints();
    gbc_btnInclude.anchor = GridBagConstraints.NORTHWEST;
    gbc_btnInclude.insets = new Insets(0, 15, 5, 0);
    gbc_btnInclude.gridx = 0;
    gbc_btnInclude.gridy = 1;
    add(btnInclude, gbc_btnInclude);

    JScrollPane scrollPane = new JScrollPane();
    GridBagConstraints gbc_scrollPane = new GridBagConstraints();
    gbc_scrollPane.anchor = GridBagConstraints.NORTHWEST;
    gbc_scrollPane.gridheight = 3;
    gbc_scrollPane.insets = new Insets(15, 15, 15, 15);
    gbc_scrollPane.fill = GridBagConstraints.BOTH;
    gbc_scrollPane.gridx = 0;
    gbc_scrollPane.gridy = 3;
    add(scrollPane, gbc_scrollPane);

    tblSequence = new JTable();

    scriptsTableModel =
            new SequenceScriptsTableModel(
                    extensionScript.getScripts(ExtensionSequence.TYPE_SEQUENCE));
    tblSequence.setModel(scriptsTableModel);

    tblSequence.getColumnModel().getColumn(0).setPreferredWidth(525);
    tblSequence.getColumnModel().getColumn(0).setMinWidth(25);
    tblSequence.getColumnModel().getColumn(1).setPreferredWidth(100);
    tblSequence.getColumnModel().getColumn(1).setMinWidth(100);
    scrollPane.setViewportView(tblSequence);

    // TODO no help available yet
    // add(getHelpButton());
}
 
Example 20
Source File: GanttChart.java    From swift-k with Apache License 2.0 4 votes vote down vote up
public GanttChart(SystemState state) {
    this.state = state;
	scale = INITIAL_SCALE;
	jobs = new ArrayList<Job>();
	jobmap = new HashMap<String, Job>();

	header = new JTable() {
		public Dimension getPreferredSize() {
			Dimension d = super.getPreferredSize();
			return new Dimension(50, d.height);
		}
	};
	header.setModel(hmodel = new HeaderModel());
	header.setShowHorizontalLines(true);
	header.setPreferredScrollableViewportSize(new Dimension(100, 10));
	header.setDefaultRenderer(Job.class, new JobNameRenderer());

	table = new JTable();
	table.setDoubleBuffered(true);
	table.setModel(cmodel = new ChartModel());
	table.setShowHorizontalLines(true);
	table.setDefaultRenderer(Job.class, new JobRenderer());
	JPanel jp = new JPanel();
	jp.setLayout(new BorderLayout());
	jp.add(table, BorderLayout.CENTER);

	csp = new JScrollPane(jp);
	csp.setColumnHeaderView(new Tickmarks());
	csp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	csp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
	csp.setRowHeaderView(header);
	csp.getVerticalScrollBar().getModel().addChangeListener(this);
	
	hsb = new JScrollBar(JScrollBar.HORIZONTAL);
	hsb.setVisible(true);
	hsb.getModel().addChangeListener(this);

	setLayout(new BorderLayout());
	add(csp, BorderLayout.CENTER);
	add(createTools(), BorderLayout.NORTH);
	add(hsb, BorderLayout.SOUTH);
	
	state.schedule(new TimerTask() {
           @Override
           public void run() {
               GanttChart.this.actionPerformed(null);
           }
	}, 1000, 1000);
}