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

The following examples show how to use javax.swing.JScrollPane#setViewportBorder() . 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: ThreadDumpWindow.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public ThreadDumpWindow(ThreadDump td) {
    setLayout(new BorderLayout());
    setFocusable(true);
    setRequestFocusEnabled(true);
    setName(Bundle.ThreadDumpWindow_Caption(StringUtils.formatUserDate(td.getTime())));
    setIcon(Icons.getImage(ProfilerIcons.THREAD));

    StringBuilder text = new StringBuilder();
    printThreads(text, td);
    a = new HTMLTextArea() {
        protected void showURL(URL url) {
            if (url == null) {
                return;
            }
            String urls = url.toString();
            ThreadDumpWindow.this.showURL(urls);
        }
    };
    a.setEditorKit(new CustomHtmlEditorKit());
    a.setText(text.toString());
    a.setCaretPosition(0);
    JScrollPane sp = new JScrollPane(a);
    sp.setBorder(BorderFactory.createEmptyBorder());
    sp.setViewportBorder(BorderFactory.createEmptyBorder());
    add(sp, BorderLayout.CENTER);
}
 
Example 2
Source File: XTextAreaPeer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void installDefaults(JScrollPane scrollpane) {
    Border b = scrollpane.getBorder();
    UIDefaults uidefaults = XToolkit.getUIDefaults();
    scrollpane.setBorder(uidefaults.getBorder("ScrollPane.border"));
    scrollpane.setBackground(uidefaults.getColor("ScrollPane.background"));
    scrollpane.setViewportBorder(uidefaults.getBorder("TextField.border"));
    JScrollBar vsb = scrollpane.getVerticalScrollBar();
    if (vsb != null) {
        if (isLeftToRight(scrollpane)) {
            vsbBorder = new CompoundBorder(vsbMarginBorderR,
                                           vsb.getBorder());
        }
        else {
            vsbBorder = new CompoundBorder(vsbMarginBorderL,
                                           vsb.getBorder());
        }
        vsb.setBorder(vsbBorder);
    }

    JScrollBar hsb = scrollpane.getHorizontalScrollBar();
    if (hsb != null) {
        hsbBorder = new CompoundBorder(hsbMarginBorder, hsb.getBorder());
        hsb.setBorder(hsbBorder);
    }
}
 
Example 3
Source File: ThreadDumpWindow.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public ThreadDumpWindow(ThreadDump td) {
    setLayout(new BorderLayout());
    setFocusable(true);
    setRequestFocusEnabled(true);
    setName(Bundle.ThreadDumpWindow_Caption(StringUtils.formatUserDate(td.getTime())));
    setIcon(Icons.getImage(ProfilerIcons.THREAD));

    StringBuilder text = new StringBuilder();
    printThreads(text, td);
    a = new HTMLTextArea() {
        protected void showURL(URL url) {
            if (url == null) {
                return;
            }
            String urls = url.toString();
            ThreadDumpWindow.this.showURL(urls);
        }
    };
    a.setEditorKit(new CustomHtmlEditorKit());
    a.setText(text.toString());
    a.setCaretPosition(0);
    JScrollPane sp = new JScrollPane(a);
    sp.setBorder(BorderFactory.createEmptyBorder());
    sp.setViewportBorder(BorderFactory.createEmptyBorder());
    add(sp, BorderLayout.CENTER);
}
 
Example 4
Source File: XTextAreaPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void installDefaults(JScrollPane scrollpane) {
    Border b = scrollpane.getBorder();
    UIDefaults uidefaults = XToolkit.getUIDefaults();
    scrollpane.setBorder(uidefaults.getBorder("ScrollPane.border"));
    scrollpane.setBackground(uidefaults.getColor("ScrollPane.background"));
    scrollpane.setViewportBorder(uidefaults.getBorder("TextField.border"));
    JScrollBar vsb = scrollpane.getVerticalScrollBar();
    if (vsb != null) {
        if (isLeftToRight(scrollpane)) {
            vsbBorder = new CompoundBorder(vsbMarginBorderR,
                                           vsb.getBorder());
        }
        else {
            vsbBorder = new CompoundBorder(vsbMarginBorderL,
                                           vsb.getBorder());
        }
        vsb.setBorder(vsbBorder);
    }

    JScrollBar hsb = scrollpane.getHorizontalScrollBar();
    if (hsb != null) {
        hsbBorder = new CompoundBorder(hsbMarginBorder, hsb.getBorder());
        hsb.setBorder(hsbBorder);
    }
}
 
