javax.swing.border.EmptyBorder Java Examples

The following examples show how to use javax.swing.border.EmptyBorder. 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: RenameDataFieldDialog.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private JPanel create() {
recentChoices = new GhidraComboBox<>();
      recentChoices.setEditable(true);

JPanel mainPanel = new JPanel(new BorderLayout());
JPanel topPanel = new JPanel(new BorderLayout());

Border border = BorderFactory.createTitledBorder("Data Field Name");
topPanel.setBorder(border);
	
mainPanel.add(topPanel, BorderLayout.NORTH);

topPanel.add(recentChoices, BorderLayout.NORTH);

      choiceTextField = (JTextField)recentChoices.getEditor().getEditorComponent();
      setFocusComponent(choiceTextField);
      choiceTextField.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent e) {
		okCallback();
	}
      });
   mainPanel.setBorder(new EmptyBorder(5,5,5,5));

return mainPanel;
  }
 
Example #2
Source File: DarkFileChooserUI.java    From darklaf with MIT License 6 votes vote down vote up
@Override
public void installComponents(final JFileChooser fc) {
    fc.setBorder(new EmptyBorder(10, 10, 7, 10));
    fc.setLayout(new BorderLayout(0, 7));
    filePane = createFilePane(fc);

    fc.add(createTopPanel(fc), BorderLayout.NORTH);
    fc.add(filePane, BorderLayout.CENTER);
    fc.add(createBottomPanel(fc), BorderLayout.SOUTH);
    fc.add(createControlPanel(fc), BorderLayout.AFTER_LINE_ENDS);

    setupButtonPanel(fc);
    if (fc.getControlButtonsAreShown()) {
        addControlButtons();
    }
    groupLabels(new AlignedLabel[]{fileNameLabel, filesOfTypeLabel});
}
 
Example #3
Source File: EditExternalLocationDialog.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private JComponent buildMainPanel() {

		Border panelBorder = new EmptyBorder(5, 10, 5, 10);
		if (externalLocation != null) {
			extLocPanel = new EditExternalLocationPanel(externalLocation); // Edit
		}
		else {
			extLocPanel = new EditExternalLocationPanel(program, externalLibraryName); // Create
		}
		extLocPanel.setBorder(panelBorder);
		int panelHeight = (externalLocation != null) ? PREFERRED_EDIT_PANEL_HEIGHT
				: PREFERRED_CREATE_PANEL_HEIGHT;
		extLocPanel.setPreferredSize(new Dimension(PREFERRED_PANEL_WIDTH, panelHeight));

		JPanel workPanel = new JPanel(new BorderLayout());
		workPanel.add(extLocPanel, BorderLayout.CENTER);

		return workPanel;
	}
 
