[Java] JtoolBar

Public on October 9, 2014
IMAGE :
 


tạo 1 thư mục trên project tên "image" và paste các hình ảnh ở trên vào

CODE :
package thanhcs.bai15;

import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JToolBar;
import javax.swing.border.TitledBorder;

public class Bai15_Joolbar extends JFrame{

    public Bai15_Joolbar() {
        // TODO Auto-generated constructor stub
        setLayout(new BorderLayout());
        
        JToolBar jtool = new JToolBar(); 
        jtool.add(new JButton(new ImageIcon("image/op.png")));
        jtool.addSeparator();
        jtool.add(new JButton(new ImageIcon("image/save.png")));
        jtool.addSeparator();
        jtool.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.RED), "JtollBar"));
        jtool.add(new JButton(new ImageIcon("image/print.png")));
        jtool.add(new JButton(new ImageIcon("image/share.png")));
        
        add(jtool, BorderLayout.NORTH);
        setVisible(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(500, 500);
        setLocationRelativeTo(null);
        
    }
    
    public static void main(String[] args) {
        
        new Bai15_Joolbar();
    }
}




[Advertising]Faster Thinking - Speed up your brain


Faster Thinking Game



sentiment_satisfied Emoticon