TAILIEUCHUNG - Java Swing phần 5

Java Swing - O'Reilly Thêm một dấu phân cách vào thanh công cụ. Hãy chắc chắn để không nhầm lẫn các dấu phân cách thanh công cụ với JSeparator, mà là một thành phần Swing riêng biệt. Tách thanh công cụ được tạo ra bằng phương pháp này chỉ đơn giản là một vùng trống của không gian được sử dụng | Java Swing - O Reilly Adds a separator to the toolbar. Be sure not to confuse the toolbar separator with Jseparator which is a separate Swing component. The toolbar separator created by this method is simply a blank area of space used to provide spacing between groups of toolbar components. The size is normally up to the toolbar though you can specify the separator s size explicitly if you wish. protected void paintBorder Graphics g Overrides the paintBorder method in JComponent in order to observe the borderPainted property. protected PropertyChangeListener createActionChangeListener JButton b An internal utility method that creates an individual property change listener for a specific menu item. The programmer typically will not need to call this method. protected void addImpl Component comp Object constraints int index Adds the given component to the toolbar with the specified constraints and at the position specified by index. Creating a Toolbar The following example adds a toolbar to the JMenu example above creating a set of buttons from the Action objects we added to the menu. Just for fun we added tool tips to the buttons on the toolbar. We also allow the user to choose from a specified font combo box showing that you can use other kinds of components in a toolbar. Note that we add the combo box and a JLabei for the combo box as separate components and that the combo box uses its own actionPerformed method import . import . import . import . import . public class ToolBarExample extends JPanel implements ActionListener public JTextPane pane public JMenuBar menuBar public JToolBar toolBar string fonts Serif SansSerif Monospaced Dialog DialogInput public ToolBarExample super true menuBar new JMenuBar JMenu formatMenu new JMenu Justify J - 397 - Java Swing - O Reilly MenuAction leftJustifyAction new MenuAction Left new ImageIcon .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.