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

The following examples show how to use javax.swing.JTable#setAutoCreateRowSorter() . 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: RspTabPanel.java    From rest-client with Apache License 2.0 6 votes vote down vote up
/**
* 
* @Title: init 
* @Description: Component Initialization 
* @param  name
* @return void 
* @throws
 */
private void init(String name)
{
    this.setLayout(new BorderLayout(RESTConst.BORDER_WIDTH, 0));

    List<String> colNames = new ArrayList<String>();
    colNames.add(name);
    colNames.add(RESTConst.VALUE);

    tabMdl = new TabModel(colNames);
    tab = new JTable(tabMdl);
    tab.setFillsViewportHeight(true);
    tab.setAutoCreateRowSorter(false);
    tab.getTableHeader().setReorderingAllowed(false);
    
    JPanel pnlNorth = new JPanel();
    pnlNorth.setLayout(new FlowLayout(FlowLayout.CENTER));
    this.add(pnlNorth, BorderLayout.NORTH);

    JPanel pnlCenter = new JPanel();
    pnlCenter.setLayout(new GridLayout(1, 1));
    JScrollPane sp = new JScrollPane(tab);
    pnlCenter.add(sp);

    this.add(pnlCenter, BorderLayout.CENTER);
}
 
Example 2
Source File: StatisticsPanel.java    From freecol with GNU General Public License v2.0 6 votes vote down vote up
private JPanel createStatsTable(String title, Map<String, String> data) {
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(new JLabel(title), BorderLayout.PAGE_START);
    StatisticsModel model = new StatisticsModel();
    model.setData(data);
    JTable table = new JTable(model);
    table.setAutoCreateColumnsFromModel(true);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    table.setAutoCreateRowSorter(true);
    JScrollPane scrollPane = new JScrollPane(table);
    table.addNotify();
    scrollPane.getViewport().setOpaque(false);
    scrollPane.getColumnHeader().setOpaque(false);
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.setPreferredSize(new Dimension(300, (data.size()+2)*17));
    return panel;
}
 
Example 3
Source File: InventoryDialog.java    From WorldGrower with GNU General Public License v3.0 6 votes vote down vote up
private JTable createInventoryTable(WorldObjectContainer inventory, ImageInfoReader imageInfoReader) {
	JTable inventoryTable = JTableFactory.createJTable(new InventoryModel(inventory));
	
	inventoryTable.setDefaultRenderer(ImageIds.class, new InventoryItemImageRenderer(imageInfoReader));
	inventoryTable.getColumnModel().getColumn(1).setCellRenderer(new InventoryItemRenderer());
	inventoryTable.getColumnModel().getColumn(2).setCellRenderer(new InventoryItemRenderer());
	inventoryTable.getColumnModel().getColumn(3).setCellRenderer(new InventoryItemRenderer());
	
	
	inventoryTable.setRowHeight(50);
	inventoryTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
	inventoryTable.getColumnModel().getColumn(0).setPreferredWidth(50);
	inventoryTable.getColumnModel().getColumn(1).setPreferredWidth(245);
	inventoryTable.getColumnModel().getColumn(2).setPreferredWidth(66);
	inventoryTable.getColumnModel().getColumn(3).setPreferredWidth(61);
	inventoryTable.getTableHeader().setReorderingAllowed(false);
	
	inventoryTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	inventoryTable.setAutoCreateRowSorter(true);
	
	return inventoryTable;
}
 
Example 4
Source File: InstancesInfoPanel.java    From hprof-tools with MIT License 6 votes vote down vote up
public InstancesInfoPanel(@Nonnull MemoryDump data, @Nonnull List<Instance> instances) {
    super(new BorderLayout());

    // Instances table
    instancesTable = new JTable();
    instancesTable.setAutoCreateRowSorter(true);
    instancesTable.setRowSelectionAllowed(true);
    instancesTable.addMouseListener(instanceSelectionListener);
    JScrollPane dataTableScrollPane = new JScrollPane(instancesTable);

    // Instance details table
    detailsTable = new JTable();
    detailsTable.setRowSelectionAllowed(true);
    JScrollPane detailsScrollPane = new JScrollPane(detailsTable);

    // Split pane dividing the instance details and the instances table
    JSplitPane splitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, detailsScrollPane, dataTableScrollPane);
    splitter.setDividerLocation(300);
    add(splitter, BorderLayout.CENTER);

    ClassProvider clsProvider = new ClassProvider(data);
    InstanceProvider instanceProvider = new InstanceProvider(data);
    presenter = new InstancesInfoPresenterImpl(this, instances, clsProvider, instanceProvider);
    showInstanceDetails(Collections.emptyMap());
}
 
