Java Code Examples for javax.swing.OverlayLayout

The following examples show how to use javax.swing.OverlayLayout. These examples are extracted from open source projects. 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 Project: stendhal   Source File: InformationPanel.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a new InformationPanel.
 */
InformationPanel() {
	setLayout(new OverlayLayout(this));
	JComponent container = SBoxLayout.createContainer(SBoxLayout.VERTICAL);
	glassPane = new JComponent(){};
	add(glassPane);
	add(container);

	// ** Zone name **
	nameField = new JTextPane();
	StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
	nameField.setAlignmentX(CENTER_ALIGNMENT);
	nameField.setOpaque(true);
	nameField.setBackground(getBackground());
	nameField.setForeground(Color.WHITE);
	nameField.setFocusable(false);
	nameField.setEditable(false);
	container.add(nameField, SLayout.EXPAND_X);

	// ** Danger display **
	dangerIndicator = new DangerIndicator(MAX_SKULLS);
	dangerIndicator.setAlignmentX(CENTER_ALIGNMENT);
	container.add(dangerIndicator);
	// Default to safe, so that we always have a tooltip
	describeDanger(0);
}
 
Example 2
Source Project: netbeans   Source File: OverlayLayoutSupport.java    License: Apache License 2.0 5 votes vote down vote up
private static Constructor getOverlayLayoutConstructor() {
    if (overlayLayoutConstructor == null) {
        try {
            overlayLayoutConstructor = OverlayLayout.class.getConstructor(
                                       new Class[] { Container.class });
        } catch (NoSuchMethodException ex) { // should not happen
            Exceptions.printStackTrace(ex);
        }
    }
    return overlayLayoutConstructor;
}
 
Example 3
Source Project: Carcassonne   Source File: LayeredScrollPane.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates a layered scroll pane and centers it for a certain grid size.
 */
public LayeredScrollPane() {
    layeredPane = new JLayeredPane();
    layeredPane.setLayout(new OverlayLayout(layeredPane));
    setViewportView(layeredPane);
    getVerticalScrollBar().setUnitIncrement(SCROLL_SPEED);
    getHorizontalScrollBar().setUnitIncrement(SCROLL_SPEED);
}
 
Example 4
/**
 * Fills the tablePane with content.
 */
private JComponent makePreviewTable() {
	previewTable = new ExtendedJTable(false, false, false);
	// ensure same background as JPanels in case of only few rows
	previewTable.setBackground(Colors.PANEL_BACKGROUND);
	previewTable.setColoredTableCellRenderer(new ColoredTableCellRenderer() {

		private final Font boldFont = getFont().deriveFont(Font.BOLD);

		@Override
		public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
													   int row, int column) {
			JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
			adjustCell(row, label, boldFont);
			return label;
		}

	});

	loadingContentPane = new LoadingContentPane("loading_data", previewTable);

	tablePane = new ExtendedJScrollPane(loadingContentPane);
	tablePane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
	tablePane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	tablePane.setBorder(null);

	// add PREVIEW label in front of scrollpane
	JLayeredPane layeredPane = new JLayeredPane();
	layeredPane.setLayout(new OverlayLayout(layeredPane));
	layeredPane.add(tablePane, JLayeredPane.DEFAULT_LAYER);

	JPanel overlayPanel = new JPanel(new BorderLayout());
	overlayPanel.setOpaque(false);
	overlayLabel = new JLabel("", SwingConstants.CENTER);
	showPreviewLettering();
	overlayPanel.add(overlayLabel, BorderLayout.CENTER);

	layeredPane.add(overlayPanel, JLayeredPane.PALETTE_LAYER);
	return layeredPane;
}
 
Example 5
Source Project: mzmine2   Source File: LabeledProgressBar.java    License: GNU General Public License v2.0 5 votes vote down vote up
public LabeledProgressBar() {

    setLayout(new OverlayLayout(this));

    label = new JLabel();
    label.setAlignmentX(0.5f);
    label.setFont(label.getFont().deriveFont(11f));
    add(label);

    progressBar = new JProgressBar(0, 100);
    progressBar.setBorderPainted(false);
    add(progressBar);

  }
 