Example 5
Source File: OQLControllerUI.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void initComponents() {
    resultsArea = new HTMLTextArea() {
        protected void showURL(URL url) {
            resultsController.showURL(url);
        }
    };

    JScrollPane resultsAreaScroll = new JScrollPane(resultsArea,
                            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    resultsAreaScroll.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5,
                                    UIUtils.getProfilerResultsBackground()));
    resultsAreaScroll.setViewportBorder(BorderFactory.createEmptyBorder());
    resultsAreaScroll.getVerticalScrollBar().setUnitIncrement(10);
    resultsAreaScroll.getHorizontalScrollBar().setUnitIncrement(10);

    JPanel contentsPanel = new JPanel();
    contentsPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, getTitleBorderColor()));
    contentsPanel.setLayout(new BorderLayout());
    contentsPanel.setOpaque(true);
    contentsPanel.setBackground(resultsArea.getBackground());
    contentsPanel.add(resultsAreaScroll, BorderLayout.CENTER);

    setLayout(new BorderLayout());
    add(contentsPanel, BorderLayout.CENTER);
}
 
Example 6
Source File: AttachDialog.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private static void showDetails(RunningVM vm) {
    HTMLTextArea area = new HTMLTextArea();
    JScrollPane areaScroll = new JScrollPane(area, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                                   JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    areaScroll.setBorder(BorderFactory.createEmptyBorder());
    areaScroll.setViewportBorder(BorderFactory.createEmptyBorder());
    areaScroll.setPreferredSize(new Dimension(500, 260));
    configureScrollBar(areaScroll.getVerticalScrollBar());
    configureScrollBar(areaScroll.getHorizontalScrollBar());
    
    area.setText(getDetails(vm));
    area.setCaretPosition(0);
    
    HelpCtx helpCtx = new HelpCtx("ProcessDetails.HelpCtx"); //NOI18N
    JButton close = new JButton(Bundle.AttachDialog_BtnClose());
    close.setDefaultCapable(true);
    DialogDescriptor dd = new DialogDescriptor(areaScroll, Bundle.AttachDialog_DetailsCaption(getProcessName(vm.getMainClass())),
                          true, new Object[] { close }, close, DialogDescriptor.DEFAULT_ALIGN, helpCtx, null);
    Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.pack();
    d.setVisible(true);
}
 
Example 7
Source File: PSheet.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private JScrollPane createScrollPane(Component inner) {
    JScrollPane result = new JScrollPane(inner);
    JViewport vp = result.getViewport();
    vp.addMouseListener(this);

    MarginViewportUI ui = (MarginViewportUI) MarginViewportUI.createUI(vp);
    vp.setUI(ui);
    ui.setMarginPainted(marginPainted);
    ui.setMarginColor(marginColor);
    ui.setEmptyString(emptyString);
    result.setBorder(BorderFactory.createEmptyBorder());
    result.setViewportBorder(result.getBorder());

    return result;
}
 
Example 8
Source File: InternalSourceViewerComponent.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public InternalSourceViewerComponent(String text, int offset, int endOffset, InternalSourceAppearance appearance) {
    super(new BorderLayout());
    
    sourceArea = new SourceArea();
    
    this.appearance = appearance;
    appearance.addListener(this);
    propertyChange(null);
    
    sourceArea.setText(text);
    setOffset(offset, endOffset);
    
    lineNumbersPanel = new JPanel(new BorderLayout());
    lineNumbersPanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 10));
    lineNumbers = new LineNumbers(sourceArea);
    lineNumbersPanel.add(lineNumbers, BorderLayout.EAST);
    
    lineNumbersViewport = new JViewport();
    lineNumbersViewport.setView(lineNumbersPanel);
    lineNumbersViewport.setPreferredSize(lineNumbersPanel.getPreferredSize());
    
    JScrollPane scrollPane = new JScrollPane(sourceArea);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    scrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
    scrollPane.setRowHeader(lineNumbersViewport);
    
    add(scrollPane, BorderLayout.CENTER);
}
 