Example 5
Source File: HealthTab.java    From FoxTelem with GNU General Public License v3.0 6 votes vote down vote up
private JScrollPane addTable(JTable table, HealthTableModel healthTableModel, JPanel centerPanel, BitArrayLayout rt) {

		table.setAutoCreateRowSorter(true);
//		listSelectionModel = table.getSelectionModel();
 //       listSelectionModel.addListSelectionListener(new SharedListSelectionHandler());
 //       table.setSelectionModel(listSelectionModel);
		table.addMouseListener(this);
		
		scrollPane = new JScrollPane (table, 
				   JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
		table.setFillsViewportHeight(true);
		table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
		//table.setMinimumSize(new Dimension(6200, 6000));

		centerPanel.add(scrollPane);
		return scrollPane;
	}
 
Example 6
Source File: CertificatesManagerSettingsPanel.java    From Spark with Apache License 2.0 5 votes vote down vote up
public void addCertTableToPanel() {
    certControll.loadKeyStores();
    certControll.createTableModel();
    certTable = new JTable(certControll.getTableModel()){
        
        @Override
        public Component prepareRenderer(TableCellRenderer renderer, int rowIndex,
                int columnIndex) {
            JComponent component = (JComponent) super.prepareRenderer(renderer, rowIndex, columnIndex);  
            Object value = getModel().getValueAt(convertRowIndexToModel(rowIndex), columnIndex);
            
            DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
            centerRenderer.setHorizontalAlignment( JLabel.CENTER );
            this.getColumnModel().getColumn(1).setCellRenderer(centerRenderer);
            
            
             if (value.equals(Res.getString("cert.valid"))) {
                component.setBackground(Color.green);
            } else if (value.equals(Res.getString("cert.expired")) || value
                    .equals(Res.getString("cert.not.valid.yet")) || value.equals(Res.getString("cert.revoked"))) {
                component.setBackground(Color.red);
            } else {
               component.setBackground(Color.white);
            }
            return component;
        }  
    };

    
    scrollPane = new JScrollPane(certTable);
    certTable.setFillsViewportHeight(true);
    certTable.setAutoCreateRowSorter(true);
    
    certControll.resizeColumnWidth(certTable);
    certTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

    
}
 
Example 7
Source File: TableSortDemo.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public TableSortDemo() {
    super(new GridLayout(1, 0));

    JTable table = new JTable(new MyTableModel());
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);
    table.setAutoCreateRowSorter(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 8
Source File: DemandsDialog.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public void initializeGUI(ImageInfoReader imageInfoReader, SoundIdReader soundIdReader) {
	DemandsModel worldModel = new DemandsModel(demands);
	JTable table = JTableFactory.createJTable(worldModel);
	table.setDefaultRenderer(ImageIds.class, new ImageTableRenderer(imageInfoReader));
	table.setAutoCreateRowSorter(true);
	table.setRowHeight(50);
	table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
	table.getColumnModel().getColumn(0).setPreferredWidth(100);
	table.getColumnModel().getColumn(1).setPreferredWidth(200);
	table.getColumnModel().getColumn(2).setPreferredWidth(100);
	table.getRowSorter().toggleSortOrder(1);

	TableCellEditor fce = new PositiveIntegerCellEditor(JTextFieldFactory.createJTextField());
       table.setDefaultEditor(Integer.class, fce);
	
	JScrollPane scrollPane = JScrollPaneFactory.createScrollPane(table);
	scrollPane.setBounds(15, 15, 418, 700);
	addComponent(scrollPane);
	
	JPanel buttonPane = new JPanel();
	buttonPane.setOpaque(false);
	buttonPane.setBounds(0, 720, 428, 75);
	buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
	addComponent(buttonPane);
	
	JButton okButton = JButtonFactory.createButton("OK", imageInfoReader, soundIdReader);
	okButton.setActionCommand("OK");
	buttonPane.add(okButton);
	addActionHandlers(okButton, worldModel, this, demands);
	getRootPane().setDefaultButton(okButton);
	
	SwingUtils.makeTransparant(table, scrollPane);
}
 
Example 9
Source File: PricesDialog.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public void initializeGUI(Consumer<int[]> setPricesAction, ImageInfoReader imageInfoReader, SoundIdReader soundIdReader) {
	PricesModel worldModel = new PricesModel(pricesOnPlayer);
	JTable table = JTableFactory.createJTable(worldModel);
	table.setDefaultRenderer(ImageIds.class, new ImageTableRenderer(imageInfoReader));
	table.setRowHeight(50);
	table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
	table.getColumnModel().getColumn(0).setPreferredWidth(100);
	table.getColumnModel().getColumn(1).setPreferredWidth(250);
	table.getColumnModel().getColumn(2).setPreferredWidth(100);
	JTableFactory.applyImageToHeaderColumn(table, table.getColumnModel().getColumn(2), ImageIds.SMALL_GOLD_COIN, imageInfoReader);
	table.setAutoCreateRowSorter(true);
	table.getRowSorter().toggleSortOrder(1);
	JScrollPane scrollPane = JScrollPaneFactory.createScrollPane(table);
	scrollPane.setBounds(15, 15, 468, 700);
	addComponent(scrollPane);
	
	JPanel buttonPane = new JPanel();
	buttonPane.setOpaque(false);
	buttonPane.setBounds(0, 730, 488, 75);
	buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
	addComponent(buttonPane);
	
	JButton okButton = JButtonFactory.createButton("OK", imageInfoReader, soundIdReader);
	okButton.setActionCommand("OK");
	buttonPane.add(okButton);
	addActionHandlers(setPricesAction, okButton, worldModel, this, pricesOnPlayer);
	getRootPane().setDefaultButton(okButton);
	
	SwingUtils.makeTransparant(table, scrollPane);
}
 
Example 10
Source File: TableEditor.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new Box with table and actions buttons
 * @return a new Box
 */
protected Container createTablePanel() {
	table = new JTable(tableModel, tableModel.getTableColumnModel());
	table.setRowHeight(22);
	table.setAutoCreateRowSorter(true);
	tableModel.addTableModelListener(this);
	JScrollPane scroll = new JScrollPane(table);
	scroll.setAlignmentX(Container.LEFT_ALIGNMENT);
	Box box = Box.createVerticalBox();
	JButton addButton = new JButton(new AddAction());
	JButton deleteButton = new JButton(new DeleteAction());
	JButton saveButton = new JButton(new SaveAction());
	JButton refreshButton = new JButton(new RefreshAction());
	Box buttonBox = Box.createHorizontalBox();
	buttonBox.add(addButton);
	buttonBox.add(Box.createHorizontalStrut(5));
	buttonBox.add(deleteButton);
	buttonBox.add(Box.createHorizontalStrut(5));
	buttonBox.add(saveButton);
	buttonBox.add(Box.createHorizontalStrut(5));
	buttonBox.add(refreshButton);
	buttonBox.setAlignmentX(Container.LEFT_ALIGNMENT);
	buttonBox.setMaximumSize(new Dimension(Short.MAX_VALUE, 25));
	box.add(buttonBox);
	box.add(Box.createVerticalStrut(5));
	box.add(scroll);
	return box;
}
 
Example 11
Source File: PlannerWindow.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public void createTable() {

		// Create schedule table model
		if (unit instanceof Person)
			PlannerTableModel = new PlannerTableModel((Person) unit);
		else if (unit instanceof Robot)
			PlannerTableModel = new PlannerTableModel((Robot) unit);

		// Create attribute scroll panel
		JScrollPane scrollPanel = new JScrollPane();
		scrollPanel.setBorder(new MarsPanelBorder());

		// Create schedule table
		table = new JTable(PlannerTableModel);
		table.setPreferredScrollableViewportSize(new Dimension(225, 100));
		table.getColumnModel().getColumn(0).setPreferredWidth(25);
		table.getColumnModel().getColumn(1).setPreferredWidth(150);
		table.setCellSelectionEnabled(false);
		// table.setDefaultRenderer(Integer.class, new NumberCellRenderer());
		scrollPanel.setViewportView(table);

		// 2015-06-08 Added sorting
		table.setAutoCreateRowSorter(true);
	    //if (!MainScene.OS.equals("linux")) {
	    //	table.getTableHeader().setDefaultRenderer(new MultisortTableHeaderCellRenderer());
	    //}
		topPanel.add(scrollPanel, BorderLayout.CENTER);

		// 2015-06-08 Added setTableStyle()
		TableStyle.setTableStyle(table);

		update();
	}
 
Example 12
Source File: PortMapperView.java    From portmapper with GNU General Public License v3.0 5 votes vote down vote up
private JComponent getMappingsPanel() {
    // Mappings panel

    final ActionMap actionMap = this.getContext().getActionMap(this.getClass(), this);

    tableModel = new PortMappingsTableModel(app);
    mappingsTable = new JTable(tableModel);
    mappingsTable.setAutoCreateRowSorter(true);
    mappingsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    mappingsTable.setSize(new Dimension(400, 100));
    mappingsTable.getSelectionModel().addListSelectionListener(
            e -> firePropertyChange(PROPERTY_MAPPING_SELECTED, false, isMappingSelected()));

    final JScrollPane mappingsTabelPane = new JScrollPane();
    mappingsTabelPane.setViewportView(mappingsTable);

    final JPanel mappingsPanel = new JPanel(new MigLayout("", "[fill,grow]", "[grow,fill][]"));
    mappingsPanel.setName("port_mappings");
    final Border panelBorder = BorderFactory
            .createTitledBorder(app.getResourceMap().getString("mainFrame.port_mappings.title"));
    mappingsPanel.setBorder(panelBorder);
    mappingsPanel.add(mappingsTabelPane, "height 100::, span 2, wrap");

    mappingsPanel.add(new JButton(actionMap.get(ACTION_REMOVE_MAPPINGS)), "");
    mappingsPanel.add(new JButton(actionMap.get(ACTION_UPDATE_PORT_MAPPINGS)), "wrap");
    return mappingsPanel;
}
 
Example 13
Source File: MagicOverviewDialog.java    From WorldGrower with GNU General Public License v3.0 4 votes vote down vote up
public MagicOverviewDialog(WorldObject playerCharacter, ImageInfoReader imageInfoReader, SoundIdReader soundIdReader, JFrame parentFrame) {
	setModalityType(ModalityType.APPLICATION_MODAL);
	contentPanel = new TiledImagePanel(imageInfoReader);
	
	int width = 900;
	int height = 850;
	setSize(width, height);
	contentPanel.setPreferredSize(new Dimension(width, height));
	setLocationRelativeTo(null);
	getContentPane().setLayout(new BorderLayout());
	contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
	getContentPane().add(contentPanel, BorderLayout.CENTER);
	contentPanel.setLayout(null);
	setUndecorated(true);
	IconUtils.setIcon(this);
	setCursor(Cursors.CURSOR);
	
	JScrollPane scrollPane = new JScrollPane();
	scrollPane.setBounds(12, 13, 871, 767);
	contentPanel.add(scrollPane);
	
	JTable magicSpellsTable = new MagicSpellsTable(new MagicSpellTableModel(playerCharacter));
	magicSpellsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	
	magicSpellsTable.setDefaultRenderer(SkillProperty.class, new SkillTableRenderer(imageInfoReader));
	magicSpellsTable.setDefaultRenderer(ImageIds.class, new ImageTableRenderer(imageInfoReader));
	magicSpellsTable.setRowHeight(50);
	magicSpellsTable.setAutoCreateRowSorter(true);
	magicSpellsTable.getRowSorter().toggleSortOrder(1);
	
	magicSpellsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
	magicSpellsTable.getColumnModel().getColumn(0).setPreferredWidth(50);
	magicSpellsTable.getColumnModel().getColumn(1).setPreferredWidth(257);
	magicSpellsTable.getColumnModel().getColumn(2).setPreferredWidth(150);
	magicSpellsTable.getColumnModel().getColumn(3).setPreferredWidth(145);
	magicSpellsTable.getColumnModel().getColumn(4).setPreferredWidth(100);
	magicSpellsTable.getColumnModel().getColumn(5).setPreferredWidth(150);
	
	JTableFactory.applyImageToHeaderColumn(magicSpellsTable, magicSpellsTable.getColumnModel().getColumn(5), ImageIds.SMALL_TURN, imageInfoReader);
	
	scrollPane.setViewportView(magicSpellsTable);

	JPanel buttonPane = new JPanel();
	buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
	buttonPane.setOpaque(false);
	buttonPane.setBounds(12, 790, 878, 75);
	contentPanel.add(buttonPane);
		
	JButton okButton = JButtonFactory.createButton("OK", imageInfoReader, soundIdReader);
	okButton.setActionCommand("OK");
	buttonPane.add(okButton);
	getRootPane().setDefaultButton(okButton);
	
	okButton.addActionListener(new CloseDialogAction());
	SwingUtils.installEscapeCloseOperation(this);
	
	SwingUtils.makeTransparant(magicSpellsTable, scrollPane);
	
	DialogUtils.createDialogBackPanel(this, parentFrame.getContentPane());
}
 
Example 14
Source File: SearchPanel.java    From RegexReplacer with MIT License 4 votes vote down vote up
private void createComponent() {
	resultTableModel = new MyTableModel();
	resultTable = new JTable(resultTableModel);
	Enumeration<TableColumn> columns = resultTable.getColumnModel()
			.getColumns();
	for (int n = 0; columns.hasMoreElements(); n++) {
		columns.nextElement().setPreferredWidth(
				resultTableModel.getColumnWidth(n));
	}
	resultTable.setPreferredScrollableViewportSize(resultTable
			.getPreferredSize());
	resultTable.setAutoCreateRowSorter(false);
	// resultTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
	regexArea = new JTextArea(3, 20);
	replaceArea = new JTextArea(3, 20);

	unixLinesCkb = new JCheckBox("UNIX_LINES");
	unixLinesCkb.setToolTipText(Helper.UNIX_LINES_TIP);
	caseInsensitiveCkb = new JCheckBox("CASE_INSENSITIVE");
	caseInsensitiveCkb.setToolTipText(Helper.CASE_INSENSITIVE_TIP);
	commentsCkb = new JCheckBox("COMMENTS");
	commentsCkb.setToolTipText(Helper.COMMENTS_TIP);
	multilineCkb = new JCheckBox("MULTILINE");
	multilineCkb.setToolTipText(Helper.MULTILINE_TIP);
	literalCkb = new JCheckBox(StrUtils.getStr("SearchPanel.LITERAL"));
	literalCkb.setToolTipText(Helper.LITERAL_TIP);
	dotallCkb = new JCheckBox("DOTALL");
	dotallCkb.setToolTipText(Helper.DOTALL_TIP);
	unicodeCaseCkb = new JCheckBox("UNICODE_CASE");
	unicodeCaseCkb.setToolTipText(Helper.UNICODE_CASE_TIP);
	canonEqCkb = new JCheckBox("CANON_EQ");
	canonEqCkb.setToolTipText(Helper.CANON_EQ_TIP);

	expressionAvailable = new JCheckBox(
			StrUtils.getStr("SearchPanel.replaceFunction"), true);
	expressionAvailable.setToolTipText(StrUtils
			.getStr("SearchPanel.replaceFunction_tip"));
	liveUpdateCkb = new JCheckBox(
			StrUtils.getStr("SearchPanel.liveUpdate"), true);
	outputResultToNewWindow = new JCheckBox(
			StrUtils.getStr("SearchPanel.getReplacementOnly"));
	outputResultToNewWindow.setToolTipText(StrUtils
			.getStr("SearchPanel.getReplacementOnly_tip"));
	divertFocus = new JCheckBox(StrUtils.getStr("SearchPanel.returnFocus"),
			true);
	divertFocus.setToolTipText(StrUtils
			.getStr("SearchPanel.returnFocus_tip"));

	updateNowBtn = new JButton(StrUtils.getStr("SearchPanel.udpate"));
	updateNowBtn.setEnabled(false);
	replaceSelected = new JButton(
			StrUtils.getStr("SearchPanel.replaceSelected"));
	replaceAll = new JButton(StrUtils.getStr("SearchPanel.replaceAll"));
	statsLabel = new JLabel(StrUtils.getStr("SearchPanel.authorLabel"));
	matchResultLabel = new JLabel();
}
 
Example 15
Source File: PageableTable.java    From jdal with Apache License 2.0 4 votes vote down vote up
/**
 * Initalize component after properties set. Normally called by context vía init-method
 */
public void init() {
	okIcon = FormUtils.getIcon(okIcon, "/images/16x16/dialog-ok.png");
	cancelIcon = FormUtils.getIcon(cancelIcon, "/images/16x16/dialog-cancel.png");
	visibilityMenuIcon = FormUtils.getIcon(visibilityMenuIcon, "/images/16x16/view-choose.png");
	userMenuIcon = FormUtils.getIcon(userMenuIcon, "/images/table/16x16/users.png");
	
	if (tableModel == null) {
		tableModel = new ListTableModel();
	}	
	
	setLayout(layout);
	
	// Server side sorter
	sorter = new ModelRowSorter<ListTableModel>(tableModel);
	sorter.addRowSorterListener(this);
	// configure paginator
	if (showPaginator) {
		if (paginatorView == null) {
			paginatorView = new PaginatorView();
			paginatorView.init();
		}
	
		paginatorView.setPaginator(page);
		page.addPaginatorListener(this);
		add(paginatorView.getPanel(), BorderLayout.SOUTH);
	}
	else {
		page.setPageSize(Integer.MAX_VALUE);
	}
	
	createColumnDescriptos();
	table = new JTable(tableModel, tableModel.getTableColumnModel());
	table.setAutoCreateRowSorter(false);
	table.setRowSorter(sorter);
	table.setRowHeight(22);
	table.addMouseListener(new TableListener());
	tableScrollPane = new JScrollPane(table);

	this.setBackground(Color.WHITE);
	add(tableScrollPane, BorderLayout.CENTER);

	
	if (showMenu)
		createMenu();
	
	page.setPageableDataSource(dataSource);
	// goto first page
	page.firstPage();
	// restore table state
	restoreState();
}
 
Example 16
Source File: DiagnosticTable.java    From FoxTelem with GNU General Public License v3.0 4 votes vote down vote up
private JTable addErrorTable() {
	if (conversionType == BitArrayLayout.CONVERT_IHU_DIAGNOSTIC) 
		tableModel = new DiagnosticTableModel();
	else if (conversionType == BitArrayLayout.CONVERT_HARD_ERROR)
		tableModel = new HardErrorTableModel();
	else if (conversionType == BitArrayLayout.CONVERT_SOFT_ERROR)
		tableModel = new SoftErrorTableModel();
	else if (conversionType == BitArrayLayout.CONVERT_SOFT_ERROR_84488)
		tableModel = new SoftError84488TableModel();
	else if (conversionType == BitArrayLayout.CONVERT_ICR_DIAGNOSTIC)
		tableModel = new IcrDiagnosticTableModel();
	else if (conversionType == BitArrayLayout.CONVERT_COM1_ISIS_ANT_STATUS)
		tableModel = new IsisAntennaStatusTableModel();
	
	JTable table = new JTable(tableModel);
	table.setAutoCreateRowSorter(true);
	
	scrollPane = new JScrollPane (table, 
			   JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
	table.setFillsViewportHeight(true);
	table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
	add(scrollPane, BorderLayout.CENTER);
	//add(table, BorderLayout.CENTER);

	TableColumn column = null;
	column = table.getColumnModel().getColumn(0);
	column.setPreferredWidth(45);
	
	column = table.getColumnModel().getColumn(1);
	column.setPreferredWidth(55);
	DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
	centerRenderer.setHorizontalAlignment( SwingConstants.CENTER );
	
	if (conversionType == BitArrayLayout.CONVERT_IHU_DIAGNOSTIC) {
		column = table.getColumnModel().getColumn(2);
		column.setPreferredWidth(250);
	} else if (conversionType == BitArrayLayout.CONVERT_HARD_ERROR)
		for (int i=0; i<6; i++) {
			column = table.getColumnModel().getColumn(i+2);
			column.setPreferredWidth(60);
			column.setCellRenderer(centerRenderer);
			column.setHeaderRenderer(centerRenderer);
		}
	else if (conversionType == BitArrayLayout.CONVERT_SOFT_ERROR) {
		for (int i=0; i<4; i++) {
			column = table.getColumnModel().getColumn(i+2);
			column.setPreferredWidth(60);
			column.setCellRenderer(centerRenderer);
			column.setHeaderRenderer(centerRenderer);
		}
		if (conversionType == BitArrayLayout.CONVERT_SOFT_ERROR_84488) {
			column = table.getColumnModel().getColumn(6);
			column.setPreferredWidth(60);
			column.setCellRenderer(centerRenderer);
			column.setHeaderRenderer(centerRenderer);
		}
	}
	else if (conversionType == BitArrayLayout.CONVERT_ICR_DIAGNOSTIC) {
		for (int i=0; i<4; i++) {
			column = table.getColumnModel().getColumn(i+2);
			column.setPreferredWidth(60);
			column.setCellRenderer(centerRenderer);
			column.setHeaderRenderer(centerRenderer);
		}
	}
	else if (conversionType == BitArrayLayout.CONVERT_COM1_ISIS_ANT_STATUS) {
		for (int i=0; i<15; i++) {
			column = table.getColumnModel().getColumn(i+2);
			column.setPreferredWidth(60);
			column.setCellRenderer(centerRenderer);
			column.setHeaderRenderer(centerRenderer);
		}
	}

	
	return table;
}
 
Example 17
Source File: KeyboardShortcutsDialog.java    From sc2gears with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new TipsDialog.
 */
public KeyboardShortcutsDialog() {
	super( "keyboardShortcuts.title", Icons.KEYBOARD );
	
	final String CTRL  = Language.getText( "keyboardShortcuts.key.ctrl"  ) + '+';
	final String SHIFT = Language.getText( "keyboardShortcuts.key.shift" ) + '+';
	final String ALT   = Language.getText( "keyboardShortcuts.key.alt"   ) + '+';
	
	final String NUMBER      = Language.getText( "keyboardShortcuts.key.number"      );
	final String FUNCION_KEY = Language.getText( "keyboardShortcuts.key.functionKey" );
	
	final JTable table = GuiUtils.createNonEditableTable();
	table.setAutoCreateRowSorter( true );
	( (DefaultTableModel) table.getModel() ).setDataVector( createData( 
			new String[][] { 
				{ "global",
				        "enableDisableReplayAutoSave"   , CTRL + ALT + "R" },
				{ null, "enableDisableApmAlert"         , CTRL + ALT + "A" },
				{ null, "startStopMousePrintRecording"  , CTRL + ALT + "M" },
				{ null, "switchToSc2gears"              , CTRL + ALT + "T" },
				{ null, "showHideLastGameInfoDialog"    , CTRL + ALT + "I" },
				{ null, "showHideApmDisplayDialog"      , CTRL + ALT + "U" },
				{ "general",
				        "openReplay"                    , CTRL + "O" },
				{ null, "openLastReplay"                , CTRL + SHIFT+ "O" },
				{ null, "exit"                          , ALT + "X" },
				{ null, "miscSettings"                  , CTRL + "P" },
				{ null, "filterTableRows"               , CTRL + "F" },
				{ null, "filterOutTableRows"            , CTRL + "T" },
				{ null, "openTool"                      , CTRL + SHIFT + FUNCION_KEY },
				{ null, "fullScreen"                    , "F11" },
				{ null, "minimieToTray"                 , "F9" },
				{ null, "tileAllWindows"                , "F2" },
				{ null, "cascadeAllWindows"             , "F3" },
				{ null, "tileVisibleWindows"            , CTRL + "F2" },
				{ null, "cascadeVisibleWindows"         , CTRL + "F3" },
				{ null, "visitHomePage"                 , CTRL + "F1" },
				{ null, "showStartPage"                 , "F1" },
				{ null, "closeInternalWindow"           , CTRL + "F4" },
				{ null, "restoreInternalWindowSize"     , CTRL + "F5" },
				{ null, "cycleThroughTabs"              , CTRL + "TAB" },
				{ null, "cycleThroughInternalWindows"   , CTRL + "TAB" },
				{ null, "cycleThroughInternalWindows"   , CTRL + "F6" },
				{ null, "switchNavTreeIntWindows"       , "F6" },
				{ null, "focusNavTreeIntWindowsSplitter", "F8" },
				{ null, "windowContextMenu"             , CTRL + "SPACE" },
				{ null, "mainMenu"                      , "F10" },
				{ null, "closeTab"                      , CTRL + "W" },
				{ "startPage",
			            "refreshContent"                , "F5" },
				{ "replayAnalyzer",
				        "selectChart"                   , CTRL + NUMBER },
				{ null, "openCloseOverlayChart"         , CTRL + SHIFT + NUMBER },
				{ null, "zoomIn"                        , CTRL + "I" },
				{ null, "zoomOut"                       , CTRL + "U" },
				{ null, "gridOnOff"                     , CTRL + "G" },
				{ null, "openGridSettings"              , CTRL + SHIFT + "G" },
				{ null, "playPause"                     , CTRL + "W" },
				{ null, "jumpBackward"                  , CTRL + "Q" },
				{ null, "jumpForward"                   , CTRL + "E" },
				{ null, "jumpToBeginning"               , CTRL + SHIFT + "Q" },
				{ null, "jumpToEnd"                     , CTRL + SHIFT + "E" },
				{ null, "slowDown"                      , CTRL + "R" },
				{ null, "speedUp"                       , CTRL + SHIFT + "R" },
				{ null, "jumpToFrame"                   , CTRL + "J" },
				{ null, "searchText"                    , CTRL + "S" },
				{ null, "filterActions"                 , CTRL + "F" },
				{ null, "filterOutActions"              , CTRL + "T" },
				{ "multiRepAnalysis",
				        "selectChart"                   , CTRL + NUMBER },
				{ "onTopApmDisplay",
					    "increaseFontSize"              , "+" },
				{ null, "decreaseFontSize"              , "-" }
			} ), new Object[] { Language.getText( "keyboardShortcuts.table.header.context" ), Language.getText( "keyboardShortcuts.table.header.function" ), Language.getText( "keyboardShortcuts.table.header.shortcut" ),  } );
	table.setPreferredScrollableViewportSize( new Dimension( 900, 500 ) );
	GuiUtils.packTable( table );
	final TableBox tableBox = new TableBox( table, getLayeredPane(), null );
	tableBox.setBorder( BorderFactory.createEmptyBorder( 15, 15, 10, 15 ) );
	getContentPane().add( tableBox, BorderLayout.CENTER );
	
	final JPanel buttonsPanel = new JPanel();
	buttonsPanel.setBorder( BorderFactory.createEmptyBorder( 0, 15, 10, 15 ) );
	final JButton closeButton = createCloseButton( "button.close" );
	buttonsPanel.add( closeButton );
	getContentPane().add( buttonsPanel, BorderLayout.SOUTH );
	
	packAndShow( closeButton, false );
}
 
Example 18
Source File: TableDemo.java    From littleluck with Apache License 2.0 4 votes vote down vote up
protected void initComponents() {
    setLayout(new BorderLayout());

    controlPanel = createControlPanel();
    add(controlPanel, BorderLayout.NORTH);

    //<snip>Create JTable
    oscarTable = new JTable(oscarModel);
    //</snip>

    //</snip>Set JTable display properties
    oscarTable.setColumnModel(createColumnModel());
    oscarTable.setAutoCreateRowSorter(true);
    oscarTable.setRowHeight(26);
    oscarTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
    oscarTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    oscarTable.setIntercellSpacing(new Dimension(0, 0));
    //</snip>

    //<snip>Initialize preferred size for table's viewable area
    Dimension viewSize = new Dimension();
    viewSize.width = oscarTable.getColumnModel().getTotalColumnWidth();
    viewSize.height = 10 * oscarTable.getRowHeight();
    oscarTable.setPreferredScrollableViewportSize(viewSize);
    //</snip>

    //<snip>Customize height and alignment of table header
    JTableHeader header = oscarTable.getTableHeader();
    header.setPreferredSize(new Dimension(30, 26));
    TableCellRenderer headerRenderer = header.getDefaultRenderer();
    if (headerRenderer instanceof JLabel) {
        ((JLabel) headerRenderer).setHorizontalAlignment(JLabel.CENTER);
    }
    //</snip>

    LuckScrollPane scrollpane = new LuckScrollPane(oscarTable);
    dataPanel = new Stacker(scrollpane);
    add(dataPanel, BorderLayout.CENTER);

    add(createStatusBar(), BorderLayout.SOUTH);

}
 
Example 19
Source File: DJarInfo.java    From portecle with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Initialize the dialog's GUI components.
 *
 * @throws IOException Problem occurred getting JAR information
 */
private void initComponents()
    throws IOException
{
	JarFile[] jarFiles = getClassPathJars();

	// JAR Information table

	// Create the table using the appropriate table model
	JarInfoTableModel jiModel = new JarInfoTableModel();
	jiModel.load(jarFiles);

	JTable jtJarInfo = new JTable(jiModel);

	jtJarInfo.setRowMargin(0);
	jtJarInfo.getColumnModel().setColumnMargin(0);
	jtJarInfo.getTableHeader().setReorderingAllowed(false);
	jtJarInfo.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
	jtJarInfo.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

	// Add custom renderers for the table cells and headers
	for (int iCnt = 0; iCnt < jtJarInfo.getColumnCount(); iCnt++)
	{
		TableColumn column = jtJarInfo.getColumnModel().getColumn(iCnt);

		column.setPreferredWidth(150);

		column.setHeaderRenderer(new JarInfoTableHeadRend());
		column.setCellRenderer(new JarInfoTableCellRend());
	}

	// Make the table sortable
	jtJarInfo.setAutoCreateRowSorter(true);
	// ...and sort it by jar file by default
	jtJarInfo.getRowSorter().toggleSortOrder(0);

	// Put the table into a scroll pane
	JScrollPane jspJarInfoTable = new JScrollPane(jtJarInfo, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
	    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	jspJarInfoTable.getViewport().setBackground(jtJarInfo.getBackground());

	// Put the scroll pane into a panel
	JPanel jpJarInfoTable = new JPanel(new BorderLayout(10, 10));
	jpJarInfoTable.setPreferredSize(new Dimension(500, 150));
	jpJarInfoTable.add(jspJarInfoTable, BorderLayout.CENTER);
	jpJarInfoTable.setBorder(new EmptyBorder(5, 5, 5, 5));

	JButton jbOK = getOkButton(true);
	JPanel jpOK = new JPanel(new FlowLayout(FlowLayout.CENTER));
	jpOK.add(jbOK);

	getContentPane().add(jpJarInfoTable, BorderLayout.CENTER);
	getContentPane().add(jpOK, BorderLayout.SOUTH);

	getRootPane().setDefaultButton(jbOK);

	initDialog();

	jbOK.requestFocusInWindow();
}
 
Example 20
Source File: HistView.java    From rest-client with Apache License 2.0 4 votes vote down vote up
/**
* 
* @Title: init 
* @Description: Component Initialization 
* @param  name
* @return void 
* @throws
 */
private void init()
{
    this.setLayout(new BorderLayout(RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH));
    this.setBorder(BorderFactory.createEmptyBorder(RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH));

    List<String> colNames = new ArrayList<String>();
    colNames.add(RESTConst.ID);
    colNames.add(RESTConst.REQUEST);
    colNames.add(RESTConst.RESPONSE);
    colNames.add(RESTConst.DATE);
    colNames.add(RESTConst.TIME);
    colNames.add(RESTConst.DESCR);

    tabMdl = new TabModel(colNames);
    tabMdl.setCellEditable(false);
    tab = new JTable(tabMdl);
    tab.setFillsViewportHeight(true);
    tab.setAutoCreateRowSorter(false);
    tab.getTableHeader().setReorderingAllowed(false);
    tab.addMouseListener(ma);
    tab.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    tab.getSelectionModel().addListSelectionListener(this);
    UIUtil.setHistTabWidth(tab);

    miRmSel = new JMenuItem(RESTConst.RM_SEL);
    miRmSel.setName(RESTConst.RM_SEL);
    miRmSel.addActionListener(this);

    miRmAll = new JMenuItem(RESTConst.RM_ALL);
    miRmAll.setName(RESTConst.RM_ALL);
    miRmAll.addActionListener(this);

    miMvUp = new JMenuItem(RESTConst.MOVE_UP);
    miMvUp.setName(RESTConst.MOVE_UP);
    miMvUp.addActionListener(this);

    miMvDown = new JMenuItem(RESTConst.MOVE_DOWN);
    miMvDown.setName(RESTConst.MOVE_DOWN);
    miMvDown.addActionListener(this);

    miEdit = new JMenuItem(RESTConst.EDIT);
    miEdit.setName(RESTConst.EDIT);
    miEdit.addActionListener(this);

    miRefresh = new JMenuItem(RESTConst.REFRESH);
    miRefresh.setName(RESTConst.REFRESH);
    miRefresh.addActionListener(this);

    histFrame = new HistFrame();
    
    pm = new JPopupMenu();
    pm.add(miRefresh);
    pm.add(miEdit);
    pm.addSeparator();
    pm.add(miMvUp);
    pm.add(miMvDown);
    pm.addSeparator();
    pm.add(miRmSel);
    pm.add(miRmAll);

    JPanel pnlCenter = new JPanel();
    pnlCenter.setLayout(new GridLayout(1, 1));
    JScrollPane sp = new JScrollPane(tab);
    pnlCenter.add(sp);

    this.add(pnlCenter, BorderLayout.CENTER);
    this.setBorder(BorderFactory.createTitledBorder(null, RESTConst.HTTP_HISTORY, TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION));
}