Example #4
Source File: WorldTableRow.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Builds the world list field (containing the country's flag and the world index).
 */
private JPanel buildWorldField()
{
	JPanel column = new JPanel(new BorderLayout(7, 0));
	column.setBorder(new EmptyBorder(0, 5, 0, 5));

	worldField = new JLabel(world.getId() + "");

	ImageIcon flagIcon = getFlag(world.getRegion());
	if (flagIcon != null)
	{
		JLabel flag = new JLabel(flagIcon);
		column.add(flag, BorderLayout.WEST);
	}
	column.add(worldField, BorderLayout.CENTER);

	return column;
}
 
Example #5
Source File: FlatTaskPaneUI.java    From FlatLaf with Apache License 2.0 6 votes vote down vote up
@Override
protected void installDefaults() {
	if( group.getContentPane() instanceof JComponent ) {
		// remove default SwingX content border, which may be still set when switching LaF
		JComponent content = (JComponent) group.getContentPane();
		Border contentBorder = content.getBorder();
		if( contentBorder instanceof CompoundBorder &&
			((CompoundBorder)contentBorder).getOutsideBorder() instanceof BasicTaskPaneUI.ContentPaneBorder &&
			((CompoundBorder)contentBorder).getInsideBorder() instanceof EmptyBorder )
		{
			content.setBorder( null );
		}

		// set non-UIResource color to background to avoid that it is lost when switching LaF
		background = UIManager.getColor( "TaskPane.background" );
		Color bg = content.getBackground();
		if( bg == null || bg instanceof UIResource ) {
			content.setBackground( new Color( background.getRGB(), true ) );
		}
	}

	roundHeight = FlatUIUtils.getUIInt( "TaskPane.roundHeight", UIManager.getInt( "Component.arc" ) );

	super.installDefaults();
}
 
Example #6
Source File: XpInfoBox.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void setStyle(Style style)
{
	container.removeAll();

	if (style == Style.SIMPLE)
	{
		progressWrapper.setBorder(new EmptyBorder(7, 7, 7, 7));
		container.add(skillWrapper, BorderLayout.WEST);
		container.add(progressWrapper, BorderLayout.CENTER);
	}
	else
	{
		progressWrapper.setBorder(new EmptyBorder(4, 7, 7, 7));
		container.add(skillWrapper, BorderLayout.WEST);
		container.add(statsPanel, BorderLayout.CENTER);
		container.add(progressWrapper, BorderLayout.SOUTH);
	}

	panel.revalidate();
	this.style = style;
}
 
Example #7
Source File: Test7022041.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
  * Check behaviour of method TitledBorder.getTitleColor()
  */
private static void checkTitleColor() {
    TitledBorder titledBorder = new TitledBorder(new EmptyBorder(1, 1, 1, 1));
    Color defaultColor = UIManager.getLookAndFeelDefaults().getColor("TitledBorder.titleColor");
    Color titledBorderColor = titledBorder.getTitleColor();

    // check default configuration
    if (defaultColor == null) {
        if (titledBorderColor == null) {
            return;
        }
        else {
            throw new RuntimeException("TitledBorder default color should be null");
        }
    }
    if (!defaultColor.equals(titledBorderColor)) {
        throw new RuntimeException("L&F default color " + defaultColor.toString()
                                 + " differs from TitledBorder color " + titledBorderColor.toString());
    }

    // title color is explicitly specified
    Color color = Color.green;
    titledBorder.setTitleColor(color);
    if (!color.equals(titledBorder.getTitleColor())) {
        throw new RuntimeException("TitledBorder color should be " + color.toString());
    }

    // title color is unspecified
    titledBorder.setTitleColor(null);
    if (!defaultColor.equals(titledBorder.getTitleColor())) {
        throw new RuntimeException("L&F default color " + defaultColor.toString()
                                 + " differs from TitledBorder color " + titledBorderColor.toString());
    }
}
 
Example #8
Source File: WindowsToolBarUI.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected Border createNonRolloverBorder() {
    if (XPStyle.getXP() != null) {
        return new EmptyBorder(3, 3, 3, 3);
    } else {
        return super.createNonRolloverBorder();
    }
}
 
Example #9
Source File: javax_swing_plaf_BorderUIResource_TitledBorderUIResource.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected TitledBorderUIResource getObject() {
    return new TitledBorderUIResource(
            new EmptyBorder(1, 2, 3, 4),
            "TITLE",
            TitledBorder.CENTER,
            TitledBorder.ABOVE_TOP,
            new Font("Serif", Font.ITALIC, 12),
            Color.RED);
}
 
Example #10
Source File: PolicyTool.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
ToolDialog(String title, PolicyTool tool, ToolWindow tw, boolean modal) {
    super(tw, modal);
    setTitle(title);
    this.tool = tool;
    this.tw = tw;
    addWindowListener(new ChildWindowListener(this));

    // Create some space around components
    ((JPanel)getContentPane()).setBorder(new EmptyBorder(6, 6, 6, 6));
}
 
Example #11
Source File: MirrorScanWindow.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the frame.
 */
public MirrorScanWindow() {
  setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  setBounds(100, 100, 800, 800);
  contentPane = new JPanel();
  contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  contentPane.setLayout(new BorderLayout(0, 0));
  setContentPane(contentPane);
}
 
Example #12
Source File: MetalworksDocumentFrame.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public MetalworksDocumentFrame() {
    super("", true, true, true, true);
    openFrameCount++;
    setTitle("Untitled Message " + openFrameCount);

    JPanel top = new JPanel();
    top.setBorder(new EmptyBorder(10, 10, 10, 10));
    top.setLayout(new BorderLayout());
    top.add(buildAddressPanel(), BorderLayout.NORTH);

    JTextArea content = new JTextArea(15, 30);
    content.setBorder(new EmptyBorder(0, 5, 0, 5));
    content.setLineWrap(true);



    JScrollPane textScroller = new JScrollPane(content,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    top.add(textScroller, BorderLayout.CENTER);


    setContentPane(top);
    pack();
    setLocation(offset * openFrameCount, offset * openFrameCount);

}
 
Example #13
Source File: AboutPanel.java    From Cafebabe with GNU General Public License v3.0 5 votes vote down vote up
public AboutPanel() {
	this.setContentType("text/html");
	this.setEditable(false);
	String license = Scanning.readInputStream(AboutPanel.class.getResourceAsStream("/resources/license.txt")).replace("\n", "<br>");
	this.setText(String.format(Scanning.readInputStream(AboutPanel.class.getResourceAsStream("/resources/about.txt")), Cafebabe.title, Cafebabe.version) + license);
	this.setFocusable(false);
	this.setOpaque(true);
	putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
	setBorder(new EmptyBorder(16, 16, 16, 16));
}
 
Example #14
Source File: FlatInspector.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
private static String toString( Border b ) {
	if( b == null )
		return "null";

	String s = b.getClass().getName();

	if( b instanceof EmptyBorder )
		s += '(' + toString( ((EmptyBorder)b).getBorderInsets() ) + ')';

	if( b instanceof UIResource )
		s += " UI";

	return s;
}
 
Example #15
Source File: bug6456844.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    JEditorPane ep = new JEditorPane();
    ep.setContentType("text/html");
    ep.setText("<html><body>abc</body></html>");
    ep.setBorder(new EmptyBorder(20, 20, 20, 20));
    ep.setBounds(0, 0, 100, 100);

    JTextComponent.DropLocation location =
            (JTextComponent.DropLocation) SwingAccessor.getJTextComponentAccessor().dropLocationForPoint(ep,
                    new Point(0, 0));

    if (location.getBias() == null) {
        throw new RuntimeException("null bias");
    }
}
 
Example #16
Source File: WindowsToolBarUI.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected Border createRolloverBorder() {
    if (XPStyle.getXP() != null) {
        return new EmptyBorder(3, 3, 3, 3);
    } else {
        return super.createRolloverBorder();
    }
}
 
Example #17
Source File: WindowsToolBarUI.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
protected Border createRolloverBorder() {
    if (XPStyle.getXP() != null) {
        return new EmptyBorder(3, 3, 3, 3);
    } else {
        return super.createRolloverBorder();
    }
}
 
Example #18
Source File: Test7149090.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    for (UIManager.LookAndFeelInfo lookAndFeel : UIManager.getInstalledLookAndFeels()) {
        for (Object[] defaultTitlePosition : DEFAULT_TITLE_POSITIONS) {
            if (defaultTitlePosition[0].equals(lookAndFeel.getName())) {
                UIManager.setLookAndFeel(lookAndFeel.getClassName());

                final int expectedPosition = (Integer) defaultTitlePosition[1];

                SwingUtilities.invokeAndWait(new Runnable() {
                    @Override
                    public void run() {
                        List<TitledBorder> borders = new ArrayList<>();

                        borders.add(BorderFactory.createTitledBorder(new EmptyBorder(0, 0, 0, 0), "Title"));

                        try {
                            Method getPositionMethod = TitledBorder.class.getDeclaredMethod("getPosition");

                            getPositionMethod.setAccessible(true);

                            for (TitledBorder border : borders) {
                                int position = (Integer) getPositionMethod.invoke(border);

                                if (position != expectedPosition) {
                                    throw new RuntimeException("Invalid title position");
                                }
                            }
                        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
                            throw new RuntimeException(e);
                        }
                    }
                });

                System.out.println("Test passed for LookAndFeel " + lookAndFeel.getName());
            }
        }
    }
}
 
