Java Code Examples for javax.swing.JPanel#setOpaque()

The following examples show how to use javax.swing.JPanel#setOpaque() . 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: MapPanel.java    From osv with GNU General Public License v3.0 6 votes vote down vote up
public MapPanel(MainWindow mw) {

		this.mw = mw;
		this.setOpaque(false);

		cp = new JPanel();
		cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS));
		cp.setOpaque(false);
		verticalSpace = new OSVEmptyPanel(mw, 0, 0.28f);
		cp.add(verticalSpace);

		mapDisplay = new MapDisplay();
		mapDisplay.setOpaque(false);

		cp.add(mapDisplay);

		add(cp);
	}
 
Example 2
Source File: SimpleInternalFrame.java    From chipster with MIT License 6 votes vote down vote up
/**
 * Creates and answers the header panel, that consists of:
 * an icon, a title label, a tool bar, and a gradient background.
 * 
 * @param label   the label to paint the icon and text
 * @param bar     the panel's tool bar
 * @return the panel's built header area
 */
private JPanel buildHeader(JLabel label, JToolBar bar) {
    if(paintGradient){
    	gradientPanel =
    		new GradientPanel(new BorderLayout(), getHeaderBackground());
    } else {
    	gradientPanel = new JPanel(new BorderLayout());
    }
    label.setOpaque(false);

    gradientPanel.add(label, BorderLayout.WEST);
    gradientPanel.setBorder(BorderFactory.createEmptyBorder(3, 4, 3, 1));
    headerPanel = new JPanel(new BorderLayout());
    headerPanel.add(gradientPanel, BorderLayout.CENTER);
    setToolBar(bar);
    if(paintTitleBorder){
    	headerPanel.setBorder(new RaisedHeaderBorder());
    }
    headerPanel.setOpaque(false);
    return headerPanel;
}
 
Example 3
Source File: RegressionTaskManagerPanel.java    From moa with GNU General Public License v3.0 6 votes vote down vote up
private static void createAndShowGUI() {

        // Create and set up the window.
        JFrame frame = new JFrame("Test");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // Create and set up the content pane.
        JPanel panel = new RegressionTaskManagerPanel();
        panel.setOpaque(true); // content panes must be opaque
        frame.setContentPane(panel);

        // Display the window.
        frame.pack();
        // frame.setSize(400, 400);
        frame.setVisible(true);
    }
 