Example 9
Source File: MBeansAttributesView.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private void initComponents() {
    setLayout(new BorderLayout());
    setOpaque(false);

    JPanel attributes = mbeansTab.getAttributesPanel();

    JScrollPane attributesScrollPane = new JScrollPane(attributes, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    attributesScrollPane.setViewportBorder(BorderFactory.createEmptyBorder());

    add(attributesScrollPane, BorderLayout.CENTER);
}
 
Example 10
Source File: MBeansOperationsView.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private void initComponents() {
    setLayout(new BorderLayout());
    setOpaque(false);

    JPanel operations = mbeansTab.getOperationsPanel();

    JScrollPane operationsScrollPane = new JScrollPane(operations, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    operationsScrollPane.setViewportBorder(BorderFactory.createEmptyBorder());

    add(operationsScrollPane, BorderLayout.CENTER);
}
 
Example 11
Source File: MBeansNotificationsView.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private void initComponents() {
    setLayout(new BorderLayout());
    setOpaque(false);

    JPanel notifications = mbeansTab.getNotificationsPanel();

    JScrollPane notificationsScrollPane = new JScrollPane(notifications, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    notificationsScrollPane.setViewportBorder(BorderFactory.createEmptyBorder());

    add(notificationsScrollPane, BorderLayout.CENTER);
}
 
Example 12
Source File: FeaturesView.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
public FeaturesView(Component defaultView, String buttonString) {
    if (UIUtils.isOracleLookAndFeel()) {
        setOpaque(true);
        setBackground(UIUtils.getProfilerResultsBackground());
    } else {
        setOpaque(false);
    }
    setBorder(BorderFactory.createEmptyBorder());
    setLayout(new BorderLayout(0, 0));
    
    if (defaultView != null) {
        JScrollPane sp = new JScrollPane(defaultView, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) {
            public Dimension getMinimumSize() { return getPreferredSize(); }
        };
        sp.getVerticalScrollBar().setUnitIncrement(20);
        sp.setBorder(null);
        sp.setViewportBorder(null);

        this.defaultView = sp;
        add(this.defaultView, BorderLayout.CENTER);
    } else {
        this.defaultView = null;
    }
    
    if (buttonString != null) {
        hintLabel = new JLabel();
        hintLabel.setIcon(Icons.getIcon(GeneralIcons.INFO));
        hintLabel.setIconTextGap(hintLabel.getIconTextGap() + 1);
        hintLabel.setOpaque(false);
        
        Font font = new JToolTip().getFont();
        
        Color f = hintLabel.getForeground();
        int r = f.getRed() + 70;
        if (r > 255) r = f.getRed() - 70; else r = Math.min(r, 70);
        int g = f.getGreen() + 70;
        if (g > 255) g = f.getRed() - 70; else g = Math.min(g, 70);
        int b = f.getBlue() + 70;
        if (b > 255) b = f.getRed() - 70; else b = Math.min(b, 70);
        hintLabel.setText("<html><body text=\"rgb(" + r + ", " + g + ", " + b + ")\" style=\"font-size: " + //NOI18N
                          (font.getSize()) + "pt; font-family: " + font.getName() + ";\">" + //NOI18N
                          Bundle.FeaturesView_noData("<b>" + buttonString + "</b>") + "</body></html>"); //NOI18N
        
        hintLabel.setSize(hintLabel.getPreferredSize());
        
        Color c = UIUtils.getProfilerResultsBackground();
        hintColor = Utils.checkedColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), 245));
    } else {
        hintColor = null;
    }
}
 