Example #19
Source File: Test7022041.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
  * Check behaviour of method TitledBorder.getTitleFont()
  */
private static void checkTitleFont() {
    TitledBorder titledBorder = new TitledBorder(new EmptyBorder(1, 1, 1, 1));
    Font defaultFont = UIManager.getLookAndFeelDefaults().getFont("TitledBorder.font");
    Font titledBorderFont = titledBorder.getTitleFont();

    // check default configuration
    if (defaultFont == null) {
        if (titledBorderFont == null) {
            return;
        }
        else {
            throw new RuntimeException("TitledBorder default font should be null");
        }
    }
    if (!defaultFont.equals(titledBorderFont)) {
        throw new RuntimeException("L&F default font " + defaultFont.toString()
                                 + " differs from TitledBorder font " + titledBorderFont.toString());
    }

    // title font is explicitly specified
    Font font = new Font("Dialog", Font.PLAIN, 10);
    titledBorder.setTitleFont(font);
    if (!font.equals(titledBorder.getTitleFont())) {
        throw new RuntimeException("TitledBorder font should be " + font.toString());
    }

    // title Font is unspecified
    titledBorder.setTitleFont(null);
    if (!defaultFont.equals(titledBorder.getTitleFont())) {
        throw new RuntimeException("L&F default font " + defaultFont.toString()
                                 + " differs from TitledBorder font " + titledBorderFont.toString());
    }
}
 
