Java Code Examples for javax.swing.BorderFactory#createMatteBorder()

The following examples show how to use javax.swing.BorderFactory#createMatteBorder() . 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: ToolBar.java    From opt4j with MIT License 6 votes vote down vote up
/**
 * Initialization. This method has to be called once after construction.
 */
public void init() {
	toolBar.setFloatable(false);
	Border border = BorderFactory.createMatteBorder(0, 0, 1, 0, toolBar.getBackground().darker());
	toolBar.setBorder(border);

	List<ToolBarService> list = new ArrayList<>();
	list.addAll(toolBarServices);
	Collections.sort(list, new ToolBarOrderComparator<>());

	for (ToolBarService toolBarService : list) {
		JToolBar component = toolBarService.getToolBar();
		component.setFloatable(false);
		toolBar.add(component);
	}
}
 
Example 2
Source File: ParetoPlotWidget.java    From opt4j with MIT License 6 votes vote down vote up
public Selection() {
	firstComboBox = new ObjectiveDropDown();
	secondComboBox = new ObjectiveDropDown();

	firstComboBox.addActionListener(this);
	secondComboBox.addActionListener(this);

	add(new JLabel("x-Axis: "));
	add(firstComboBox);
	addSeparator();
	add(new JLabel("y-Axis: "));
	add(secondComboBox);
	setFloatable(false);

	Border border = BorderFactory.createMatteBorder(0, 0, 1, 0, getBackground().darker());
	setBorder(border);

}
 
Example 3
Source File: ConfigDialog.java    From lizzie with GNU General Public License v3.0 6 votes vote down vote up
public Component getTableCellRendererComponent(
    JTable table, Object color, boolean isSelected, boolean hasFocus, int row, int column) {
  Color newColor = (Color) color;
  setBackground(newColor);
  if (isBordered) {
    if (isSelected) {
      if (selectedBorder == null) {
        selectedBorder =
            BorderFactory.createMatteBorder(2, 5, 2, 5, table.getSelectionBackground());
      }
      setBorder(selectedBorder);
    } else {
      if (unselectedBorder == null) {
        unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5, table.getBackground());
      }
      setBorder(unselectedBorder);
    }
  }

  return this;
}
 
Example 4
Source File: JPerfmonParamsPanel.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
private void makePtqlLink() {
    jLabelPtqlHelp.setForeground(Color.blue);
    jLabelPtqlHelp.setFont(jLabelPtqlHelp.getFont().deriveFont(Font.PLAIN));
    jLabelPtqlHelp.setCursor(new Cursor(Cursor.HAND_CURSOR));
    jLabelPtqlHelp.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK) {
                JMeterPluginsUtils.openInBrowser("http://support.hyperic.com/display/SIGAR/PTQL");
            }
        }
    });
    Border border = BorderFactory.createMatteBorder(0, 0, 1, 0, java.awt.Color.blue);
    jLabelPtqlHelp.setBorder(border);
}
 
Example 5
Source File: MoreImmutablesTest.java    From snake-yaml with Apache License 2.0 6 votes vote down vote up
public void testMatteBorder() {
    DumperOptions options = new DumperOptions();
    options.setWidth(400);
    Yaml yaml = new Yaml(new ImmutablesRepresenter(), options);
    Insets insets = new Insets(10, 20, 30, 40);
    Color color = new Color(100, 150, 200);
    MatteBorder border = BorderFactory.createMatteBorder(insets.top, insets.left,
            insets.bottom, insets.right, color);
    String dump = yaml.dump(border);
    assertEquals(
            "!!javax.swing.border.MatteBorder [!!java.awt.Insets [10, 20, 30, 40], !!java.awt.Color [100, 150, 200, 255]]\n",
            dump);
    Object loaded = yaml.load(dump);
    assertTrue(loaded instanceof MatteBorder);
    MatteBorder loadedBorder = (MatteBorder) loaded;
    assertEquals(insets, loadedBorder.getBorderInsets());
    assertEquals(color, loadedBorder.getMatteColor());
}
 