Example 13
Source File: HeaderPanel.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private void initComponents() {
    JTable impl = new JTable(new DefaultTableModel(new Object[] { "" }, 0)); // NOI18N
    TableColumnModel colMod = impl.getColumnModel();
    final TableColumn col = colMod.getColumn(0);
    impl.setFocusable(false);
    header = new Header(colMod);
    impl.setTableHeader(header);
    header.setResizingAllowed(false);
    header.setReorderingAllowed(false);

    final TableCellRenderer renderer = header.getDefaultRenderer();
    header.setDefaultRenderer(new TableCellRenderer() {
        public Component getTableCellRendererComponent(
                JTable table, Object value, boolean isSelected, boolean hasFocus,
                int row, int column) {

            Component component = renderer.getTableCellRendererComponent(
                    table, getRendererValue(), isSelected(),
                    isSelected(), row, processMouseEvents() ? 0 : 1);

            setupRenderer(component);

            col.setWidth(header.getWidth());
            return component;
        }
    });

    JScrollPane scroll = new JScrollPane(impl, JScrollPane.VERTICAL_SCROLLBAR_NEVER,
                                               JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) {
        public Dimension getPreferredSize() { return header.getPreferredSize(); }
        public void reshape(int x, int y, int width, int height) {
            header.setPreferredSize(new Dimension(width, height));
            super.reshape(x, y, width, height);
        }
    };
    scroll.setBorder(BorderFactory.createEmptyBorder());
    scroll.setViewportBorder(BorderFactory.createEmptyBorder());

    setLayout(new OverlayLayout(this));
    add(scroll);
}
 
Example 14
Source File: GlassFishWebModuleViewProvider.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
public GlassfishWebModuleView(GlassFishWebModule webModule) {
            super(webModule, "Overview", NODE_ICON, 0, true);

            module = webModule;
            JPanel masterPanel = new JPanel(new BorderLayout());
            masterPanel.setOpaque(false);
            
            HTMLTextArea generalDataArea = new HTMLTextArea();
            generalDataArea.setText(buildInfo());
            generalDataArea.setBorder(BorderFactory.createEmptyBorder());
//            generalDataArea.setOpaque(false);
            
            JScrollPane generalDataScroll = new JScrollPane(generalDataArea);
            generalDataScroll.setViewportBorder(BorderFactory.createEmptyBorder());
            generalDataScroll.setBorder(BorderFactory.createEmptyBorder());
            generalDataScroll.setOpaque(false);
            
            HTMLLabel appLink = new HTMLLabel("<html><body><h2>Application hosted by <a href=\"#\">" + DataSourceDescriptorFactory.getDescriptor(module.getGlassFishRoot().getApplication()).getName()+ "</a></h2></body></html>") {
                protected void showURL(URL url) {
                    DataSourceWindowManager.sharedInstance().openDataSource(module.getGlassFishRoot().getApplication());
                }
            };
            masterPanel.add(generalDataScroll, BorderLayout.CENTER);
            masterPanel.add(appLink, BorderLayout.NORTH);

            SimpleXYChartDescriptor desc = SimpleXYChartDescriptor.decimal(10, false, 500);
            desc.addLineItems("Current","Maximum");

            activeSessionsChart = ChartFactory.createSimpleXYChart(desc);

            desc = SimpleXYChartDescriptor.decimal(10, true, 500);
            desc.addLineItems("Created","Expired","Rejected");
            totalSessionsChart = ChartFactory.createSimpleXYChart(desc);

            desc = SimpleXYChartDescriptor.decimal(10, false, 500);
            desc.addLineItems("Count","Reloads","Errors");
            jspChart = ChartFactory.createSimpleXYChart(desc);

            JPanel servletsPanel = new JPanel(new BorderLayout());
            servletsPanel.setOpaque(false);
            servletsModel = new ServletTableModel(webModule.getMonitor(), Quantum.seconds(5));

            RowSorter<TableModel> servletsRowSorter = new TableRowSorter<TableModel>(servletsModel);

            StatsTable servletsTable = new StatsTable(servletsModel);
            servletsTable.setRowSorter(servletsRowSorter);

            JScrollPane servletsScroller = new JScrollPane(servletsTable);
            servletsScroller.getViewport().setBackground(generalDataArea.getBackground());
            servletsPanel.add(servletsScroller, BorderLayout.CENTER);

            JPanel wsPanel = new JPanel(new BorderLayout());
            wsPanel.setOpaque(false);
            wsModel = new WSTableModel(webModule.getMonitor(), Quantum.seconds(5));

            RowSorter<TableModel> wsRowSorter = new TableRowSorter<TableModel>(wsModel);

            StatsTable wsTable = new StatsTable(wsModel);
            wsTable.setRowSorter(wsRowSorter);

            JScrollPane wsScroller = new JScrollPane(wsTable);
            wsScroller.getViewport().setBackground(generalDataArea.getBackground());
            wsPanel.add(wsScroller, BorderLayout.CENTER);

            DataViewComponent.MasterView masterView = new DataViewComponent.MasterView("Overview", null, masterPanel);
            DataViewComponent.MasterViewConfiguration masterConfiguration = new DataViewComponent.MasterViewConfiguration(false);
            dvc = new DataViewComponent(masterView, masterConfiguration);
            dvc.configureDetailsArea(new DataViewComponent.DetailsAreaConfiguration("Sessions", true), DataViewComponent.TOP_LEFT);
            dvc.addDetailsView(new DataViewComponent.DetailsView("Sessions Active", null, 10, activeSessionsChart.getChart(), null),
                               DataViewComponent.TOP_LEFT);
            dvc.addDetailsView(new DataViewComponent.DetailsView("Sessions Total", null, 20, totalSessionsChart.getChart(), null),
                               DataViewComponent.TOP_LEFT);

            dvc.configureDetailsArea(new DataViewComponent.DetailsAreaConfiguration("JSPs", true), DataViewComponent.TOP_RIGHT);
            dvc.addDetailsView(new DataViewComponent.DetailsView("JSPs", null, 10, jspChart.getChart(), null), DataViewComponent.TOP_RIGHT);

            dvc.configureDetailsArea(new DataViewComponent.DetailsAreaConfiguration("Runtime", true),
                                     DataViewComponent.BOTTOM_LEFT);
            dvc.addDetailsView(new DataViewComponent.DetailsView("Servlets", null, 10, servletsPanel, null),
                               DataViewComponent.BOTTOM_LEFT);
            dvc.addDetailsView(new DataViewComponent.DetailsView("WebServices", null, 20, wsPanel, null),
                               DataViewComponent.BOTTOM_LEFT);
            
            refreshTask = Scheduler.sharedInstance().schedule(new SchedulerTask() {
                public void onSchedule(long timeStamp) {
                    try {
                        refreshData(timeStamp);
                    } catch (Exception e) {
                        if (!(e instanceof UndeclaredThrowableException)) {
                            Logger.getLogger(GlassFishWebModuleViewProvider.class.getName()).log(Level.INFO,"onSchedule",e);
                        } else {
                            Scheduler.sharedInstance().unschedule(refreshTask);
                            refreshTask = null;
                        }
                    }
                }
            }, Quantum.seconds(5));
        }
 