Example #20
Source File: ClosableDialog.java    From openAGV with Apache License 2.0 5 votes vote down vote up
/**
 * Creates new instance.
 *
 * @param parent The dialog's parent.
 * @param modal Whether the dialog is modal or not.
 * @param content The dialog's actual content.
 * @param title The dialog's title.
 */
public ClosableDialog(Component parent, boolean modal, JComponent content, String title) {
  super(JOptionPane.getFrameForComponent(parent), title, modal);
  initComponents();
  getContentPane().add(content, java.awt.BorderLayout.CENTER);
  content.setBorder(new EmptyBorder(new Insets(4, 4, 4, 4)));
  getRootPane().setDefaultButton(buttonClose);
  pack();
}
 
Example #21
Source File: DrawingViewScrollPane.java    From openAGV with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param drawingView The drawing view.
 * @param placardPanel The view's placard panel.
 */
public DrawingViewScrollPane(OpenTCSDrawingView drawingView,
                             DrawingViewPlacardPanel placardPanel) {
  this.drawingView = requireNonNull(drawingView, "drawingView");
  this.placardPanel = requireNonNull(placardPanel, "placardPanel");

  setViewport(new JViewport());
  getViewport().setView(drawingView);
  setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
  setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  setViewportBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
  setHorizontalScrollBar(new PlacardScrollbar());
  setLayout(new PlacardScrollPaneLayout());
  setBorder(new EmptyBorder(0, 0, 0, 0));

  // Horizontal and vertical rulers
  Ruler.Horizontal newHorizontalRuler = new Ruler.Horizontal(drawingView);
  drawingView.addPropertyChangeListener(newHorizontalRuler);
  newHorizontalRuler.setPreferredWidth(drawingView.getWidth());
  Ruler.Vertical newVerticalRuler = new Ruler.Vertical(drawingView);
  drawingView.addPropertyChangeListener(newVerticalRuler);
  newVerticalRuler.setPreferredHeight(drawingView.getHeight());
  setColumnHeaderView(newHorizontalRuler);
  setRowHeaderView(newVerticalRuler);

  this.add(placardPanel, JScrollPane.LOWER_LEFT_CORNER);

  // Register handler for rulers toggle button.
  placardPanel.getToggleRulersButton().addItemListener(
      new RulersToggleListener(placardPanel.getToggleRulersButton()));
  placardPanel.getToggleRulersButton().setSelected(rulersVisible);
}
 
Example #22
Source File: StandardDialog.java    From openAGV with Apache License 2.0 5 votes vote down vote up
/**
 * Passt die Größe des Dialogs nach dem Hinzufügen des Panels an.
 *
 * @param content
 */
protected final void initSize(JComponent content) {
  fContent = content;
  getContentPane().add(content, BorderLayout.CENTER);
  content.setBorder(new EmptyBorder(new Insets(3, 3, 3, 3)));
  getRootPane().setDefaultButton(okButton);
  pack();
}
 
Example #23
Source File: InternalFrameDemo.java    From darklaf with MIT License 5 votes vote down vote up
@Override
public JComponent createComponent() {
    desktop = new JDesktopPane();
    JPanel panel = new JPanel();
    panel.setBorder(new CompoundBorder(new EmptyBorder(20, 20, 20, 20),
                                       DarkBorders.createLineBorder(1, 1, 1, 1)));
    panel.setLayout(new BorderLayout());
    panel.add(desktop, BorderLayout.CENTER);

    createFrame();

    desktop.setDragMode(JDesktopPane.LIVE_DRAG_MODE);
    return new DemoPanel(desktop, new BorderLayout(), 10);
}
 