Example 4
Source File: StopwatchProfilingPoint.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void initComponents() {
    setLayout(new BorderLayout());

    JPanel contentsPanel = new JPanel(new BorderLayout());
    contentsPanel.setBackground(UIUtils.getProfilerResultsBackground());
    contentsPanel.setOpaque(true);
    contentsPanel.setBorder(BorderFactory.createMatteBorder(0, 15, 15, 15, UIUtils.getProfilerResultsBackground()));

    headerArea = new HTMLTextArea() {
            protected void showURL(URL url) {
                String urlString = url.toString();

                if (START_LOCATION_URLMASK.equals(urlString)) {
                    Utils.openLocation(StopwatchProfilingPoint.this.getStartLocation());
                } else if (StopwatchProfilingPoint.this.usesEndLocation()) {
                    Utils.openLocation(StopwatchProfilingPoint.this.getEndLocation());
                }
            }
        };

    JScrollPane headerAreaScrollPane = new JScrollPane(headerArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                                       JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    headerAreaScrollPane.setBorder(BorderFactory.createMatteBorder(0, 0, 15, 0, UIUtils.getProfilerResultsBackground()));
    headerAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
    contentsPanel.add(headerAreaScrollPane, BorderLayout.NORTH);

    dataArea = new HTMLTextArea();

    JScrollPane dataAreaScrollPane = new JScrollPane(dataArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    TitledBorder tb = new TitledBorder(Bundle.StopwatchProfilingPoint_DataString());
    tb.setTitleFont(Utils.getTitledBorderFont(tb).deriveFont(Font.BOLD));
    tb.setTitleColor(javax.swing.UIManager.getColor("Label.foreground")); // NOI18N
    dataAreaScrollPane.setBorder(tb);
    dataAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
    dataAreaScrollPane.setBackground(UIUtils.getProfilerResultsBackground());
    contentsPanel.add(dataAreaScrollPane, BorderLayout.CENTER);

    add(contentsPanel, BorderLayout.CENTER);
}
 
Example 5
Source File: ContentsPanel.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private void addLink( String resourceKey, boolean includeSource, boolean drawBottom, boolean drawRight ) {
    JPanel panel = new JPanel(new BorderLayout());
    panel.setOpaque( false );
    panel.add( new WebLink(resourceKey, includeSource), BorderLayout.CENTER );
    panel.setBorder( new MyBorder(drawBottom, drawRight) );
    add( panel );
}
 
Example 6
Source File: PopupMenuDemo.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public Container createContentPane() {
    // Create the content-pane-to-be.
    JPanel contentPane = new JPanel(new BorderLayout());
    contentPane.setOpaque(true);

    // Create a scrolled text area.
    output = new JTextArea(5, 30);
    output.setEditable(false);
    scrollPane = new JScrollPane(output);

    // Add the text area to the content pane.
    contentPane.add(scrollPane, BorderLayout.CENTER);

    return contentPane;
}
 
Example 7
Source File: CursorOverlappedPanelsTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static JPanel createPanel(Point location, boolean enabled) {
    final JPanel panel = new JPanel();
    panel.setOpaque(false);
    panel.setEnabled(enabled);
    panel.setSize(new Dimension(200, 200));
    panel.setLocation(location);
    panel.setBorder(BorderFactory.createTitledBorder(
            enabled ? "Enabled" : "Disabled"));
    panel.setCursor(Cursor.getPredefinedCursor(
            enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
    System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
    return panel;
}
 
Example 8
Source File: ChooseKnowledgeDialog.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
private void initializeGui(Component parent, List<KnowledgeDescription> knowledgeDescriptions, ImageInfoReader imageInfoReader, SoundIdReader soundIdReader, JFrame parentFrame) {
	knowledgeTable = JTableFactory.createJTable(new KnowledgeModel(knowledgeDescriptions));
	knowledgeTable.setDefaultRenderer(ImageIds.class, new ImageCellRenderer(imageInfoReader));
	knowledgeTable.setDefaultRenderer(String.class, new DefaultTableCellRenderer());
	knowledgeTable.setRowHeight(50);
	knowledgeTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
	knowledgeTable.getColumnModel().getColumn(0).setPreferredWidth(30);
	knowledgeTable.getColumnModel().getColumn(1).setPreferredWidth(50);
	knowledgeTable.getColumnModel().getColumn(2).setPreferredWidth(500);
	knowledgeTable.getColumnModel().getColumn(0).setHeaderValue(" ");
	knowledgeTable.getColumnModel().getColumn(1).setHeaderValue(" ");
	knowledgeTable.getColumnModel().getColumn(2).setHeaderValue(" ");
	knowledgeTable.getTableHeader().setReorderingAllowed(false);
	
	JScrollPane scrollPane = JScrollPaneFactory.createScrollPane(knowledgeTable);
	scrollPane.setBounds(5, 5, 585, 510);
	this.addComponent(scrollPane);
	SwingUtils.makeTransparant(knowledgeTable, scrollPane);
	
	JPanel buttonPane = new JPanel(new BorderLayout());
	buttonPane.setBounds(5, 540, 585, 40);
	buttonPane.setOpaque(false);
	this.addComponent(buttonPane);
	
	okButton = JButtonFactory.createButton("OK", imageInfoReader, soundIdReader);
	okButton.setActionCommand("OK");
	buttonPane.add(okButton, BorderLayout.EAST);
	getRootPane().setDefaultButton(okButton);
	
	DialogUtils.createDialogBackPanel(this, parentFrame.getContentPane());
}
 
Example 9
Source File: EncryptOneView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
public static JPanel wrapIntoMessagePanel(JComponent comp, Color color) {
	JPanel pnlPadding = new JPanel(new BorderLayout());
	pnlPadding.setBorder(BorderFactory.createLineBorder(Color.yellow.darker(), 1, true));
	JPanel pnlMsg = new JPanel(new BorderLayout());
	pnlMsg.setOpaque(false);
	pnlPadding.add(pnlMsg);
	int charHalfWidth = UiUtils.getFontRelativeSize(1) / 2;
	pnlMsg.setBorder(BorderFactory.createEmptyBorder(charHalfWidth / 2, 5, charHalfWidth / 2, 5));
	comp.setOpaque(false);
	pnlMsg.add(comp);
	pnlPadding.setBackground(color);
	return pnlPadding;
}
 
Example 10
Source File: CustomizedToolbarDemo.java    From pumpernickel with MIT License 5 votes vote down vote up
public CustomizedToolbarDemo() {

		for (int a = 0; a < list.length; a++) {
			list[a].setName("" + a); // give every component a unique name
			list[a].setOpaque(false);
		}

		ActionListener showCustomizeAction = new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				toolbar.displayDialog(JVM.isMac ? 350 : 280);
			}
		};
		customize.addActionListener(showCustomizeAction);

		setLayout(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();
		c.gridx = 0;
		c.gridy = 0;
		c.weightx = 1;
		c.weighty = 0;
		c.fill = GridBagConstraints.HORIZONTAL;
		add(toolbar, c);
		c.gridy++;
		c.weighty = 1;
		c.fill = GridBagConstraints.BOTH;
		JPanel fluff = new JPanel();
		fluff.setBorder(new PartialLineBorder(Color.lightGray, new Insets(1, 0,
				0, 0)));
		fluff.setUI(new TexturePaintPanelUI(PlafPaintUtils.getCheckerBoard(3)));
		fluff.setOpaque(false);
		add(fluff, c);
	}
 
Example 11
Source File: CursorOverlappedPanelsTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static JPanel createPanel(Point location, boolean enabled) {
    final JPanel panel = new JPanel();
    panel.setOpaque(false);
    panel.setEnabled(enabled);
    panel.setSize(new Dimension(200, 200));
    panel.setLocation(location);
    panel.setBorder(BorderFactory.createTitledBorder(
            enabled ? "Enabled" : "Disabled"));
    panel.setCursor(Cursor.getPredefinedCursor(
            enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
    System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
    return panel;
}
 
Example 12
Source File: MenuLookDemo.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public Container createContentPane() {
    // Create the content-pane-to-be.
    JPanel contentPane = new JPanel(new BorderLayout());
    contentPane.setOpaque(true);

    // Create a scrolled text area.
    output = new JTextArea(5, 30);
    output.setEditable(false);
    scrollPane = new JScrollPane(output);

    // Add the text area to the content pane.
    contentPane.add(scrollPane, BorderLayout.CENTER);

    return contentPane;
}
 
Example 13
Source File: SimpleCameraDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public JPanel getComponent(int width, int height) throws IOException {
	// the main panel
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new GridBagLayout());
	vc = new VideoCaptureComponent(640, 480);
	base.add(vc);

	return base;
}
 
Example 14
Source File: CostPanel.java    From magarena with GNU General Public License v3.0 4 votes vote down vote up
public CostPanel(final MagicManaCost cost) {

        setOpaque(false);
        setLayout(new BorderLayout());

        if (cost == null) {
            return;
        }

        final JPanel centerPanel=new JPanel();
        centerPanel.setOpaque(false);

        final SpringLayout springLayout = new SpringLayout();
        centerPanel.setLayout(springLayout);

        final List<MagicIcon> icons = cost.getIcons();

        final JLabel[] manaLabels=new JLabel[icons.size()];
        for (int i=0;i<manaLabels.length;i++) {

            manaLabels[i]=new JLabel();
            manaLabels[i].setPreferredSize(MANA_ICON_SIZE);
            manaLabels[i].setMaximumSize(MANA_ICON_SIZE);
            manaLabels[i].setHorizontalAlignment(JLabel.CENTER);

            if (i > 0) {
                // previous (left) mana touches current one
                springLayout.putConstraint(SpringLayout.EAST, manaLabels[i-1],
                             0, SpringLayout.WEST, manaLabels[i]);
            }
            if (i == manaLabels.length - 1) {
                // last mana touches right side of panel
                springLayout.putConstraint(SpringLayout.EAST, manaLabels[i],
                             0, SpringLayout.EAST, centerPanel);
            }

            centerPanel.add(manaLabels[i]);
        }
        int index=0;
        for (final MagicIcon icon : icons) {
            manaLabels[index++].setIcon(MagicImages.getIcon(icon));
            if (index==manaLabels.length) {
                break;
            }
        }
        add(centerPanel,BorderLayout.CENTER);
    }
 
Example 15
Source File: EditTrafficModelControlPanel.java    From VanetSim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor, creating GUI items.
 */
public EditTrafficModelControlPanel() {
	setLayout(new GridBagLayout());
	
	// global layout settings
	GridBagConstraints c = new GridBagConstraints();
	c.fill = GridBagConstraints.BOTH;
	c.anchor = GridBagConstraints.PAGE_START;
	c.weightx = 0.5;
	c.gridx = 0;
	c.gridy = 0;
	c.gridheight = 1;
	
	c.gridwidth = 1;

	c.insets = new Insets(5,5,5,5);
	
	c.gridx = 0;
	
	// Radio buttons to select add, edit or delete mode
	ButtonGroup group = new ButtonGroup();
	selectModel_ = new JRadioButton(Messages.getString("EditTrafficControlPanel.model")); //$NON-NLS-1$
	selectModel_.setActionCommand("model"); //$NON-NLS-1$
	selectModel_.addActionListener(this);
	selectModel_.setSelected(true);
	group.add(selectModel_);
	++c.gridy;
	add(selectModel_,c);
			
	selectTraces_ = new JRadioButton(Messages.getString("EditTrafficControlPanel.traces")); //$NON-NLS-1$
	selectTraces_.setActionCommand("traces"); //$NON-NLS-1$
	selectTraces_.addActionListener(this);
	group.add(selectTraces_);
	++c.gridy;
	add(selectTraces_,c);
		
	
	c.gridx = 0;
	chooseTrafficModelLabel_ = new JLabel(Messages.getString("EditTrafficControlPanel.comboBoxModel")); //$NON-NLS-1$
	++c.gridy;
	add(chooseTrafficModelLabel_,c);
	chooseTrafficModel_ = new JComboBox<String>();
	chooseTrafficModel_.setActionCommand("chooseTrafficModel");
	chooseTrafficModel_.addItem("VANETSim classic");
	chooseTrafficModel_.addItem("IDM/MOBIL");
	chooseTrafficModel_.addActionListener(this);
	c.gridx = 1;
	add(chooseTrafficModel_, c);
	
	
	c.gridx = 0;
	chooseTracesLabel_ = new JLabel(Messages.getString("EditTrafficControlPanel.comboBoxTraces")); //$NON-NLS-1$
	++c.gridy;
	add(chooseTracesLabel_,c);
	chooseTraces_ = new JComboBox<String>();
	chooseTraces_.setActionCommand("chooseTraces");
	chooseTraces_.addItem("sjtu taxi traces");
	chooseTraces_.addItem("San Francisco traces");
	chooseTraces_.addActionListener(this);
	c.gridx = 1;
	add(chooseTraces_, c);
	chooseTraces_.setVisible(false);
	chooseTracesLabel_.setVisible(false);
	
	
	
	//to consume the rest of the space
	c.weighty = 1.0;
	++c.gridy;
	JPanel space = new JPanel();
	space.setOpaque(false);
	add(space, c);
}
 
Example 16
Source File: FirstContactDialog.java    From freecol with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create an FirstContactDialog.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 * @param frame The owner frame.
 * @param player The {@code Player} making contact.
 * @param other The {@code Player} to contact.
 * @param tile An optional {@code Tile} on offer.
 * @param settlementCount The number of settlements the other
 *     player has.
 */
public FirstContactDialog(FreeColClient freeColClient, JFrame frame,
        Player player, Player other, Tile tile, int settlementCount) {
    super(freeColClient, frame);

    JPanel panel = new MigPanel(new MigLayout("wrap 1", "[center]", "[]20"));
    panel.setOpaque(false);

    String headerKey = BASE_KEY + other.getNation().getSuffix();
    if (!Messages.containsKey(headerKey)) headerKey = BASE_KEY + NATIVES;
    JLabel header = Utility.localizedHeaderLabel(headerKey,
        SwingConstants.LEADING, FontLibrary.FontSize.MEDIUM);
    JLabel image = new JLabel(new ImageIcon(ImageLibrary
            .getMeetingImage(other)));
    image.setOpaque(false);

    JTextArea tutorial = null;
    if (!player.hasContactedIndians() && freeColClient.tutorialMode()) {
        tutorial = Utility.localizedTextArea(TUTORIAL_KEY);
    }

    String messageId = (tile != null)
        ? "firstContactDialog.welcomeOffer.text"
        : "firstContactDialog.welcomeSimple.text";
    String type = ((IndianNationType)other.getNationType())
        .getSettlementTypeKey(true);
    JTextArea text = Utility.localizedTextArea(StringTemplate
        .template(messageId)
        .addStringTemplate("%nation%", other.getNationLabel())
        .addName("%camps%", Integer.toString(settlementCount))
        .add("%settlementType%", type));

    // Resize the text areas to better match the image.
    int columns = (int)Math.floor(text.getColumns()
        * image.getPreferredSize().getWidth()
        / text.getPreferredSize().getWidth());
    text.setColumns(columns);
    text.setSize(text.getPreferredSize());
    if (tutorial != null) {
        tutorial.setColumns(columns);
        tutorial.setSize(tutorial.getPreferredSize());
    }

    panel.add(header);
    panel.add(image);
    if (tutorial != null) panel.add(tutorial);
    panel.add(text);
    panel.setSize(panel.getPreferredSize());

    ImageIcon icon = new ImageIcon(getImageLibrary()
        .getScaledNationImage(other.getNation()));
    initializeConfirmDialog(frame, false, panel, icon, "yes", "no");
}
 
Example 17
Source File: FeaturesView.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private JPanel createContainer(ProfilerFeature feature) {
    JPanel container = new JPanel(new BorderLayout(0, 0));
    container.putClientProperty(ProfilerFeature.class, feature);
    
    JPanel results = feature.getResultsUI();
    JPanel xresults = new JPanel(new BorderLayout()) {
        public void paint(Graphics g) {
            super.paint(g);
            if (hintLabel != null) {
                Dimension dim = hintLabel.getSize();
                int x = (getWidth() - dim.width) / 2;
                int y = (getHeight() - dim.height) / 2;
                
                g.setColor(hintColor);
                g.fillRect(x - XMAR, y - YMAR, dim.width + XMAR * 2, dim.height + YMAR * 2);
                g.setColor(Color.LIGHT_GRAY);
                g.drawRect(x - XMAR, y - YMAR, dim.width + XMAR * 2, dim.height + YMAR * 2);
                
                g.translate(x, y);
                hintLabel.paint(g);
                g.translate(-x, -y);
            }
        }
    };
    xresults.add(results, BorderLayout.CENTER);
    container.add(xresults, BorderLayout.CENTER);
    
    JPanel settings = feature.getSettingsUI();
    if (settings != null) {
        JPanel pan = new JPanel(new BorderLayout(0, 0)) {
            public void setVisible(boolean visible) {
                super.setVisible(visible);
                for (Component c : getComponents()) c.setVisible(visible);
            }
        };
        pan.setOpaque(true);
        pan.setBackground(UIUtils.getProfilerResultsBackground());
        pan.add(settings, BorderLayout.CENTER);
        JSeparator sep = UIUtils.createHorizontalLine(pan.getBackground());
        pan.add(sep, BorderLayout.SOUTH);
        pan.setVisible(settings.isVisible());
        container.add(pan, BorderLayout.NORTH);
    }
    
    return container;
}
 
Example 18
Source File: PreferencePanel.java    From pumpernickel with MIT License 4 votes vote down vote up
public PreferencePanel(String defaultTitle) {
	super();
	new WindowDragger(header);
	this.defaultTitle = defaultTitle;
	setLayout(new GridBagLayout());
	separator.setOpaque(false);
	separator.setUI(new HairSeparatorUI());
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.weightx = 0;
	c.weighty = 1;
	c.insets = new Insets(2, 2, 2, 0);
	c.fill = GridBagConstraints.VERTICAL;
	header.add(prevButton, c);
	c.gridx++;
	c.insets = new Insets(2, 0, 2, 2);
	header.add(nextButton, c);
	c.gridx++;
	c.insets = new Insets(2, 2, 2, 2);
	header.add(homeButton, c);
	c.gridx++;
	JPanel fluff = new JPanel();
	fluff.setOpaque(false);
	c.weightx = 1;
	header.add(fluff, c);
	repack();

	if (isMac) {
		homeButton.putClientProperty("JButton.buttonType",
				"segmentedTextured");
	} else {
		homeButton.setUI(new BevelButtonUI());
	}

	prevButton.putClientProperty("JButton.segmentPosition", "first");
	nextButton.putClientProperty("JButton.segmentPosition", "last");
	homeButton.putClientProperty("JButton.segmentPosition", "only");

	navigationStack.add(homeButton);

	prevButton.addActionListener(navigationListener);
	nextButton.addActionListener(navigationListener);
	homeButton.addActionListener(navigationListener);

	if (isMac) {
		header.setUI(new GradientHeaderUI());
		separator.setForeground(new Color(64, 64, 64));
	}
}
 
Example 19
Source File: ImageInfoEditor2.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private JPanel createStxOverlayComponent() {
    JPanel stxOverlayComponent = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    stxOverlayComponent.setOpaque(false);

    final ImageInfoEditorModel model = getModel();
    if (!showExtraInfo || model == null) {
        return stxOverlayComponent;
    }

    stxOverlayComponent.setBorder(new EmptyBorder(4, 0, 0, 8));

    JComponent labels = new JComponent() {
        @Override
        protected void paintComponent(Graphics g) {
            g.setColor(getBackground());
            g.fillRect(0, 0, getWidth(), getHeight());
        }
    };
    labels.setBorder(new EmptyBorder(0, 2, 0, 2));
    labels.setLayout(new GridLayout(-1, 1));
    labels.setBackground(new Color(255, 255, 255, 127));
    stxOverlayComponent.add(labels);

    labels.add(new JLabel("Name: " + model.getParameterName()));
    labels.add(new JLabel("Unit: " + model.getParameterUnit()));

    final Stx stx = model.getSampleStx();
    if (stx == null) {
        return stxOverlayComponent;
    }

    labels.add(new JLabel("Min: " + getValueForDisplay(model.getMinSample())));
    labels.add(new JLabel("Max: " + getValueForDisplay(model.getMaxSample())));
    if (stx.getResolutionLevel() > 0 && model.getSampleScaling() == Scaling.IDENTITY) {
        final ActionLabel label = new ActionLabel("Rough statistics!");
        label.setToolTipText("Click to compute accurate statistics.");
        label.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                askUser();
            }
        });
        labels.add(label);
    }

    return stxOverlayComponent;
}
 
Example 20
Source File: TriggeredTakeSnapshotProfilingPoint.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void initComponents() {
    setLayout(new BorderLayout());

    JPanel contentsPanel = new JPanel(new BorderLayout());
    contentsPanel.setBackground(UIUtils.getProfilerResultsBackground());
    contentsPanel.setOpaque(true);
    contentsPanel.setBorder(BorderFactory.createMatteBorder(0, 15, 15, 15, UIUtils.getProfilerResultsBackground()));

    headerArea = new HTMLTextArea();

    JScrollPane headerAreaScrollPane = new JScrollPane(headerArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                                       JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    headerAreaScrollPane.setBorder(BorderFactory.createMatteBorder(0, 0, 15, 0, UIUtils.getProfilerResultsBackground()));
    headerAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
    contentsPanel.add(headerAreaScrollPane, BorderLayout.NORTH);

    dataArea = new HTMLTextArea() {
            protected void showURL(URL url) {
                File resolvedFile = null;

                try {
                    resolvedFile = new File(url.toURI());
                } catch (URISyntaxException ex) {
                    ex.printStackTrace();
                }

                final File snapshotFile = resolvedFile;

                if ((snapshotFile != null) && snapshotFile.exists()) {
                    String type = TriggeredTakeSnapshotProfilingPoint.this.getSnapshotType();
                    if (type.equals(TYPE_PROFDATA_KEY) || type.equals(TYPE_HEAPDUMP_KEY)) {
                        ResultsManager.getDefault().openSnapshot(snapshotFile);
                    }
                } else {
                    ProfilerDialogs.displayWarning(
                            Bundle.TriggeredTakeSnapshotProfilingPoint_SnapshotNotAvailableMsg());
                }
            }
        };

    JScrollPane dataAreaScrollPane = new JScrollPane(dataArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    TitledBorder tb = new TitledBorder(Bundle.TriggeredTakeSnapshotProfilingPoint_DataString());
    tb.setTitleFont(Utils.getTitledBorderFont(tb).deriveFont(Font.BOLD));
    tb.setTitleColor(javax.swing.UIManager.getColor("Label.foreground")); // NOI18N
    dataAreaScrollPane.setBorder(tb);
    dataAreaScrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
    dataAreaScrollPane.setBackground(UIUtils.getProfilerResultsBackground());
    contentsPanel.add(dataAreaScrollPane, BorderLayout.CENTER);

    add(contentsPanel, BorderLayout.CENTER);
}