Example 15
Source File: HeaderPanel.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private void initComponents() {
    JTable impl = new JTable(new DefaultTableModel(new Object[] { "" }, 0)); // NOI18N
    TableColumnModel colMod = impl.getColumnModel();
    final TableColumn col = colMod.getColumn(0);
    impl.setFocusable(false);
    header = new Header(colMod);
    impl.setTableHeader(header);
    header.setResizingAllowed(false);
    header.setReorderingAllowed(false);

    final TableCellRenderer renderer = header.getDefaultRenderer();
    header.setDefaultRenderer(new TableCellRenderer() {
        public Component getTableCellRendererComponent(
                JTable table, Object value, boolean isSelected, boolean hasFocus,
                int row, int column) {

            Component component = renderer.getTableCellRendererComponent(
                    table, getRendererValue(), isSelected(),
                    isSelected(), row, processMouseEvents() ? 0 : 1);

            setupRenderer(component);

            col.setWidth(header.getWidth());
            return component;
        }
    });

    JScrollPane scroll = new JScrollPane(impl, JScrollPane.VERTICAL_SCROLLBAR_NEVER,
                                               JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) {
        public Dimension getPreferredSize() { return header.getPreferredSize(); }
        public void reshape(int x, int y, int width, int height) {
            header.setPreferredSize(new Dimension(width, height));
            super.reshape(x, y, width, height);
        }
    };
    scroll.setBorder(BorderFactory.createEmptyBorder());
    scroll.setViewportBorder(BorderFactory.createEmptyBorder());

    setLayout(new OverlayLayout(this));
    add(scroll);
}
 