Example 6
Source File: CStatusColumnRenderer.java    From binnavi with Apache License 2.0 5 votes vote down vote up
@Override
public Component getTableCellRendererComponent(final JTable table, final Object value,
    final boolean isSelected, final boolean hasFocus, final int row, final int column) {
  final CResultColumnWrapper wrapper = (CResultColumnWrapper) value;

  final CInstructionResult result = wrapper.getResult();

  setBackground(CResultColor.determineBackgroundColor(wrapper.getStartInstruction(),
      wrapper.getTrackedRegister(), result));
  setForeground(CResultColor.determineForegroundColor(wrapper.getStartInstruction(),
      wrapper.getTrackedRegister(), result));
  setText(CResultText.determineDescription(wrapper.getStartInstruction(),
      wrapper.getTrackedRegister(), result));

  setHorizontalAlignment(SwingConstants.CENTER);

  if (isSelected) {
    if (selectedBorder == null) {
      selectedBorder =
          BorderFactory.createMatteBorder(2, 5, 2, 5, table.getSelectionBackground());
    }

    setBorder(selectedBorder);
  } else {
    if (unselectedBorder == null) {
      unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5, table.getBackground());
    }

    setBorder(unselectedBorder);
  }

  return this;
}
 
Example 7
Source File: ColorPropertyCellRenderer.java    From openAGV with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance of ColorPropertyCellRenderer
 */
public ColorPropertyCellRenderer() {
  super();
  setOpaque(true);
  Border insideBorder = BorderFactory.createLineBorder(Color.black);
  Border outsideBorder = BorderFactory.createMatteBorder(5, 10, 5, 10, Color.white);
  setBorder(BorderFactory.createCompoundBorder(outsideBorder, insideBorder));
}
 
Example 8
Source File: CTypeColumnRenderer.java    From binnavi with Apache License 2.0 5 votes vote down vote up
@Override
public Component getTableCellRendererComponent(final JTable table,
    final Object value,
    final boolean isSelected,
    final boolean hasFocus,
    final int row,
    final int column) {
  final ITypeDescription type = (ITypeDescription) value;

  setBackground(type.getColor());
  setForeground(Color.BLACK);
  setText(type.getDescription());

  setHorizontalAlignment(SwingConstants.CENTER);

  if (isSelected) {
    if (selectedBorder == null) {
      selectedBorder = BorderFactory.createMatteBorder(
          2, 5, 2, 5, table.getSelectionBackground());
    }

    setBorder(selectedBorder);
  } else {
    if (unselectedBorder == null) {
      unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5, table.getBackground());
    }

    setBorder(unselectedBorder);
  }

  return this;
}
 
Example 9
Source File: Table.java    From Spark with Apache License 2.0 5 votes vote down vote up
@Override
public Component getTableCellRendererComponent(JTable table, Object color, boolean isSelected, boolean hasFocus, int row, int column) {
          final String text = ((JButton)color).getText();
          setText(text);

          final Icon icon = ((JButton)color).getIcon();
          setIcon(icon);

          if (isSelected) {
              setForeground(table.getSelectionForeground());
              setBackground(table.getSelectionBackground());
          }
          else {
              setForeground(Color.black);
              setBackground(Color.white);
              if (row % 2 == 0) {
                  //setBackground( new Color( 156, 207, 255 ) );
              }
          }

          if (isBordered) {
              if (isSelected) {
                  if (selectedBorder == null) {
                      selectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5,
                              table.getSelectionBackground());
                  }
                  setBorder(selectedBorder);
              }
              else {
                  if (unselectedBorder == null) {
                      unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5,
                              table.getBackground());
                  }
                  setBorder(unselectedBorder);
              }
          }
          return this;
      }
 
Example 10
Source File: TestResultRow.java    From tmc-intellij with MIT License 5 votes vote down vote up
private void createBorder() {
    logger.info("Creating border. @TestResultRow");

    Border innerPadding = BorderFactory.createEmptyBorder(5, 10, 5, 5);
    Border leftColorBar = BorderFactory.createMatteBorder(0, 6, 0, 0, borderColor);
    Border compoundBorder = BorderFactory.createCompoundBorder(leftColorBar, innerPadding);
    this.setBorder(compoundBorder);
}
 