Example #24
Source File: UIManagerDefaults.java    From darklaf with MIT License 5 votes vote down vote up
private JComponent createSelectionPanel() {
    comboBox = new JComboBox<>();

    final JLabel label = new JLabel("Select Item:");
    label.setDisplayedMnemonic('S');
    label.setLabelFor(comboBox);

    ItemListener itemListener = e -> {
        selectedItem = null;
        if (table.isEditing()) {
            table.getCellEditor().stopCellEditing();
        }
        table.clearSelection();
        resetComponents();
    };

    byComponent = new JRadioButton("By Component", true);
    byComponent.setMnemonic('C');
    byComponent.addItemListener(itemListener);

    final JRadioButton byValueType = new JRadioButton("By Value Type");
    byValueType.setMnemonic('V');
    byValueType.addItemListener(itemListener);

    final ButtonGroup group = new ButtonGroup();
    group.add(byComponent);
    group.add(byValueType);

    final JPanel panel = new JPanel();
    panel.setBorder(new EmptyBorder(15, 0, 15, 0));
    panel.add(label);
    panel.add(comboBox);
    panel.add(byComponent);
    panel.add(byValueType);
    return panel;
}
 
Example #25
Source File: CreateUITable.java    From darklaf with MIT License 5 votes vote down vote up
private String parsePreview(final String key, final Object val, final int ident) {
    Object value = getValue(val);
    if (value instanceof Color) {
        return StringUtil.repeat(IDENT, ident)
               + String.format("<td style=\"background-color: #%s\" width=\"%d\" height=\"%d\">\n",
                               ColorUtil.toHex((Color) value), SAMPLE_WIDTH, SAMPLE_HEIGHT);
    } else if (value instanceof DarkSVGIcon) {
        return parseSVGIcon((DarkSVGIcon) value, ident);
    } else if ((value instanceof Border && !(value instanceof EmptyBorder))
               || value instanceof Font
               || (value instanceof Icon && !(value instanceof EmptyIcon))) {
        return parseImage(key, value, ident);
    }
    return StringUtil.repeat(IDENT, ident) + "<td></td>\n";
}
 
Example #26
Source File: DarkPanelPopupUI.java    From darklaf with MIT License 5 votes vote down vote up
protected HeaderButton createCloseButton() {
    HeaderButton closeButton = new HeaderButton(UIManager.getIcon("TabFramePopup.close.icon"), this);
    closeButton.setBorder(new EmptyBorder(4, 4, 4, 4));
    closeButton.addActionListener(e -> popupComponent.close());
    String tooltip = ResourceUtil.getResourceBundle("actions", popupComponent).getString("Actions.close");
    tooltip = tooltip + " (" + UIManager.getString("TabFramePopup.closeTooltipTextHint") + ")";
    closeButton.setToolTipText(tooltip);
    return closeButton;
}
 
Example #27
Source File: DarkTabbedPopupUI.java    From darklaf with MIT License 5 votes vote down vote up
protected void setupTabbedPane() {
    label.setBorder(new EmptyBorder(0, 5, 0, 5));
    JPanelUIResource buttonHolder = new JPanelUIResource();
    buttonHolder.setLayout(new BoxLayout(buttonHolder, BoxLayout.X_AXIS));
    buttonHolder.add(Box.createHorizontalStrut(1));
    buttonHolder.add(closeButton);
    buttonHolder.add(Box.createHorizontalStrut(1));
    buttonHolder.setOpaque(false);
    tabbedPane.setOpaque(false);
    tabbedPane.putClientProperty("JTabbedPane.leadingComponent", label);
    tabbedPane.putClientProperty("JTabbedPane.trailingComponent", buttonHolder);
}
 
Example #28
Source File: DarkSpinnerUI.java    From darklaf with MIT License 5 votes vote down vote up
@Override
protected Component createNextButton() {
    nextButton = createArrow(SwingConstants.NORTH);
    nextButton.setName("Spinner.nextButton");
    nextButton.setBorder(new EmptyBorder(1, 1, 1, 1));
    nextButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    installNextButtonListeners(nextButton);
    return nextButton;
}
 
Example #29
Source File: PolicyTool.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
ToolDialog(String title, PolicyTool tool, ToolWindow tw, boolean modal) {
    super(tw, modal);
    setTitle(title);
    this.tool = tool;
    this.tw = tw;
    addWindowListener(new ChildWindowListener(this));

    // Create some space around components
    ((JPanel)getContentPane()).setBorder(new EmptyBorder(6, 6, 6, 6));
}
 
Example #30
Source File: javax_swing_border_TitledBorder.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected TitledBorder getObject() {
    return new TitledBorder(
            new EmptyBorder(1, 2, 3, 4),
            "TITLE",
            TitledBorder.CENTER,
            TitledBorder.ABOVE_TOP,
            new Font("Arial", Font.ITALIC, 12),
            Color.RED);
}