Results 1 to 6 of 6

Thread: Confused with BorderFactory class

  1. #1
    Join Date
    Dec 2009
    Posts
    32

    Confused with BorderFactory class

    Hi All,

    I just started to learn advanced java programming. Some of the concept of this programming seems quit confusing. And BorderFactory class is one it. I don't have any idea about the methods and constructors of BorderFactory class of java. If you posses sound knowledge about the BorderFactory class then please try to share it with me. Your any help over BorderFactory class would be greatly appreciated.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Confused with BorderFactory class

    Every BorderFactory class component can have one or more borders. Borders are incredibly useful objects that, while not themselves components, know how to draw the edges of Swing components. Borders are useful not only for drawing lines and fancy edges, but also for providing titles and empty space around components. To put a border around a JComponent, you use its setBorder method. You can use the BorderFactory class to create most of the borders that Swing provides.

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Confused with BorderFactory class

    Hi,

    I suggest you to study following example of BorderFactory class, which will definitely solve your confusion about it:
    Code:
    import javax.swing.BorderFactory;
    
    public class BorderFactoryMain extends JFrame {
      public MainClass(String name) {
        getContentPane().setLayout(new FlowLayout());
        JLabel labelTwo = new JLabel("www.java2s.com");
        labelTwo.setBorder(BorderFactory.createEtchedBorder());
        
        add(labelTwo);
       
        JLabel labelThree01 = new JLabel("MatteBorder");
        labelThree01.setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink));
        add(labelThree01);
        
        JLabel labelSix1 = new JLabel("CompoundBorder");
        Border one = BorderFactory.createEtchedBorder();
        Border two = BorderFactory.createMatteBorder(4, 4, 4, 4, Color.blue);
        labelSix1.setBorder(BorderFactory.createCompoundBorder(one, two));
        add(labelSix1);
          }
      public static void main(String[] ardgs) {
        JFrame frame1 = new MainClass("javax.swing.JButton");
        frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame1.pack();
        frame1.setVisible(true);
    
      }
    }

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Confused with BorderFactory class

    Below I have give few methods of BorderFactory class along with it's different parameters:
    1. createTitledBorder(String ttl)
    2. createTitledBorder(Border bdr, String ttl, int ttlJustification, int ttlPosition, Font ttlFont, Color ttlColor)
    3. createTitledBorder(Border bdr, String ttl, int ttlJustification, int ttlPosition, Font ttlFont)
    4. createTitledBorder(Border bdr, String ttl, int ttlJustification, int ttlPosition)
    5. createTitledBorder(Border bdr, String ttl)

  5. #5
    Join Date
    May 2008
    Posts
    2,012

    Re: Confused with BorderFactory class

    Hi friend,
    I hope something below code can help you to know about the BorderFactory class:
    Code:
    import javax.swing.JFrame;
    import javax.swing.border.Border;
    import javax.swing.JButton;
    
    public class BorderFactoryDM
     {
      public static void main(String[] arf) {
        JFrame FND = new JFrame("Empty Borders");
        FND.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Border emptyBorder1 = BorderFactory.createEmptyBorder(20, 20, 0, 0);
        JButton emptyButton1 = new JButton("With Empty");
        emptyButton1.setBorder(emptyBorder1);
        JButton nonemptyButton1 = new JButton("Without Empty");
        Container contentPane1 = FND.getContentPane();
        contentPane1.add(emptyButton1, BorderLayout.NORTH);
        contentPane1.add(nonemptyButton1, BorderLayout.SOUTH);
        FND.pack();
        FND.setSize(400, FND.getHeight());
        FND.setVisible(true);
      }
    }

  6. #6
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Confused with BorderFactory class

    Hello friend,

    A BorderFactory class is nothing but the 'Factory class' which is used for the for Border object vending. The BorderFactory class of java is taken form the java package known as 'java.lang.Object'. This java class extends 'Object' interface of java. The 'createMatteBorder' method of BorderFactory class is used for the creations of 'matte-look border' and which comprises many specified icon tiles.

Similar Threads

  1. Confused about Scrollbar class
    By Jagruti23 in forum Software Development
    Replies: 5
    Last Post: 06-03-2010, 04:18 PM
  2. Confused with JInternalFrame class
    By Truster in forum Software Development
    Replies: 5
    Last Post: 17-02-2010, 09:58 AM
  3. Confused with JSpinner class
    By Bottlenecked in forum Software Development
    Replies: 4
    Last Post: 15-02-2010, 09:51 AM
  4. Confused with OverlayLayout class
    By Bottlenecked in forum Software Development
    Replies: 5
    Last Post: 12-02-2010, 09:37 AM
  5. Confused with 'Class SpinnerNumberModel'
    By Khan Baba in forum Software Development
    Replies: 5
    Last Post: 11-02-2010, 11:08 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,029,377.75423 seconds with 16 queries