Example 11
Source File: JiveSortableTable.java    From Spark with Apache License 2.0 5 votes vote down vote up
@Override
public Component getTableCellRendererComponent(JTable table, Object color, boolean isSelected, boolean hasFocus, int row, int column) {
          final String text = ((JLabel)color).getText();
          if (text != null) {
              setText(" " + text);
          }
          final Icon icon = ((JLabel)color).getIcon();
          setIcon(icon);

          if (isSelected) {
              setForeground(table.getSelectionForeground());
              setBackground(table.getSelectionBackground());
          }
          else {
              setForeground(Color.black);
              setBackground(Color.white);
              if (row % 2 == 0) {
                  //setBackground( new Color( 156, 207, 255 ) );
              }
          }

          if (isBordered) {
              if (isSelected) {
                  if (selectedBorder == null) {
                      selectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5,
                              table.getSelectionBackground());
                  }
                  setBorder(selectedBorder);
              }
              else {
                  if (unselectedBorder == null) {
                      unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5,
                              table.getBackground());
                  }
                  setBorder(unselectedBorder);
              }
          }
          return this;
      }
 
Example 12
Source File: JiveSortableTable.java    From Spark with Apache License 2.0 5 votes vote down vote up
@Override
public Component getTableCellRendererComponent(JTable table, Object color, boolean isSelected, boolean hasFocus, int row, int column) {
          final String text = ((JButton)color).getText();
          setText(text);

          final Icon icon = ((JButton)color).getIcon();
          setIcon(icon);

          if (isSelected) {
              setForeground(table.getSelectionForeground());
              setBackground(table.getSelectionBackground());
          }
          else {
              setForeground(Color.black);
              setBackground(Color.white);
              if (row % 2 == 0) {
                  //setBackground( new Color( 156, 207, 255 ) );
              }
          }

          if (isBordered) {
              if (isSelected) {
                  if (selectedBorder == null) {
                      selectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5,
                              table.getSelectionBackground());
                  }
                  setBorder(selectedBorder);
              }
              else {
                  if (unselectedBorder == null) {
                      unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5,
                              table.getBackground());
                  }
                  setBorder(unselectedBorder);
              }
          }
          return this;
      }
 
Example 13
Source File: ToggleProfilingPointAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void setProfilingPointFactory(ProfilingPointFactory ppFactory, int index) {
    this.ppFactory = ppFactory;

    if (ppFactory != null) {
        label.setText(ppFactory.getType());
        label.setIcon(ppFactory.getIcon());
    } else {
        label.setText(NO_ACTION_NAME);
        label.setIcon(NO_ACTION_ICON);
    }

    Component selected = null;

    if ((index >= 0) && (index < previewPanel.getComponentCount())) {
        selected = previewPanel.getComponent(index);
    }

    for (Component c : previewPanel.getComponents()) {
        if (c == selected) {
            Border empt1 = BorderFactory.createEmptyBorder(2, 2, 2, 2);
            Border sel = BorderFactory.createMatteBorder(1, 1, 1, 1, SystemColor.textHighlight);
            Border empt2 = BorderFactory.createEmptyBorder(0, 2, 0, 2);
            Border comp1 = BorderFactory.createCompoundBorder(empt2, sel);
            Border comp2 = BorderFactory.createCompoundBorder(comp1, empt1);
            ((JComponent) c).setBorder(comp2);
        } else {
            ((JComponent) c).setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
        }
    }
}
 
Example 14
Source File: MakeColorsPane.java    From DroidUIBuilder with Apache License 2.0 5 votes vote down vote up
public Component getTableCellRendererComponent(JTable table,
		Object value, boolean isSelected, boolean hasFocus, int row,
		int column)
{
	Color color = (Color) value;
	JLabel lb = new JLabel("#" + Integer.toString(color.getRed(), 16)
			+ Integer.toString(color.getGreen(), 16)
			+ Integer.toString(color.getBlue(), 16)
			+ Integer.toString(color.getAlpha(), 16));
	lb.setOpaque(true);
	lb.setBackground(color);

	if (isSelected)
	{
		if (selectedBorder == null)
		{
			selectedBorder = BorderFactory.createMatteBorder(1, 1, 1,
					1, table.getSelectionBackground());
		}
		lb.setBorder(selectedBorder);
	}
	else
	{
		if (unselectedBorder == null)
		{
			unselectedBorder = BorderFactory.createMatteBorder(1, 1, 1,
					1, table.getBackground());
		}
		lb.setBorder(unselectedBorder);
	}

	lb.setToolTipText("Red: " + color.getRed() + ", Green: "
			+ color.getGreen() + ", Blue: " + color.getBlue());

	return lb;
}
 
