Java Code Examples for javax.swing.JScrollPane#setColumnHeaderView()

The following examples show how to use javax.swing.JScrollPane#setColumnHeaderView() . 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: BaseTable.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Overridden - JTable's implementation of the method will
 *  actually attach (and leave behind) a gratuitous border
 *  on the enclosing scroll pane. */
protected final void configureEnclosingScrollPane() {
    Container p = getParent();

    if (p instanceof JViewport) {
        Container gp = p.getParent();

        if (gp instanceof JScrollPane) {
            JScrollPane scrollPane = (JScrollPane) gp;
            JViewport viewport = scrollPane.getViewport();

            if ((viewport == null) || (viewport.getView() != this)) {
                return;
            }

            scrollPane.setColumnHeaderView(getTableHeader());
        }
    }
}
 
Example 2
Source File: WeaponEditor.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
private Component createOutline(List<WeaponStats> weapons, Class<? extends WeaponStats> weaponClass) {
    mOutline = new WeaponOutline();
    OutlineModel model = mOutline.getModel();
    WeaponColumn.addColumns(mOutline, weaponClass, true);
    mOutline.setAllowColumnDrag(false);
    mOutline.setAllowColumnResize(false);
    mOutline.setAllowRowDrag(false);

    for (WeaponStats weapon : weapons) {
        if (mWeaponClass.isInstance(weapon)) {
            model.addRow(new WeaponDisplayRow(weapon.clone(mOwner)));
        }
    }

    mOutline.addActionListener(this);
    Dimension size = mOutline.getMinimumSize();
    if (size.height < 50) {
        size.height = 50;
        mOutline.setMinimumSize(size);
    }

    JScrollPane scroller = new JScrollPane(mOutline);
    scroller.setColumnHeaderView(mOutline.getHeaderPanel());
    return scroller;
}
 
Example 3
Source File: DiskLayoutPanel.java    From DiskBrowser with GNU General Public License v3.0 5 votes vote down vote up
public DiskLayoutPanel ()
// ---------------------------------------------------------------------------------//
{
  super (new BorderLayout ());

  diskLayoutImage = new DiskLayoutImage ();
  verticalRuler = new ScrollRuler (diskLayoutImage, ScrollRuler.VERTICAL);
  horizontalRuler = new ScrollRuler (diskLayoutImage, ScrollRuler.HORIZONTAL);
  legendPanel = new DiskLegendPanel ();

  setBackground (Color.WHITE);

  sp = new JScrollPane (diskLayoutImage, VERTICAL_SCROLLBAR_ALWAYS,
      HORIZONTAL_SCROLLBAR_ALWAYS);
  sp.getViewport ().setBackground (Color.WHITE);
  sp.setColumnHeaderView (horizontalRuler);
  sp.setRowHeaderView (verticalRuler);
  sp.setBorder (null);
  sp.setCorner (JScrollPane.UPPER_LEFT_CORNER, new Corner (true));
  sp.setCorner (JScrollPane.LOWER_LEFT_CORNER, new Corner (false));
  sp.setCorner (JScrollPane.UPPER_RIGHT_CORNER, new Corner (false));
  sp.setCorner (JScrollPane.LOWER_RIGHT_CORNER, new Corner (false));

  // this is just so the pack is correct
  add (sp, BorderLayout.CENTER);
  add (legendPanel, BorderLayout.SOUTH);
}
 
