static BorderBuilder fromField(Instance instance, String field, boolean uiresource, Heap heap) { Object _border = instance.getValueOfField(field); if (!(_border instanceof Instance)) return null; Instance border = (Instance)_border; // Make sure subclasses are listed before base class if using isSubclassOf if (DetailsUtils.isSubclassOf(border, BevelBorder.class.getName())) { return new BevelBorderBuilder(border, heap); } else if (DetailsUtils.isSubclassOf(border, MatteBorder.class.getName())) { // Must be before EmptyBorder (extends EmptyBorder) return new EmptyBorderBuilder(border, heap); } else if (DetailsUtils.isSubclassOf(border, EmptyBorder.class.getName())) { return new MatteBorderBuilder(border, heap); } else if (DetailsUtils.isSubclassOf(border, EtchedBorder.class.getName())) { return new EtchedBorderBuilder(border, heap); } else if (DetailsUtils.isSubclassOf(border, LineBorder.class.getName())) { return new LineBorderBuilder(border, heap); } else if (DetailsUtils.isSubclassOf(border, TitledBorder.class.getName())) { return new TitledBorderBuilder(border, heap); } else if (DetailsUtils.isSubclassOf(border, CompoundBorder.class.getName())) { return new CompoundBorderBuilder(border, heap); } return null; }
protected Expression instantiate(Object oldInstance, Encoder out) { MatteBorder border = (MatteBorder) oldInstance; Insets insets = border.getBorderInsets(); Object object = border.getTileIcon(); if (object == null) { object = border.getMatteColor(); } Object[] args = new Object[] { insets.top, insets.left, insets.bottom, insets.right, object, }; return new Expression(border, border.getClass(), "new", args); }
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()); }
public void addComponent(JPanelMenu menu) { // if (p.x > 20) { // p.x = 20; // p.y += 55; // } // p.y += 20; // 20 puntitos extra de separacion. JLabel lbl = new JLabel(AppLocal.getIntString(KeyText)); lbl.applyComponentOrientation(menu.getComponentOrientation()); lbl.setBorder(new MatteBorder(new Insets(0, 0, 1, 0), new Color(0, 0, 0))); // lbl.setSize(670, 20); // lbl.setLocation(p); // p.y += 35; // comp.add(lbl); menu.addTitle(lbl); }
private void updateDetailsBorder(@Nullable VcsFullCommitDetails data) { if (data == null || !myColorManager.isMultipleRoots()) { myMainContentPanel.setBorder(BorderFactory.createEmptyBorder()); } else { Color color = VcsLogGraphTable.getRootBackgroundColor(data.getRoot(), myColorManager); myMainContentPanel.setBorder(new CompoundBorder(new MatteBorder(0, VcsLogGraphTable.ROOT_INDICATOR_COLORED_WIDTH, 0, 0, color), new MatteBorder(0, VcsLogGraphTable.ROOT_INDICATOR_WHITE_WIDTH, 0, 0, new JBColor(new NotNullProducer<Color>() { @NotNull @Override public Color produce() { return getDetailsBackground(); } })))); } }
private void initStatusBar() { jlStatusBar = new JLabel(); int rightPadding = 3; if (OperatingSystem.isMacOs()) { rightPadding = 15; // Allow extra padding in the grow box status bar // if using Mac OS } jlStatusBar.setBorder(new CompoundBorder(new MatteBorder(1, 0, 0, 0, Color.LIGHT_GRAY), new EmptyBorder(3, 3, 3, rightPadding))); setDefaultStatusBarText(); if (applicationSettings.getShowStatusBar()) { frame.getContentPane().add(jlStatusBar, BorderLayout.SOUTH); } }
/** * * @param menu */ @Override public void addComponent(JPanelMenu menu) { // if (p.x > 20) { // p.x = 20; // p.y += 55; // } // p.y += 20; // 20 puntitos extra de separacion. JLabel lbl = new JLabel(AppLocal.getIntString(KeyText)); lbl.applyComponentOrientation(menu.getComponentOrientation()); lbl.setBorder(new MatteBorder(new Insets(0, 0, 1, 0), new Color(0, 0, 0))); // lbl.setSize(670, 20); // lbl.setLocation(p); // p.y += 35; // comp.add(lbl); // lbl.setFont(new Font("DotumChe",Font.PLAIN,14)); menu.addTitle(lbl); }
/** * * @param menu */ @Override public void addComponent(JPanelMenu menu) { // if (p.x > 20) { // p.x = 20; // p.y += 55; // } // p.y += 20; // 20 puntitos extra de separacion. JLabel lbl = new JLabel(AppLocal.getIntString(KeyText)); lbl.applyComponentOrientation(menu.getComponentOrientation()); lbl.setBorder(new MatteBorder(new Insets(0, 0, 1, 0), new Color(0, 0, 0))); // lbl.setSize(670, 20); // lbl.setLocation(p); // p.y += 35; // comp.add(lbl); menu.addTitle(lbl); }
private static void makeBotOrMiddle(final int index, final int bottom) { fileListingRows.get(index).setInGroup(true); JTextField textField = new JTextField(); textField.setSize(200, 30); textField.setEditable(false); textField.setPreferredSize(new Dimension(200, 25)); textField.setBorder(new MatteBorder(0, 0, bottom, 0, borderColor)); new FileDrop(textField, textField.getBorder(), new FileDrop.Listener() { @Override public void filesDropped(final File[] files) { for (int i = 0; i < files.length; i++) { FileListing.addFile(files[i], fileListingRows.get(i) .getXmlFormat().getSelectedItem().toString()); } } }); listing.add(textField, fileListingCons, (index * COLSINLISTING) + 2); }
@Test public void testBorder() throws Exception { final int top = 9; final int left = 3; final int bottom = 1; final int right = 6; final Color matteColor = new Color(174, 2, 126); matteBorderDecorator.set(top, left, bottom, right, matteColor); final MatteBorder matte = new MatteBorder(top, left, bottom, right, matteColor); assertEquals(button.getBorder().getClass(), matte.getClass()); final MatteBorder border = (MatteBorder) button.getBorder(); assertEquals(border.getBorderInsets(), matte.getBorderInsets()); assertEquals(border.getMatteColor(), matte.getMatteColor()); }
@Override public Component getListCellRendererComponent( JList<? extends TransactionBean> list, TransactionBean value, int index, boolean isSelected, boolean cellHasFocus) { JTextPane client = new JTextPane(); client.setEditable(false); client.setContentType("text/html"); TransactionRenderOpsBean ops = mRuntime.getRenderOps(); String html = TransactionLogic.renderAsHTML(value, ops); int w = list.getFixedCellWidth(); if (w < 0) w = 750; else w = w*3/4; html = "<html><body><table width=\""+w+"px\">"+html+"</table></body></html>"; client.setText(html); if (cellHasFocus) client.setBorder(new MatteBorder(1, 5, 1, 1, Color.DARK_GRAY)); client.setBackground(isSelected ? SELECTED : DESELECTED); return client; }
@Override protected void initComponentDefaults(UIDefaults table) { super.initComponentDefaults(table); Border lineBorder = new BorderUIResource(new MatteBorder(1, 1, 1, 1, Color.LIGHT_GRAY)); Object textBorder = new BorderUIResource(new CompoundBorder(lineBorder, new BasicBorders.MarginBorder())); Object[] defaults = new Object[] { "ComboBox.selectionForeground", getHighlightedTextColor(), "Panel.font", getControlTextFont(), "ToolTip.border", lineBorder, "TitledBorder.border", lineBorder, "TextField.border", textBorder, "PasswordField.border", textBorder, "TextArea.border", textBorder, "TextPane.border", textBorder, "EditorPane.border", textBorder, "Button.border", lineBorder, }; table.putDefaults(defaults); }
/** * Adds a button to this {@link ComboButton}. Beware that this method does * change the styling (colors, borders etc.) of the button to make it fit * the {@link ComboButton}. * * @param button */ public void addButton(final AbstractButton button) { WidgetUtils.setDefaultButtonStyle(button); final EmptyBorder baseBorder = new EmptyBorder(WidgetUtils.BORDER_WIDE_WIDTH - 1, 9, WidgetUtils.BORDER_WIDE_WIDTH - 1, 9); if (getComponentCount() == 0) { button.setBorder(baseBorder); } else { final Component lastComponent = getComponent(getComponentCount() - 1); if (lastComponent instanceof AbstractButton) { // previous component was also a button - add a line on the left // side final Border outsideBorder = new MatteBorder(0, 1, 0, 0, WidgetUtils.BG_COLOR_LESS_BRIGHT); button.setBorder(new CompoundBorder(outsideBorder, baseBorder)); } else { button.setBorder(baseBorder); } } button.setOpaque(false); _buttons.add(button); add(button); }
public static JButton createSmallButton(final String text, final Icon icon) { final JButton b = new JButton(icon); if (text != null) { b.setText(text); b.setFont(WidgetUtils.FONT_SMALL); } b.setMargin(new Insets(0, 0, 0, 0)); b.setUI(new MetalButtonUI()); b.setBackground(WidgetUtils.COLOR_WELL_BACKGROUND); final MatteBorder outerBorder = new MatteBorder(1, 1, 1, 1, WidgetUtils.BG_COLOR_LESS_BRIGHT); b.setBorder(new CompoundBorder(outerBorder, new EmptyBorder(2, 4, 2, 4))); b.setFocusPainted(false); return b; }
public MaterialTabBarButton(SwingViewContainer2 viewContainer, MaterialStyle materialStyle, SwingView view, boolean selected) { setContentAreaFilled(false); setFocusable(false); addMouseListener(createBackgroundPainter(viewContainer, ColorFactory.create(materialStyle.getTabToolbarStyle().getPressedColor()), view)); // setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, style.COLORS.getForeground1())); // setBorder(BorderFactory.createBevelBorder(1)); // setText(view.getViewTitle().toUpperCase()); //putting everything in a label so we can use borders JLabel label = new JLabel(view.getViewTitle().toUpperCase()); EmptyBorder padding = new EmptyBorder(12,12,12,12); if (selected) { MatteBorder bottomBar = BorderFactory.createMatteBorder(0, 0, 2, 0,ColorFactory.create( materialStyle.getTabContainerStyle().getBackground())); label.setBorder(new CompoundBorder( bottomBar, padding)); } else { label.setBorder(padding); } label.setFont(AwtFontFactory.create(materialStyle.getTabToolbarButtonStyle().getFont())); label.setForeground(ColorFactory.create(materialStyle.getTabToolbarButtonStyle().getTextColor())); add(label); }
private void initInterface() { setBounds(300, 30, 0, 0); setSize(694, 711); setResizable(false); setTitle("Dama"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new BorderLayout(0, 0)); buildMenu(); black = new PlayerLabel(Controller.getController().getBlack().getNome(), false); add(black, BorderLayout.NORTH); white = new PlayerLabel(Controller.getController().getWhite().getNome(), true); add(white, BorderLayout.SOUTH); pannello = new JPanel(new GridLayout(8, 8, 0, 0)); pannello.setDoubleBuffered(true); pannello.setBorder(new MatteBorder(2, 4, 2, 4, border)); createInterface(); add(pannello, BorderLayout.CENTER); }
public void testCreateMatteBorderintintintintIcon() { Icon icon = new ImageIcon(new BufferedImage(20, 20, BufferedImage.TYPE_BYTE_GRAY)); int top = 100; int left = 200; int right = 300; int bottom = 400; MatteBorder border = BorderFactory.createMatteBorder(top, left, bottom, right, icon); Insets insets = border.getBorderInsets(null); assertEquals(insets, new Insets(top, left, bottom, right)); icon = new ImageIcon(new BufferedImage(30, 40, BufferedImage.TYPE_4BYTE_ABGR)); top = 200; left = 300; right = 200; bottom = 300; border = BorderFactory.createMatteBorder(top, left, bottom, right, icon); Insets insets2 = border.getBorderInsets(null); assertEquals(insets2, new Insets(top, left, bottom, right)); }
public void testCreateMatteBorderintintintintColor() { Color color = Color.RED; int top = 100; int left = 200; int right = 300; int bottom = 400; MatteBorder border = BorderFactory.createMatteBorder(top, left, bottom, right, color); Insets insets = border.getBorderInsets(null); assertEquals(insets, new Insets(top, left, bottom, right)); color = Color.YELLOW; top = 200; left = 300; right = 200; bottom = 300; border = BorderFactory.createMatteBorder(top, left, bottom, right, color); Insets insets2 = border.getBorderInsets(null); assertEquals(insets2, new Insets(top, left, bottom, right)); }
public void testGetDesktopIconBorder() { JComponent testButton = newJComponent(); assertTrue(MetalBorders.getDesktopIconBorder() instanceof BorderUIResource.CompoundBorderUIResource); BorderUIResource.CompoundBorderUIResource border = (BorderUIResource.CompoundBorderUIResource) MetalBorders .getDesktopIconBorder(); assertTrue(border.getInsideBorder() instanceof MatteBorder); MatteBorder insideBorder = (MatteBorder) border.getInsideBorder(); assertTrue(border.getOutsideBorder() instanceof LineBorder); LineBorder outsideBorder = (LineBorder) border.getOutsideBorder(); assertEquals(new Insets(2, 2, 1, 2), insideBorder.getBorderInsets(testButton)); assertEquals(new Insets(1, 1, 1, 1), outsideBorder.getBorderInsets(testButton)); assertTrue(insideBorder.isBorderOpaque()); assertEquals(new ColorUIResource(238, 238, 238), insideBorder.getMatteColor()); assertFalse(outsideBorder.getRoundedCorners()); assertTrue(outsideBorder.isBorderOpaque()); assertEquals(new ColorUIResource(122, 138, 153), outsideBorder.getLineColor()); assertEquals(1, outsideBorder.getThickness()); }
/** * */ public void configure() { this.simulateButton.setIcon(IconLoader.getInstance().getImage("run.png")); this.toolbar.setFloatable(false); this.toolbarWrapper.setBorder(new MatteBorder(0, 0, 1, 0, new Color(180, 180, 180))); this.simulateButton.addActionListener(this); this.zoomOutButton.setIcon(IconLoader.getInstance().getImage("zoomout.png")); this.zoomInButton.setIcon(IconLoader.getInstance().getImage("zoomin.png")); this.zoomInButton.addActionListener(this); this.zoomOutButton.addActionListener(this); this.paintAreaScroller.setBorder(null); }
public JScrollAndJumpPane(Component view) { if (view != null) { scrollPane = new JScrollPane(view); } else { scrollPane = new JScrollPane(); } scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); jumpBar = createJumpBar(scrollPane.getVerticalScrollBar()); scrollPane.getViewport().addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { revalidate(); } }); add(scrollPane); add(jumpBar); setBorder(scrollPane.getBorder()); scrollPane.setBorder(new MatteBorder(0, 0, 0, 1, new Color(224, 224, 224))); setLayout(this); }
public final void setToolbarActions(final AnAction... actions) { final DefaultActionGroup actionGroup = new DefaultActionGroup(); for (final AnAction action : actions) { actionGroup.add(action); } if (getHelpId() != null) { actionGroup.add(Separator.getInstance()); actionGroup.add(new ContextHelpAction(getHelpId())); } final ActionManager actionManager = ActionManager.getInstance(); final ToolbarPosition position = getToolbarPosition(); final ActionToolbar myActionToolbar = actionManager.createActionToolbar(ActionPlaces.PROJECT_VIEW_TOOLBAR, actionGroup, position == ToolbarPosition.TOP || position == ToolbarPosition.BOTTOM); myActionToolbar.setTargetComponent(myInnerPanel); final JComponent toolbarComponent = myActionToolbar.getComponent(); final MatteBorder matteBorder = BorderFactory.createMatteBorder(0, 0, position == ToolbarPosition.TOP ? 1 : 0, 0, JBColor.DARK_GRAY); toolbarComponent.setBorder(BorderFactory.createCompoundBorder(matteBorder, toolbarComponent.getBorder())); getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { myActionToolbar.updateActionsImmediately(); } }); add(toolbarComponent, position.getPosition()); }