Example 15
Source File: TabTableUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static Border createTabBorder( JTable table, int tabsLocation ) {
    if( IS_AQUA ) {
        return BorderFactory.createMatteBorder( 1, 0, 0, 0, table.getGridColor());
    } else {
        if( tabsLocation != JTabbedPane.TOP && !UIManager.getBoolean("nb.multitabs.noTabBorder") ) //NOI18N
            return BorderFactory.createMatteBorder( 1, 0, 0, 0, table.getGridColor());
    }
    return BorderFactory.createEmptyBorder();
}
 
Example 16
Source File: PluginRenderer.java    From Spark with Apache License 2.0 5 votes vote down vote up
@Override
public Component getTableCellRendererComponent(JTable table, Object color, boolean isSelected, boolean hasFocus, int row, int column) {

       final Icon icon = SparkRes.getImageIcon(SparkRes.PLUGIN_IMAGE);
       setIcon(icon);

       if (isSelected) {
           setForeground(table.getSelectionForeground());
           setBackground(table.getSelectionBackground());
       }
       else {
           setForeground(Color.black);
           setBackground(Color.white);
           if (row % 2 == 0) {
               //setBackground( new Color( 156, 207, 255 ) );
           }
       }

       if (isBordered) {
           if (isSelected) {
               if (selectedBorder == null) {
                   selectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5,
                           table.getSelectionBackground());
               }
               setBorder(selectedBorder);
           }
           else {
               if (unselectedBorder == null) {
                   unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5,
                           table.getBackground());
               }
               setBorder(unselectedBorder);
           }
       }
       return this;
   }
 
Example 17
Source File: StatusBar.java    From opt4j with MIT License 5 votes vote down vote up
/**
 * Initialization. This method has to called once after construction.
 */
public void init() {
	panel.setLayout(new BorderLayout());
	Border border = BorderFactory.createMatteBorder(1, 0, 0, 0, label.getBackground().darker());
	panel.setBorder(border);

	JPanel containerText = new JPanel(new FlowLayout(0, 5, 0));
	timeLabel.setText("[time per iteration in ms]");
	timeLabel.setHorizontalAlignment(SwingConstants.LEFT);
	label.setPreferredSize(new Dimension(50, 18));
	label.setHorizontalAlignment(SwingConstants.RIGHT);
	label.setPreferredSize(new Dimension(50, 18));

	containerText.add(label);
	containerText.add(timeLabel);
	panel.add(containerText, BorderLayout.WEST);

	JPanel container = new JPanel(new BorderLayout());
	container.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 4));
	bar.setMinimum(0);
	bar.setMaximum(progress.getMaxIterations());

	bar.setPreferredSize(new Dimension(200, 16));
	bar.setStringPainted(true);

	container.add(bar);
	panel.add(container, BorderLayout.EAST);

	time = System.nanoTime();

	update("", "init");
}
 
Example 18
Source File: ColorCellRenderer.java    From jdal with Apache License 2.0 5 votes vote down vote up
public Component getTableCellRendererComponent(
                        JTable table, Object color,
                        boolean isSelected, boolean hasFocus,
                        int row, int column) {
    Color newColor = (Color)color;
    setBackground(newColor);
    if (isBordered) {
        if (isSelected) {
            if (selectedBorder == null) {
                selectedBorder = BorderFactory.createMatteBorder(2,5,2,5,
                                          table.getSelectionBackground());
            }
            setBorder(selectedBorder);
        } else {
            if (unselectedBorder == null) {
                unselectedBorder = BorderFactory.createMatteBorder(2,5,2,5,
                                          table.getBackground());
            }
            setBorder(unselectedBorder);
        }
    }
    
    setToolTipText("RGB value: " + newColor.getRed() + ", "
                                 + newColor.getGreen() + ", "
                                 + newColor.getBlue());
    return this;
}
 
Example 19
Source File: ModelTreeRTStats.java    From mts with GNU General Public License v3.0 4 votes vote down vote up
public void fillWithTotal(JPanel gridPanel, StatKey prefixKey, List<CounterReportTemplate> templateList) {
    // Creation of a border in top of panel
    Border totalBorder = BorderFactory.createMatteBorder(2, 0, 0, 0, ModelTreeRTStats.instance().getColorByString("columnTitle"));

    // We create a new panel for total row
    JPanel panelTotal = new JPanel();
    panelTotal.setLayout(new javax.swing.BoxLayout(panelTotal, javax.swing.BoxLayout.X_AXIS));
    panelTotal.setBackground(ModelTreeRTStats.instance().getColorByString("backgroundTotal"));
    panelTotal.setBorder(totalBorder);

    // We create a new panel for the title of the row
    JPanel panelTotalTitle = new JPanel();
    panelTotalTitle.setLayout(new javax.swing.BoxLayout(panelTotalTitle, javax.swing.BoxLayout.X_AXIS));
    panelTotalTitle.setBackground(ModelTreeRTStats.instance().getColorByString("backgroundTotal"));

    // Title of the row
    panelTotalTitle.add(new JLabel("TOTAL"));

    panelTotal.add(panelTotalTitle);

    // We add  this panel to the global panel for short stats (gridLayout)
    gridPanel.add(panelTotal);

    for (CounterReportTemplate template : templateList) {
        // We get (if possible) the counter matching the current StatKey and current template
        DerivedCounter derivedCounter = null;
        try {
            derivedCounter = template.getDerivedCounter(pool, prefixKey);
        }
        catch (ParsingException ex) {
            GlobalLogger.instance().getApplicationLogger().error(Topic.CORE, ex, "error RT Stats , fill With Total , can't get derived counter ");
        }
        if (derivedCounter != null) {
            // We get the short panel of this stat
            JPanel panelShortTotal = derivedCounter.generateShortRTStats();

            // We want a white color for this panel background
            panelShortTotal.setBackground(ModelTreeRTStats.instance().getColorByString("backgroundTotal"));

            // We specify the border style of this panel
            panelShortTotal.setBorder(totalBorder);

            if (derivedCounter.id.equals(statSelected)) {
                // We change the color of the background (now it's pink)
                panelShortTotal.setBackground(ModelTreeRTStats.instance().getColorByString("selectedForGraph"));

                // We clean the bottom panel
                JFrameRTStats.instance().getJPanelBottom().removeAll();

                // We add the panel with the long report and graph
                JFrameRTStats.instance().getJPanelBottom().add(derivedCounter.generateLongRTStats());

                // We create a blank line
                JFrameRTStats.instance().getJPanelBottom().add(new JLabel("<html><br/></html>"));

                // We add graphics
                JFrameRTStats.instance().getJPanelBottom().add(derivedCounter.getChartPanel());
            }

            // We add this element on the main panel for shorts stats
            gridPanel.add(panelShortTotal);
        }
        else {
            JPanel panelEmpty = new JPanel();

            // Color of this panel
            panelEmpty.setBackground(ModelTreeRTStats.instance().getColorByString("backgroundTotal"));

            // We specify the border style of this panel
            panelEmpty.setBorder(totalBorder);

            // We want a text alignment on the left
            panelEmpty.setLayout(new javax.swing.BoxLayout(panelEmpty, javax.swing.BoxLayout.X_AXIS));

            // We add a label "-"
            panelEmpty.add(new JLabel(" - "));

            // We add this element on the main panel for shorts stats
            gridPanel.add(panelEmpty);
        }
    }
}
 
Example 20
Source File: ButtonDialog.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
public static Border createBorder() {
	return BorderFactory.createMatteBorder(1, 1, 1, 1, Color.LIGHT_GRAY);
}