Example 16
Source File: ServerSetupPanel.java    From triplea with GNU General Public License v3.0 4 votes vote down vote up
private void layoutPlayers() {
  final JPanel players = new JPanel();
  final GridBagLayout layout = new GridBagLayout();
  players.setLayout(layout);
  final Insets spacing = new Insets(3, 16, 0, 0);
  final Insets lastSpacing = new Insets(3, 16, 0, 16);
  int gridx = 0;
  final boolean disableable =
      !model.getPlayersAllowedToBeDisabled().isEmpty()
          || model.getPlayersEnabledListing().containsValue(Boolean.FALSE);
  final GridBagConstraints enabledPlayerConstraints = new GridBagConstraints();
  if (disableable) {
    enabledPlayerConstraints.anchor = GridBagConstraints.WEST;
    enabledPlayerConstraints.gridx = gridx++;
    enabledPlayerConstraints.insets = new Insets(3, 20, 0, -10);
  }
  final GridBagConstraints nameConstraints = new GridBagConstraints();
  nameConstraints.anchor = GridBagConstraints.WEST;
  nameConstraints.gridx = gridx++;
  nameConstraints.insets = spacing;
  final GridBagConstraints playerConstraints = new GridBagConstraints();
  playerConstraints.anchor = GridBagConstraints.WEST;
  playerConstraints.gridx = gridx++;
  playerConstraints.insets = spacing;
  final GridBagConstraints localConstraints = new GridBagConstraints();
  localConstraints.anchor = GridBagConstraints.WEST;
  localConstraints.gridx = gridx++;
  localConstraints.insets = spacing;
  final GridBagConstraints typeConstraints = new GridBagConstraints();
  typeConstraints.anchor = GridBagConstraints.WEST;
  typeConstraints.gridx = gridx++;
  typeConstraints.insets = spacing;
  final GridBagConstraints allianceConstraints = new GridBagConstraints();
  allianceConstraints.anchor = GridBagConstraints.WEST;
  allianceConstraints.gridx = gridx;
  allianceConstraints.insets = lastSpacing;
  if (disableable) {
    final JLabel enableLabel = new JLabel("Use");
    enableLabel.setForeground(Color.black);
    layout.setConstraints(enableLabel, enabledPlayerConstraints);
    players.add(enableLabel);
  }
  final JLabel nameLabel = new JLabel("Name");
  nameLabel.setForeground(Color.black);
  layout.setConstraints(nameLabel, nameConstraints);
  players.add(nameLabel);
  final JLabel playedByLabel = new JLabel("Played by");
  playedByLabel.setForeground(Color.black);
  layout.setConstraints(playedByLabel, playerConstraints);
  players.add(playedByLabel);
  final JLabel localLabel = new JLabel("Local");
  localLabel.setForeground(Color.black);
  layout.setConstraints(localLabel, localConstraints);
  players.add(localLabel);
  final JLabel typeLabel = new JLabel("Type");
  typeLabel.setForeground(Color.black);
  layout.setConstraints(typeLabel, typeConstraints);
  players.add(typeLabel);
  final JLabel allianceLabel = new JLabel("Alliance");
  allianceLabel.setForeground(Color.black);
  layout.setConstraints(allianceLabel, allianceConstraints);
  players.add(allianceLabel);
  if (playerRows.isEmpty()) {
    final JLabel noPlayers = new JLabel("Load a game file first");
    layout.setConstraints(noPlayers, nameConstraints);
    players.add(noPlayers);
  }
  for (final PlayerRow row : playerRows) {
    if (disableable) {
      layout.setConstraints(row.getEnabledPlayer(), enabledPlayerConstraints);
      players.add(row.getEnabledPlayer());
    }
    layout.setConstraints(row.getName(), nameConstraints);
    players.add(row.getName());
    layout.setConstraints(row.getPlayer(), playerConstraints);
    players.add(row.getPlayer());
    layout.setConstraints(row.getLocal(), localConstraints);
    players.add(row.getLocal());
    layout.setConstraints(row.getType(), typeConstraints);
    players.add(row.getType());
    layout.setConstraints(row.getAlliance(), allianceConstraints);
    players.add(row.getAlliance());
    row.getAlliance().addActionListener(e -> allianceRowButtonFired(row));
  }
  removeAll();
  add(info, BorderLayout.NORTH);
  final JScrollPane scroll =
      new JScrollPane(
          players,
          ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
          ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  scroll.setBorder(null);
  scroll.setViewportBorder(null);
  add(scroll, BorderLayout.CENTER);
  add(networkPanel, BorderLayout.SOUTH);
  invalidate();
  validate();
}
 
Example 17
Source File: OverviewControllerUI.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private void initComponents() {
    // dataArea
    dataArea = new HTMLTextArea() {
        protected void showURL(URL url) {
            if (url == null) return;
            String urls = url.toString();
            if (urls.equals(OverviewController.SHOW_SYSPROPS_URL)) {
                showSysprops = true;
                refreshSummary();
            } else if (urls.equals(OverviewController.SHOW_THREADS_URL)) {
                showThreads = true;
                refreshSummary();
            } else {
                overviewController.showURL(urls);
            }
        }
    };
    dataArea.setEditorKit(new CustomHtmlEditorKit());
    dataArea.setSelectionColor(UIConstants.TABLE_SELECTION_BACKGROUND_COLOR);
    JScrollPane dataAreaScrollPane = new JScrollPane(dataArea,
                            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    dataAreaScrollPane.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5,
                                    UIUtils.getProfilerResultsBackground()));
    dataAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
    dataAreaScrollPane.getVerticalScrollBar().setUnitIncrement(10);
    dataAreaScrollPane.getHorizontalScrollBar().setUnitIncrement(10);

    JPanel contentsPanel = new JPanel();
    contentsPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, getTitleBorderColor()));
    contentsPanel.setLayout(new BorderLayout());
    contentsPanel.setOpaque(true);
    contentsPanel.setBackground(dataArea.getBackground());
    contentsPanel.add(dataAreaScrollPane, BorderLayout.CENTER);

    setLayout(new BorderLayout());
    add(contentsPanel, BorderLayout.CENTER);
    
    // UI tweaks
    setBackground(dataArea.getBackground());
}
 
