⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 buttonbar.java

📁 一个简单的JAVA绘图程序
💻 JAVA
字号:
//********************************************************************
//  ButtonBar.java       Author: Lewis and Loftus / Peter DePasquale
//
//  Refinement #1
//
//  Represents the primary toolbar of controls for PaintBox.
//********************************************************************

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ButtonBar extends JToolBar
{
   private JRadioButton selectButton, lineButton, ovalButton;
   private JRadioButton rectButton, polyButton;
   private JButton strokeButton;

   //-----------------------------------------------------------------
   //  Sets up the panel of buttons.
   //-----------------------------------------------------------------
   public ButtonBar ()
   {
      ButtonListener listener = new ButtonListener ();

      ButtonGroup shapeGroup = new ButtonGroup ();

      selectButton = new JRadioButton (
                            new ImageIcon ("../images/selectOn.gif"));
      selectButton.addActionListener (listener);

      lineButton = new JRadioButton (
                                new ImageIcon ("../images/line.gif"));
      lineButton.addActionListener (listener);

      ovalButton = new JRadioButton (
                                new ImageIcon ("../images/oval.gif"));
      ovalButton.addActionListener (listener);

      rectButton = new JRadioButton (
                                new ImageIcon ("../images/rect.gif"));
      rectButton.addActionListener (listener);

      polyButton = new JRadioButton (
                                new ImageIcon ("../images/poly.gif"));
      polyButton.addActionListener (listener);

      strokeButton = new JButton (" Stroke ");
      strokeButton.setBackground (Color.black);
      strokeButton.setForeground (Color.white);
      strokeButton.addActionListener (listener);

      add (selectButton);
      add (new JToolBar.Separator ());
      add (lineButton);
      add (ovalButton);
      add (rectButton);
      add (polyButton);
      add (new JToolBar.Separator ());
      add (strokeButton);

      setFloatable (false);
   }

   //*****************************************************************
   //  An inner class to handle button events.
   //*****************************************************************
   private class ButtonListener implements ActionListener
   {
      //--------------------------------------------------------------
      //  Responds to action events caused by buttons.
      //--------------------------------------------------------------
      public void actionPerformed (ActionEvent event)
      {
         //  to be implemented
      }
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -