Tabnine Logo
JComponent.setBorder
Code IndexAdd Tabnine to your IDE (free)

How to use
setBorder
method
in
javax.swing.JComponent

Best Java code snippets using javax.swing.JComponent.setBorder (Showing top 20 results out of 2,106)

Refine searchRefine arrow

  • Window.setVisible
  • Container.add
  • JFrame.setDefaultCloseOperation
  • Window.pack
  • JPanel.<init>
  • JFrame.<init>
origin: stackoverflow.com

private JFrame frame = new JFrame("Test");
private JPanel panel = new JPanel();
private JLabel label = new JLabel("CenteredJLabel");
  panel.add(label);
  panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  frame.add(panel);
  frame.setSize(400, 300);
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
origin: stackoverflow.com

setBorder(BorderFactory.createCompoundBorder(
   BorderFactory.createTitledBorder("Player Editor"),
   BorderFactory.createEmptyBorder(5, 5, 5, 5)));
  FieldTitle fieldTitle = FieldTitle.values()[i];
  gbc = createGbc(0, i);
  add(new JLabel(fieldTitle.getTitle() + ":", JLabel.LEFT), gbc);
  gbc = createGbc(1, i);
  JTextField textField = new JTextField(10);
  add(textField, gbc);
origin: stackoverflow.com

JPanel gui = new JPanel(new GridLayout(2,0,5,5));
gui.setBorder(new EmptyBorder(10,10,10,10));
gui.setBackground(Color.RED);
l1.setBorder(brdrRight);
gui.add(l1);
l2.setBorder(brdrLeft);
l2.setBackground(Color.YELLOW);
l2.setOpaque(true);
gui.add(l2);
JPanel p1 = new JPanel();
p1.add(new JLabel("Panel 1"));
p1.setBorder(brdrRight);
p1.setOpaque(false);
gui.add(p1);
JPanel p2 = new JPanel();
p2.add(new JLabel("Panel 2"));
p2.setBorder(brdrLeft);
gui.add(p2);
origin: camunda/camunda-bpm-platform

getContentPane().add(cp, BorderLayout.NORTH);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
final JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setBorder(BorderFactory.createTitledBorder("Events: "));
scrollPane.setPreferredSize(new Dimension(900, 300));
getContentPane().add(jsp, BorderLayout.CENTER);
pack();
setVisible(true);
origin: stackoverflow.com

final JPanel gui = new JPanel(new BorderLayout(5,5));
gui.setBorder( new TitledBorder("BorderLayout(5,5)") );
JPanel plafComponents = new JPanel(
  new FlowLayout(FlowLayout.RIGHT, 3,3));
plafComponents.setBorder(
  new TitledBorder("FlowLayout(FlowLayout.RIGHT, 3,3)") );
plafComponents.add(plafChooser);
plafComponents.add(pack);
gui.add(plafComponents, BorderLayout.NORTH);
JPanel dynamicLabels = new JPanel(new BorderLayout(4,4));
dynamicLabels.setBorder(
  new TitledBorder("BorderLayout(4,4)") );
gui.add(dynamicLabels, BorderLayout.WEST);
final JPanel labels = new JPanel(new GridLayout(0,2,3,3));
labels.setBorder(
  new TitledBorder("GridLayout(0,2,3,3)") );
JPanel imagePanel = new JPanel(new GridBagLayout());
imagePanel.setBorder(
  new TitledBorder("GridBagLayout()") );
frame.pack();
origin: camunda/camunda-bpm-platform

protected JPanel createStatusArea() {
 JPanel statusArea = new JPanel();
 JLabel status =
   new JLabel("No log records to display.");
 _statusLabel = status;
 status.setHorizontalAlignment(JLabel.LEFT);
 statusArea.setBorder(BorderFactory.createEtchedBorder());
 statusArea.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
 statusArea.add(status);
 return (statusArea);
}
origin: camunda/camunda-bpm-platform

/**
 * Creates a new <code>DetailPanel</code> instance.
 *
 * @param aTable the table to listen for selections on
 * @param aModel the model backing the table
 */
DetailPanel(JTable aTable, final MyTableModel aModel) {
  mModel = aModel;
  setLayout(new BorderLayout());
  setBorder(BorderFactory.createTitledBorder("Details: "));
  mDetails = new JEditorPane();
  mDetails.setEditable(false);
  mDetails.setContentType("text/html");
  add(new JScrollPane(mDetails), BorderLayout.CENTER);
  final ListSelectionModel rowSM = aTable.getSelectionModel();
  rowSM.addListSelectionListener(this);
}
origin: stackoverflow.com