Example 6
private void addLayeredValidator() {
    validator = new Validator();
    
    JLayeredPane layeredPane = getRootPane().getLayeredPane();
    layeredPane.setLayout(new OverlayLayout(layeredPane));
    layeredPane.add(validator, (Integer) (JLayeredPane.DEFAULT_LAYER + 50));
    //validator.setBounds(0, 0, getWidth(), getHeight());
}
 
Example 7
Source Project: chipster   Source File: TrackGroup.java    License: MIT License 5 votes vote down vote up
public TrackGroup(GBrowserView view) {
      this.view = view;
      component.setLayout(new GridBagLayout());    
      component.setInheritsPopupMenu(true);
      //Usually track fills the whole track group and listen for these events. 
      //When the height of the settings panel exceeds the height of the tracks, also the 
      //TrackGroup becomes visible and has to listen for events.
      component.addMouseListener(getView());
      component.addMouseMotionListener(getView());
      component.addMouseWheelListener(getView());
      
      component.setBackground(Color.white);     
      
component.setLayout(new OverlayLayout(component));				

trackLayer = new JPanel();
settingsLayer = new JPanel();

trackLayer.setInheritsPopupMenu(true);
settingsLayer.setInheritsPopupMenu(true);

//First component added is the topmost when drawn
component.add(settingsLayer);
component.add(trackLayer); 		

trackLayer.setLayout(new MigLayout("flowy, fillx, gap 0! 0!, insets 0"));
settingsLayer.setLayout(new MigLayout("gap 0! 0!, insets 0"));

settingsLayer.setOpaque(false);		
trackLayer.setBackground(Color.white);			
  }
 
Example 8
/**
 * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable,
 *      java.lang.Object, boolean, boolean, int, int)
 */
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
    boolean hasFocus, int row, int column) {

  JPanel newPanel = new JPanel();
  newPanel.setLayout(new OverlayLayout(newPanel));

  Color bgColor;

  if (isSelected)
    bgColor = table.getSelectionBackground();
  else
    bgColor = table.getBackground();

  newPanel.setBackground(bgColor);

  if (value instanceof Feature) {

    Feature peak = (Feature) value;
    double maxHeight = 0;

    PeakShapeNormalization norm =
        parameters.getParameter(PeakListTableParameters.peakShapeNormalization).getValue();
    if (norm == null)
      norm = PeakShapeNormalization.ROWMAX;
    switch (norm) {
      case GLOBALMAX:
        maxHeight = peakList.getDataPointMaxIntensity();
        break;
      case ROWMAX:
        int rowNumber = peakList.getPeakRowNum(peak);
        maxHeight = peakList.getRow(rowNumber).getDataPointMaxIntensity();
        break;
      default:
        maxHeight = peak.getRawDataPointsIntensityRange().upperEndpoint();
        break;
    }
    PeakXICComponent xic = new PeakXICComponent(peak, maxHeight);

    // newPanel.add(xic);

    // newPanel.setToolTipText(xic.getToolTipText());

  }

  if (value instanceof PeakListRow) {

    PeakListRow plRow = (PeakListRow) value;

    RawDataFile[] dataFiles = peakList.getRawDataFiles().toArray(RawDataFile[]::new);
    Feature[] peaks = new Feature[dataFiles.length];
    for (int i = 0; i < dataFiles.length; i++) {
      peaks[i] = plRow.getPeak(dataFiles[i]);
    }

    // CombinedXICComponent xic = new CombinedXICComponent(peaks, plRow.getID());

    // newPanel.add(xic);

    // newPanel.setToolTipText(xic.getToolTipText());

  }

  return newPanel;

}
 
Example 9
/**
 * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable,
 *      java.lang.Object, boolean, boolean, int, int)
 */
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
    boolean hasFocus, int row, int column) {

  JPanel newPanel = new JPanel();
  newPanel.setLayout(new OverlayLayout(newPanel));

  Color bgColor;

  if (isSelected)
    bgColor = table.getSelectionBackground();
  else
    bgColor = table.getBackground();

  newPanel.setBackground(bgColor);

  if (hasFocus) {
    Border border = null;
    if (isSelected)
      border = UIManager.getBorder("Table.focusSelectedCellHighlightBorder");
    if (border == null)
      border = UIManager.getBorder("Table.focusCellHighlightBorder");

    /*
     * The "border.getBorderInsets(newPanel) != null" is a workaround for OpenJDK 1.6.0 bug,
     * otherwise setBorder() may throw a NullPointerException
     */
    if ((border != null) && (border.getBorderInsets(newPanel) != null)) {
      newPanel.setBorder(border);
    }

  }

  if (value != null) {
    FeatureStatus status = (FeatureStatus) value;

    switch (status) {
      case DETECTED:
        newPanel.add(greenCircle);
        break;
      case ESTIMATED:
        newPanel.add(yellowCircle);
        break;
      case MANUAL:
        newPanel.add(orangeCircle);
        break;
      default:
        newPanel.add(redCircle);
        break;
    }

    newPanel.setToolTipText(status.toString());

  } else {
    newPanel.add(redCircle);
  }

  return newPanel;

}
 
Example 10
protected OverlayLayout getObject() {
    return new OverlayLayout(new JLabel("TEST"));
}
 
Example 11
protected OverlayLayout getAnotherObject() {
    return null; // TODO: could not update property
    // return new OverlayLayout(new JPanel());
}
 
Example 12
protected OverlayLayout getObject() {
    return new OverlayLayout(new JLabel("TEST"));
}
 
Example 13
protected OverlayLayout getAnotherObject() {
    return null; // TODO: could not update property
    // return new OverlayLayout(new JPanel());
}
 
Example 14
protected OverlayLayout getObject() {
    return new OverlayLayout(new JLabel("TEST"));
}
 
Example 15
protected OverlayLayout getAnotherObject() {
    return null; // TODO: could not update property
    // return new OverlayLayout(new JPanel());
}
 
Example 16
protected OverlayLayout getObject() {
    return new OverlayLayout(new JLabel("TEST"));
}
 
Example 17
protected OverlayLayout getAnotherObject() {
    return null; // TODO: could not update property
    // return new OverlayLayout(new JPanel());
}
 
Example 18
Source Project: netbeans   Source File: OverlayLayoutSupport.java    License: Apache License 2.0 4 votes vote down vote up
/** Gets the supported layout manager class - OverlayLayout.
 * @return the class supported by this delegate
 */
@Override
public Class getSupportedClass() {
    return OverlayLayout.class;
}
 
Example 19
Source Project: netbeans   Source File: HeaderPanel.java    License: Apache License 2.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 20
protected OverlayLayout getObject() {
    return new OverlayLayout(new JLabel("TEST"));
}
 
Example 21
protected OverlayLayout getAnotherObject() {
    return null; // TODO: could not update property
    // return new OverlayLayout(new JPanel());
}
 
Example 22
protected OverlayLayout getObject() {
    return new OverlayLayout(new JLabel("TEST"));
}
 
Example 23
protected OverlayLayout getAnotherObject() {
    return null; // TODO: could not update property
    // return new OverlayLayout(new JPanel());
}
 
Example 24
protected OverlayLayout getObject() {
    return new OverlayLayout(new JLabel("TEST"));
}
 
Example 25
protected OverlayLayout getAnotherObject() {
    return null; // TODO: could not update property
    // return new OverlayLayout(new JPanel());
}
 
Example 26
protected OverlayLayout getObject() {
    return new OverlayLayout(new JLabel("TEST"));
}
 
Example 27
protected OverlayLayout getAnotherObject() {
    return null; // TODO: could not update property
    // return new OverlayLayout(new JPanel());
}
 
Example 28
protected OverlayLayout getObject() {
    return new OverlayLayout(new JLabel("TEST"));
}
 
Example 29
protected OverlayLayout getAnotherObject() {
    return null; // TODO: could not update property
    // return new OverlayLayout(new JPanel());
}
 
Example 30
Source Project: visualvm   Source File: HeaderPanel.java    License: 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);
}