Example 18
Source File: DetailsPanel.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private void initComponents() {        
    table = new DetailsTable();
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JViewport viewport = new Viewport(table);

    final JScrollPane tableScroll = new JScrollPane(
                                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                        JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    tableScroll.setViewport(viewport);
    tableScroll.setBorder(BorderFactory.createEmptyBorder());
    tableScroll.setViewportBorder(BorderFactory.createEmptyBorder());
    tableScroll.setCorner(JScrollPane.UPPER_RIGHT_CORNER, new HeaderPanel());
    
    scrollBar = new ScrollBar(JScrollBar.VERTICAL) {
        public int getUnitIncrement(int direction) {
            JViewport vp = tableScroll.getViewport();
            Scrollable view = (Scrollable)(vp.getView());
            Rectangle vr = vp.getViewRect();
            return view.getScrollableUnitIncrement(vr, getOrientation(), direction);
        }
        public int getBlockIncrement(int direction) {
            JViewport vp = tableScroll.getViewport();
            Scrollable view = (Scrollable)(vp.getView());
            Rectangle vr = vp.getViewRect();
            return view.getScrollableBlockIncrement(vr, getOrientation(), direction);
        }
        public void setValues(int newValue, int newExtent, int newMin, int newMax) {
            setEnabled(newExtent < newMax);
            if (isEnabled() && !isSelectionChanging() && isTrackingEnd())
                newValue = newMax - newExtent;
            super.setValues(newValue, newExtent, newMin, newMax);
        }
    };
    tableScroll.setVerticalScrollBar(scrollBar);
    dataContainer = tableScroll;

    JLabel noDataLabel = new JLabel("<No probe selected>", JLabel.CENTER);
    noDataLabel.setEnabled(false);
    noDataContainer = new JPanel(new BorderLayout());
    noDataContainer.setOpaque(false);
    noDataContainer.add(noDataLabel, BorderLayout.CENTER);

    setOpaque(false);
    setLayout(new BorderLayout());
    add(noDataContainer, BorderLayout.CENTER);
}
 
Example 19
Source File: ContextView.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * 
 * @author  Tim Boudreau
 * @author  Marian Petras
 */
public ContextView(ResultModel resultModel,
        ExplorerManager explorerManager) {
    Border b = BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(        //outside border
                            0, 0, 1, 0, 
                            UIManager.getColor("controlShadow")),   //NOI18N
            BorderFactory.createEmptyBorder(        //inside border
                            5, 5, 1, 5));
    lblPath.setBorder(b);
    
    editorPane.setEditable(false);
    editorPane.getCaret().setBlinkRate(0);
    
    editorScroll = new JScrollPane(editorPane);
    editorScroll.setViewportBorder(BorderFactory.createEmptyBorder());
    editorScroll.setBorder(BorderFactory.createEmptyBorder());
    
    JPanel fileViewPanel = new JPanel();
    fileViewPanel.setLayout(new BorderLayout());
    fileViewPanel.add(lblPath, BorderLayout.NORTH);
    fileViewPanel.add(editorScroll, BorderLayout.CENTER);
    
    Box messagePanel = Box.createVerticalBox();
    messagePanel.add(Box.createVerticalGlue());
    messagePanel.add(lblMessage);
    messagePanel.add(Box.createVerticalGlue());
    lblMessage.setAlignmentX(0.5f);
    lblMessage.setHorizontalAlignment(SwingConstants.CENTER);
    lblMessage.setEnabled(false);
    
    setLayout(cardLayout = new CardLayout());
    add(fileViewPanel, FILE_VIEW);
    add(messagePanel, MESSAGE_VIEW);
    
    setResultModel(resultModel);

    this.explorerManager = explorerManager;
    explorerManager.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("selectedNodes")) {
                updateForSelection();
            }
        }
    });
}
 