l.setBorder(new LineBorder(Color.RED, 2));
return l;
SwingUtilities.invokeLater(new Runnable() {
  public void run() {
    JPanel p = new JPanel(new GridLayout(2,2,4,4));
    p.setBackground(Color.black);
    p.setBorder(new EmptyBorder(4,4,4,4));
    JPanel border = new JPanel(new BorderLayout());
    border.add(getLabel(
      "Border", SwingConstants.CENTER), BorderLayout.CENTER);
    p.add(border);
    JPanel gridbag = new JPanel(new GridBagLayout());
    gridbag.add(getLabel("GridBag"));
    p.add(gridbag);
    p.add(box);
    JFrame f = new JFrame("Streeeetch me..");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setContentPane(p);
    f.pack();
    f.setLocationByPlatform(true);
    f.setVisible(true);
origin: stackoverflow.com

private JButton stopButton = new JButton();
private JButton pauseButton = new JButton();
private JPanel mainPanel = new JPanel();
private JProgressBar progressBar = new JProgressBar();
 progressBar.setBorderPainted(true);
 JPanel btnPanel = new JPanel(new GridLayout(1, 0, 5, 0));
 btnPanel.add(playButton);
 btnPanel.add(pauseButton);
 btnPanel.add(stopButton);
 mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15));
 mainPanel.add(btnPanel, BorderLayout.CENTER);
 mainPanel.add(progressBar, BorderLayout.PAGE_END);
origin: stackoverflow.com

this.setBorder(BorderFactory.createEmptyBorder(N, N, N, N));
for (int r = 0; r < N; r++) {
  for (int c = 0; c < N; c++) {
    this.add(create(r + N, r + 1, c + 2));
sb.append("</html></body>");
JLabel label = new JLabel(sb.toString(), JLabel.CENTER);
label.setBorder(BorderFactory.createLineBorder(Color.lightGray));
return label;
JFrame f = new JFrame("HTMLFractions");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(this);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
origin: stackoverflow.com

int h = bi.getHeight();
int step = w/3;
JPanel p = new JPanel(new GridLayout(3,3));
p.setOpaque(false);
int count = 0;
      button.setBorder(null);
      p.add(button);
    } else {
      JLabel label = new JLabel(new ImageIcon(icon));
      p.add(label);
JPanel center = new JPanel(new GridBagLayout());
center.setBackground(Color.BLACK);
center.add(p);
JOptionPane.showMessageDialog(null, center);
origin: stackoverflow.com

Runnable r = new Runnable() {
 public void run() {
  final JFrame f = new JFrame("Test Screenshot");
  f.setJMenuBar(mb);
  JPanel p = new JPanel( new BorderLayout(5,5) );
  p.setBorder( new TitledBorder("Main GUI") );
  p.add( new JScrollPane(new JTree()),
   BorderLayout.WEST );
  p.add( new JScrollPane( new JTextArea(HELP,10,30) ),
   BorderLayout.CENTER );
  f.pack();
  f.setLocationRelativeTo(null);
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  f.setVisible(true);
origin: stackoverflow.com

private JPanel mainPanel = new JPanel();
private SwingPropertyChangeSupport spcSupport = new SwingPropertyChangeSupport(
   this);
 JPanel buttonsPanel = createButtonsPanel();
 mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
 mainPanel.setLayout(new BorderLayout(5, 5));
 mainPanel.add(textAreasPanel, BorderLayout.CENTER);
 mainPanel.add(buttonsPanel, BorderLayout.PAGE_END);
 JPanel buttonsPanel = new JPanel(new GridLayout(2, 0, 5, 5));
 for (final GuiButtonText guiBtnText : GuiButtonText.values()) {
   AbstractAction btnAction = new AbstractAction(guiBtnText.getText()) {
   buttonsPanel.add(button);
 JPanel textAreasPanel = new JPanel();
 textAreasPanel.setLayout(new BoxLayout(textAreasPanel,
    BoxLayout.PAGE_AXIS));
   JScrollPane scrollPane = new JScrollPane(tArea);
   JPanel outerPanel = new JPanel(new BorderLayout());
   outerPanel.setBorder(BorderFactory.createTitledBorder(textDest.getText()));
   outerPanel.add(scrollPane);
   textAreasPanel.add(outerPanel);
origin: stackoverflow.com

this.setBorder(BorderFactory.createTitledBorder("Panel " + n));
GroupLayout layout = new GroupLayout(this);          
this.setLayout(layout);
JFrame f = new JFrame("GroupPanel");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS));
f.add(new GroupPanel(1));
f.add(new GroupPanel(2));
f.add(Box.createVerticalGlue());
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
origin: stackoverflow.com

setBorder(standardBorder);
setCursor( new Cursor(Cursor.HAND_CURSOR) );
setBorder(activeBorder);
try {
  Desktop.getDesktop().browse(target);
setBorder(standardBorder);
setBorder(hoverBorder);
setBorder(standardBorder);
setBorder(standardBorder);
setBorder(hoverBorder);
JPanel p = new JPanel(new GridLayout(0,1));
File f = new File(".","LinkLabel.java");
p.add(linkLabelFile);
p.add(linkLabelWeb);
JPanel labelConstrain = new JPanel(new BorderLayout());
labelConstrain.add( linkLabelConstrain, BorderLayout.EAST );
p.add(labelConstrain);
origin: stackoverflow.com

JFrame frame = new JFrame("Input Integer Example");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
JPanel contentPane = new JPanel();
contentPane.setBorder(
  BorderFactory.createEmptyBorder(5, 5, 5, 5));
tField = new JTextField(10);
((AbstractDocument)tField.getDocument()).setDocumentFilter(
    new MyDocumentFilter());        
contentPane.add(tField); 
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
origin: stackoverflow.com

l.setBackground(bg);
l.setOpaque(true);
c.add(l);
  l.setBackground(bg);
  l.setOpaque(true);
  c.add(l);
        null, "Use gradient fille color?");
    boolean gradientFill = gradient == JOptionPane.OK_OPTION;
    JPanel gui = new JPanel(new GridLayout(0, 8, 0, 0));
    gui.setBorder(new BevelBorder(
        BevelBorder.LOWERED,
        Color.GRAY.brighter(), Color.GRAY,
        JOptionPane.INFORMATION_MESSAGE);
    JPanel tileSet = new JPanel(new GridLayout(0, 6, 0, 0));
    tileSet.setOpaque(false);
    int[] tileSetOrder = new int[]{
origin: stackoverflow.com

JPanel contentPane = new JPanel(
        new GridLayout(0, 1, hGap, vGap));
contentPane.setBorder(
  BorderFactory.createEmptyBorder(hGap, vGap, hGap, vGap));
borderPanel = new JPanel(new BorderLayout(hGap, vGap));
borderPanel.setBorder(
  BorderFactory.createTitledBorder("BorderLayout"));
borderPanel.setOpaque(true);
contentPane.add(borderPanel);
flowPanel = new JPanel(new FlowLayout(
      FlowLayout.CENTER, hGap, vGap));
flowPanel.setBorder(
  BorderFactory.createTitledBorder("FlowLayout"));
flowPanel.setOpaque(true);
gridPanel.setBorder(
  BorderFactory.createTitledBorder("GridLayout"));
gridPanel.setOpaque(true);
gridBagPanel.setBorder(
  BorderFactory.createTitledBorder("GridBagLayout"));
gridBagPanel.setOpaque(true);
cardPanel.setBorder(
  BorderFactory.createTitledBorder("CardLayout"));
cardPanel.setOpaque(true);
origin: org.apache.log4j/com.springsource.org.apache.log4j

protected JPanel createStatusArea() {
 JPanel statusArea = new JPanel();
 JLabel status =
   new JLabel("No log records to display.");
 _statusLabel = status;
 status.setHorizontalAlignment(JLabel.LEFT);
 statusArea.setBorder(BorderFactory.createEtchedBorder());
 statusArea.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
 statusArea.add(status);
 return (statusArea);
}
origin: stackoverflow.com

    tree.expandRow(ii);
  JPanel buttonPanel = new JPanel(buttonLayout);
  gui.add(buttonPanel, BorderLayout.PAGE_START);
  buttonPanel.add(new JLabel("H Gap"));
mainLayout.setVgap(vGap);
buttonLayout.setHgap(hGap);
gui.setBorder(new EmptyBorder(vBorder,hBorder,vBorder,hBorder));
Container c = gui.getTopLevelAncestor();
if (c instanceof Window) {
  Window w = (Window)c;
  w.pack();
    JFrame f = new JFrame("White (OK Red) Space");
    f.add(gui);
    f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    f.pack();
    f.setVisible(true);
javax.swingJComponentsetBorder

Popular methods of JComponent

  • getPreferredSize
  • add
  • getHeight
  • getWidth
  • putClientProperty
  • setOpaque
  • setToolTipText
  • setBackground
  • getClientProperty
  • setEnabled
  • repaint
  • setPreferredSize
  • repaint,
  • setPreferredSize,
  • setVisible,
  • setForeground,
  • getActionMap,
  • addMouseListener,
  • getParent,
  • getBorder,
  • setFont

Popular in Java

  • Creating JSON documents from java classes using gson
  • addToBackStack (FragmentTransaction)
  • getContentResolver (Context)
  • onRequestPermissionsResult (Fragment)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • JComboBox (javax.swing)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now