Example 4
Source File: OverviewPanel.java    From blog with Apache License 2.0 5 votes vote down vote up
public OverviewPanel() {
	setLayout(null);
	selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	treeSelectionListModelSelectionAdapter
			.setListModelSelection(listModelSelection);
	personList.setSelectionModel(selectionModel);
	personTable.setSelectionModel(selectionModel);
	personComboBoxModel.setListSelectionModel(selectionModel);
	personTree.setSelectionModel(treeSelectionListModelSelectionAdapter);

	ListCellRenderer<Person> personRenderer = new PersonListCellRenderer();
	personList.setCellRenderer(personRenderer);
	personList.setEnabled(true);
	personsComboBox.setRenderer(personRenderer);
	personTree.setCellRenderer(new PersonTreeCellRenderer());
	personTree.setRootVisible(false);
	personTable.setSelectionModel(personList.getSelectionModel());

	JScrollPane scrollPane = new JScrollPane();
	scrollPane.setBounds(10, 11, 580, 130);
	add(scrollPane);

	scrollPane.setViewportView(personTable);

	personsComboBox.setBounds(10, 153, 580, 30);
	add(personsComboBox);

	JScrollPane scrollPane_1 = new JScrollPane();
	scrollPane_1.setBounds(10, 194, 580, 105);
	add(scrollPane_1);

	scrollPane_1.setViewportView(personList);

	JScrollPane scrollPane_2 = new JScrollPane();
	scrollPane_2.setBounds(10, 310, 580, 205);
	add(scrollPane_2);

	scrollPane_2.setColumnHeaderView(personTree);
}
 
Example 5
Source File: RouterClientTest.java    From jRUDP with MIT License 4 votes vote down vote up
private RouterClientTest() {
	setResizable(false);
	setTitle("jRUDP Client Test");
	setDefaultCloseOperation(EXIT_ON_CLOSE);
	setSize(289, 500);
	setLocationRelativeTo(null);
	getContentPane().setLayout(null);

	try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch(Exception e) {}

	JScrollPane scrollPane = new JScrollPane();
	scrollPane.setBounds(10, 69, 263, 156);
	getContentPane().add(scrollPane);

	lblRecPacketQueue = new JLabel("Received Packet Queue (Front==index#0)");
	scrollPane.setColumnHeaderView(lblRecPacketQueue);

	JList<String> listPacketQueue = new JList<>();
	listPacketQueue.setEnabled(false);
	listPacketQueue.setModel(modelRecPackets);
	scrollPane.setViewportView(listPacketQueue);

	btnConnection = new JButton("Connect");
	btnConnection.addActionListener((action)->{
		if(clientInstance != null && clientInstance.isConnected()) {
			disconnectWGui();
		}
		else {
			connectWGui();
		}
	});
	btnConnection.setBounds(10, 438, 263, 23);
	getContentPane().add(btnConnection);

	tfServerPort = new JTextField();
	tfServerPort.setText(ST_SERVER_PORT + "");
	tfServerPort.setBounds(96, 407, 177, 20);
	tfServerPort.setColumns(10);
	getContentPane().add(tfServerPort);

	tfServerHost = new JTextField();
	tfServerHost.setText(ST_SERVER_HOST);
	tfServerHost.setColumns(10);
	tfServerHost.setBounds(96, 376, 177, 20);
	getContentPane().add(tfServerHost);

	JLabel lblServerHost = new JLabel("Server Host:");
	lblServerHost.setBounds(23, 379, 71, 14);
	getContentPane().add(lblServerHost);

	JLabel lblServerPort = new JLabel("Server Port:");
	lblServerPort.setBounds(23, 410, 71, 14);
	getContentPane().add(lblServerPort);

	JScrollPane scrollPane_1 = new JScrollPane();
	scrollPane_1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
	scrollPane_1.setBounds(10, 236, 263, 126);
	getContentPane().add(scrollPane_1);

	taConsole = new JTextArea();
	taConsole.setLineWrap(true);
	taConsole.setWrapStyleWord(true);
	taConsole.setEditable(false);
	taConsole.setBackground(Color.LIGHT_GRAY);
	taConsole.setFont(new Font("SansSerif", Font.BOLD, 11));
	scrollPane_1.setViewportView(taConsole);
	
	taHandledPacket = new JTextArea();
	taHandledPacket.setEditable(false);
	taHandledPacket.setEnabled(false);
	taHandledPacket.setFont(new Font("SansSerif", Font.BOLD, 11));
	taHandledPacket.setText("Last Handled Packet:\r\nnull");
	taHandledPacket.setBounds(10, 11, 263, 47);
	getContentPane().add(taHandledPacket);
	setVisible(true);

	System.setOut(new PrintStream(new OutputStream() {
		@Override
		public void write(int b) throws IOException {
			taConsole.append("" + (char)b);
			taConsole.setSize(taConsole.getPreferredSize());
			JScrollBar sb = scrollPane_1.getVerticalScrollBar();
			sb.setValue( sb.getMaximum() );
		}
	}));

	System.out.println("[INFO]Console: on");

	setVisible(true);
}
 