Example 20
Source File: CustomScroll.java    From mars-sim with GNU General Public License v3.0 3 votes vote down vote up
public CustomScroll(JComponent component) {
        scr = new JScrollPane(component);
        scr.setBorder(null);
        scr.setViewportBorder(null);
        scr.setBorder(BorderFactory.createEmptyBorder());
        scr.getViewport().setOpaque(false);
//        scr.setOpaque(false);
//        scr.setBackground(new Color(0, 0, 0, 5));
        verticalScrollBar = scr.getVerticalScrollBar();
        verticalScrollBar.setVisible(false);
        verticalScrollBar.setOpaque(false);
        verticalScrollBar.setUI(new MyScrollBarUI());
        verticalScrollBar.setUnitIncrement(16);

        horizontalScrollBar = scr.getHorizontalScrollBar();
        horizontalScrollBar.setVisible(false);
        horizontalScrollBar.setOpaque(false);
        horizontalScrollBar.setUI(new MyScrollBarUI());

        JLayeredPane layeredPane = new JLayeredPane();
        layeredPane.setLayer(verticalScrollBar, JLayeredPane.PALETTE_LAYER);
        layeredPane.setLayer(horizontalScrollBar, JLayeredPane.PALETTE_LAYER);

        scr.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
        scr.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        scr.setLayout(new ScrollPaneLayout() {
            @Override
            public void layoutContainer(Container parent) {
                viewport.setBounds(0, 0, getWidth(), getHeight());
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        displayScrollBarsIfNecessary(viewport);
                    }
                });
            }
        });

        layeredPane.add(horizontalScrollBar);
        layeredPane.add(verticalScrollBar);
        layeredPane.add(scr);

        setLayout(new BorderLayout() {
            @Override
            public void layoutContainer(Container target) {
                super.layoutContainer(target);
                int width = getWidth();
                int height = getHeight();
                scr.setBounds(0, 0, width, height);

                int scrollBarSize = 10;
                int cornerOffset = verticalScrollBar.isVisible() &&
                        horizontalScrollBar.isVisible() ? scrollBarSize : 0;
                if (verticalScrollBar.isVisible()) {
                    verticalScrollBar.setBounds(width - scrollBarSize, 0,
                            scrollBarSize, height - cornerOffset);
                }
                if (horizontalScrollBar.isVisible()) {
                    horizontalScrollBar.setBounds(0, height - scrollBarSize,
                            width - cornerOffset, scrollBarSize);
                }
            }
        });
        add(layeredPane, BorderLayout.CENTER);
        layeredPane.setBackground(Color.BLUE);
    }