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

📄 transferobjectframe.java

📁 Java灵感编程1-101之61-80
💻 JAVA
字号:
package transferobject;import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.*;import com.borland.jbcl.layout.*;import javax.swing.event.*;/** * <p>Title: TransferObject  Demo</p> * <p>Description: This is a TransferObject Demo</p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: D6-125</p> * @author liujun * @version 1.0 */public class TransferObjectFrame extends JFrame {  JPanel contentPane;  BorderLayout borderLayout1 = new BorderLayout();  JPanel jPanel1 = new JPanel();  JRadioButton jRadioButton1 = new JRadioButton();  JRadioButton jRadioButton2 = new JRadioButton();  JRadioButton jRadioButton3 = new JRadioButton();  JRadioButton jRadioButton4 = new JRadioButton();  ButtonGroup buttonGroup1 = new ButtonGroup();  Border border1;  JPanel jPanel2 = new JPanel();  JSlider jSlider1 = new JSlider();  Border border2;  TitledBorder titledBorder1;  JRadioButton jRadioButton5 = new JRadioButton();  //声明自己创建的Panel1类变量  Panel1 myPanel1 = new Panel1();  //Construct the frame  public TransferObjectFrame() {    enableEvents(AWTEvent.WINDOW_EVENT_MASK);    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  //Component initialization  private void jbInit() throws Exception  {    //setIconImage(Toolkit.getDefaultToolkit().createImage(TransferObjectFrame.class.getResource("[Your Icon]")));    contentPane = (JPanel) this.getContentPane();    border1 = new EtchedBorder(EtchedBorder.RAISED,Color.white,new Color(134, 134, 134));    border2 = new TitledBorder(new EtchedBorder(EtchedBorder.RAISED,Color.white,new Color(134, 134, 134)),"刻度");    titledBorder1 = new TitledBorder("");    contentPane.setLayout(borderLayout1);    this.setSize(new Dimension(400, 300));    this.setTitle("Transfer Object Frame Demo");    jRadioButton1.setSelected(true);    jRadioButton1.setText("旋转");    jRadioButton1.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jRadioButton1_actionPerformed(e);      }    });    jRadioButton2.setText("放大或缩小");    jRadioButton2.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jRadioButton2_actionPerformed(e);      }    });    jRadioButton3.setText("平行移动");    jRadioButton3.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jRadioButton3_actionPerformed(e);      }    });    jRadioButton4.setText("垂直移动");    jRadioButton4.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jRadioButton4_actionPerformed(e);      }    });    jSlider1.setOrientation(JSlider.VERTICAL);    jSlider1.setMaximum(180);    jSlider1.setMinimum(1);    jSlider1.setPaintTicks(true);    jSlider1.setBorder(border2);    jSlider1.addChangeListener(new javax.swing.event.ChangeListener() {      public void stateChanged(ChangeEvent e) {        jSlider1_stateChanged(e);      }    });    jRadioButton5.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jRadioButton5_actionPerformed(e);      }    });    jRadioButton5.setText("倾斜");    contentPane.add(jPanel1,  BorderLayout.NORTH);    jPanel1.add(jRadioButton1, null);    jPanel1.add(jRadioButton2, null);    jPanel1.add(jRadioButton3, null);    jPanel1.add(jRadioButton4, null);    jPanel1.add(jRadioButton5, null);    buttonGroup1.add(jRadioButton1);    buttonGroup1.add(jRadioButton2);    buttonGroup1.add(jRadioButton3);    buttonGroup1.add(jRadioButton4);    buttonGroup1.add(jRadioButton5);    contentPane.add(jPanel2,  BorderLayout.WEST);    jPanel2.add(jSlider1, null);    //添加Panel1类变量到界面    contentPane.add(myPanel1, BorderLayout.CENTER);  }  //Overridden so we can exit when window is closed  protected void processWindowEvent(WindowEvent e) {    super.processWindowEvent(e);    if (e.getID() == WindowEvent.WINDOW_CLOSING) {      System.exit(0);    }  }  void jRadioButton1_actionPerformed(ActionEvent e) {   change();  }  void jRadioButton2_actionPerformed(ActionEvent e) {   change();  }  void jRadioButton3_actionPerformed(ActionEvent e) {   change();  }  void jRadioButton4_actionPerformed(ActionEvent e) {   change();  }  void jSlider1_stateChanged(ChangeEvent e) {   change();  }  void jRadioButton5_actionPerformed(ActionEvent e) {   change();  }  void change()  {      float x=jSlider1.getValue();//得到滑动条数值    if(jRadioButton1.isSelected())        {//旋转        myPanel1.setRotate(x);        }    if(jRadioButton2.isSelected())        {//放大       x=x/90.0f;       myPanel1.setScale(x);        }    if(jRadioButton3.isSelected())       {//水平平移        x=x-90.0f;        myPanel1.setTranslateX(x);       }    if(jRadioButton4.isSelected())       {//垂直平移       x=x-90.0f;        myPanel1.setTranslateY(x);       }    if(jRadioButton5.isSelected())       {//倾斜      x=(x-90.0f)/45.0f;      myPanel1.setShear(x);       }  }}

⌨️ 快捷键说明

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