Example 6
Source File: NbEditorUI.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static void processSideBars(Map sideBars, JComponent ec, JScrollPane scroller) {
        // Remove all existing sidebars
        ec.removeAll();

        // Add the scroller and the new sidebars
        ec.add(scroller);
        scroller.setRowHeader(null);
        scroller.setColumnHeaderView(null);
//        final MouseDispatcher mouse = new MouseDispatcher((JTextComponent) ec.getClientProperty(JTextComponent.class));
        for (Iterator entries = sideBars.entrySet().iterator(); entries.hasNext(); ) {
            Map.Entry entry = (Map.Entry) entries.next();
            SideBarPosition position = (SideBarPosition) entry.getKey();
            JComponent sideBar = (JComponent) entry.getValue();
            
//            if (position.getPosition() == SideBarPosition.WEST) {
//                JPanel p = new JPanel(new BorderLayout()) {
//
//                    @Override
//                    public void addNotify() {
//                        super.addNotify();
//                        infiltrateContainer(this, mouse, true);
//                    }
//
//                    @Override
//                    public void removeNotify() {
//                        infiltrateContainer(this, mouse, false);
//                        super.removeNotify();
//                    }
//
//                };
//                p.add(sideBar, BorderLayout.CENTER);
//                sideBar = p;
//            }
            
            if (position.isScrollable()) {
                if (position.getPosition() == SideBarPosition.WEST) {
                    scroller.setRowHeaderView(sideBar);
                } else {
                    if (position.getPosition() == SideBarPosition.NORTH) {
                        scroller.setColumnHeaderView(sideBar);
                    } else {
                        throw new IllegalArgumentException("Unsupported side bar position, scrollable = true, position=" + position.getBorderLayoutPosition()); // NOI18N
                    }
                }
            } else {
                ec.add(sideBar, position.getBorderLayoutPosition());
            }
        }
    }
 
Example 7
Source File: LibraryDockable.java    From gcs with Mozilla Public License 2.0 4 votes vote down vote up
/** Creates a new {@link LibraryDockable}. */
public LibraryDockable(ListFile file) {
    super(file);
    mOutline = createOutline();
    mOutline.setDynamicRowHeight(true);
    OutlineModel outlineModel = mOutline.getModel();
    outlineModel.applySortConfig(outlineModel.getSortConfig());
    outlineModel.setRowFilter(this);
    LibraryContent content = new LibraryContent(mOutline);
    LibraryHeader  header  = new LibraryHeader(mOutline.getHeaderPanel());
    Preferences    prefs   = Preferences.getInstance();
    mToolbar = new Toolbar();
    mScaleCombo = new JComboBox<>(Scales.values());
    mScaleCombo.setSelectedItem(prefs.getInitialUIScale());
    mScaleCombo.addActionListener((event) -> {
        Scales scales = (Scales) mScaleCombo.getSelectedItem();
        if (scales == null) {
            scales = Scales.ACTUAL_SIZE;
        }
        Scale scale = scales.getScale();
        header.setScale(scale);
        content.setScale(scale);
    });
    mToolbar.add(mScaleCombo);
    createFilterField();
    createCategoryCombo();
    mLockButton = new IconButton(outlineModel.isLocked() ? Images.LOCKED : Images.UNLOCKED, I18n.Text("Switches between allowing editing and not"), () -> {
        OutlineModel model = mOutline.getModel();
        model.setLocked(!model.isLocked());
        mLockButton.setIcon(model.isLocked() ? Images.LOCKED : Images.UNLOCKED);
    });
    mToolbar.add(mLockButton);
    mToolbar.add(new IconButton(Images.TOGGLE_OPEN, I18n.Text("Opens/closes all hierarchical rows"), () -> mOutline.getModel().toggleRowOpenState()));
    mToolbar.add(new IconButton(Images.SIZE_TO_FIT, I18n.Text("Sets the width of each column to exactly fit its contents"), () -> mOutline.sizeColumnsToFit()));
    add(mToolbar, BorderLayout.NORTH);
    mScroller = new JScrollPane(content);
    mScroller.setBorder(null);
    mScroller.setColumnHeaderView(header);
    add(mScroller, BorderLayout.CENTER);
    prefs.getNotifier().add(this, Fonts.FONT_NOTIFICATION_KEY);
    setDropTarget(new DropTarget(mOutline, mOutline));
}
 
Example 8
Source File: EditBox.java    From jaamsim with Apache License 2.0 4 votes vote down vote up
@Override
public void setEntity(Entity entity) {
	if (entity == currentEntity) {
		// Reset the title in case the entity's name has changed
		if (currentEntity != null)
			setTitle("Input Editor - " + currentEntity.getName());
		return;
	}

	if (currentEntity != null) {
		int idx = jTabbedFrame.getSelectedIndex();
		if (idx > -1)
			lastCategory = jTabbedFrame.getTitleAt(idx);
	}

	if (jTabbedFrame == null)
		return;
	jTabbedFrame.removeAll();

	currentEntity = entity;
	if (currentEntity == null) {
		setTitle("Input Editor");
		return;
	}
	setTitle("Input Editor - " + currentEntity.getName());

	int initialTab = 0;
	int curTab = 0;
	editTableList.clear();
	for (CategoryInputs each : getInputs(currentEntity)) {
		EditTableModel mod = new EditTableModel(each);
		EditTable propTable = new EditTable(currentEntity, curTab, mod, columnRender);
		editTableList.add(propTable);
		JScrollPane jScrollPane = new JScrollPane(propTable);
		jScrollPane.getVerticalScrollBar().setUnitIncrement(ROW_HEIGHT);
		jScrollPane.setColumnHeaderView( propTable.getTableHeader());

		jTabbedFrame.addTab(each.category, null, jScrollPane, null);
		if (each.category.equals(lastCategory))
			initialTab = curTab;

		curTab++;
	}

	prevTab = -1;
	if (jTabbedFrame.getTabCount() > 0) {
		jTabbedFrame.setSelectedIndex(initialTab);
		prevTab = initialTab;
	}
}
 
Example 9
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);
}
 
Example 10
Source File: ExportJar.java    From bytecode-viewer with GNU General Public License v3.0 4 votes vote down vote up
public ExportJar(final String jarPath) {
    setSize(new Dimension(250, 277));
    setResizable(false);
    setTitle("Save As Jar..");

    JButton btnNewButton = new JButton("Save As Jar..");
    btnNewButton.setMaximumSize(new Dimension(999, 23));
    btnNewButton.setMinimumSize(new Dimension(999, 23));
    btnNewButton.setSize(new Dimension(999, 0));
    getContentPane().setLayout(
            new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

    JScrollPane scrollPane = new JScrollPane();
    getContentPane().add(scrollPane);

    JLabel lblMetainfmanifestmf = new JLabel("META-INF/MANIFEST.MF:");
    scrollPane.setColumnHeaderView(lblMetainfmanifestmf);

    final JTextArea mani = new JTextArea();
    mani.setText("Manifest-Version: 1.0\r\nClass-Path: .\r\nMain-Class: ");
    scrollPane.setViewportView(mani);
    getContentPane().add(btnNewButton);

    btnNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            BytecodeViewer.viewer.setIcon(true);
            Thread t = new Thread() {
                @Override
                public void run() {
                    JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), jarPath,
                            mani.getText());
                    BytecodeViewer.viewer.setIcon(false);
                }
            };
            t.start();
            dispose();
        }
    });

    this.setLocationRelativeTo(null);
}