Example #1
0
  /**
   * Create a button to go inside of the toolbar. By default this will load an image resource. The
   * image filename is relative to the classpath (including the '.' directory if its a part of the
   * classpath), and may either be in a JAR file or a separate file.
   *
   * @param key The key in the resource file to serve as the basis of lookups.
   */
  protected JButton createToolbarButton(String key) {
    URL url = getResource(key + imageSuffix);
    JButton b =
        new JButton(new ImageIcon(url)) {

          @Override
          public float getAlignmentY() {
            return 0.5f;
          }
        };
    b.setRequestFocusEnabled(false);
    b.setMargin(new Insets(1, 1, 1, 1));

    String astr = getProperty(key + actionSuffix);
    if (astr == null) {
      astr = key;
    }
    Action a = getAction(astr);
    if (a != null) {
      b.setActionCommand(astr);
      b.addActionListener(a);
    } else {
      b.setEnabled(false);
    }

    String tip = getResourceString(key + tipSuffix);
    if (tip != null) {
      b.setToolTipText(tip);
    }

    return b;
  }
    BusinessPane() {
      setLayout(null);
      add(info_label);
      info_label.setBounds(10, 10, 300, 20);
      info_label.setFont(new Font("TimesRoman", Font.BOLD, 12));
      add(info_scroll);
      info_scroll.setBounds(5, 35, 615, 400);
      info_name.add(columnName[0]);
      info_name.add(columnName[1]);
      info_name.add(columnName[2]);
      info_name.add(columnName[3]);
      DefaultTableModel info_model = new DefaultTableModel(info_data, info_name);
      info_table.setModel(info_model);
      info_table.getColumnModel().getColumn(0).setWidth(25);
      info_table.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              if (e.getClickCount() == 1) { // click to trigger the event
                // show_selected();
                // System.out.print(table_selected(0));
              }
            }
          });

      add(B_refresh);
      B_refresh.setMargin(new java.awt.Insets(1, 1, 1, 1));
      B_refresh.setBounds(530, 440, 90, 25);
      B_refresh.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              update_table();
            }
          });
    }
Example #3
0
 /** Simple convenience routine for adding a button/icon to a Toolbar */
 public static JButton addTool(JToolBar toolBar, String name) {
   JButton b;
   b = new JButton(new ImageIcon("images/" + name + ".gif", name));
   toolBar.add(b);
   b.setToolTipText(name);
   b.setMargin(new Insets(0, 0, 0, 0));
   b.getAccessibleContext().setAccessibleName(name);
   return b;
 }
  public MenuedButton(Icon icon, JPopupMenu menu) {
    JButton iconBut = new JButton(icon);
    iconBut.setMargin(new Insets(0, 0, 0, 0));
    // iconBut.

    setMainButton(iconBut);
    setPopupMenu(menu);
    setShdPopupOnBtnClick(true);
    setPopupLocation(BELOW);
  }
  public void setUseFlatUI(boolean b) {
    main.setContentAreaFilled(!b);
    main.setFocusPainted(!b);
    main.setBorderPainted(!b);
    main.setMargin(new Insets(1, 1, 1, 1));

    popper.setContentAreaFilled(!b);
    popper.setFocusPainted(!b);
    popper.setBorderPainted(!b);
    popper.setMargin(new Insets(1, 1, 1, 1));

    setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    setOpaque(false);

    MouseAdapter ma =
        new MouseAdapter() {
          public void mouseEntered(MouseEvent e) {
            main.setContentAreaFilled(true);
            main.setBackground(new Color(216, 240, 254));
            // m.getMainButton().setForeground( Color.black );
            setBorder(new LineBorder(new Color(200, 200, 200), 1));
            setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

            popper.setBackground(new Color(242, 242, 242));
            popper.setContentAreaFilled(true);
            popper.setBorder(menu.getBorder());
          }

          public void mouseExited(MouseEvent e) {
            main.setContentAreaFilled(false);
            //	c.setForeground( Color.black );
            setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
            setCursor(Cursor.getDefaultCursor());

            popper.setContentAreaFilled(false);
            popper.setBorder(null);
          }
        };

    main.addMouseListener(ma);
    popper.addMouseListener(ma);
  }
 public JButton createImageButton(Action a) {
   JButton b = new JButton(a);
   b.setMargin(new Insets(0, 0, 0, 0));
   return b;
 }
    MemberPane() {
      setLayout(null);
      /*add(B_add);
      B_add.setMargin(new java.awt.Insets(1, 1, 1, 1));
      B_add.setBounds(230,440,90,25);
      B_add.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent event){
                	String[] data={T_title.getText(),T_director.getText(),T_actor.getText(),T_actress.getText()};
                	DBcore.addData("movie_info",data);
                	DBcore.showDB("movie_info", movie_column,info_data,info_table);
                }
            });*/
      add(B_delete);
      B_delete.setMargin(new java.awt.Insets(1, 1, 1, 1));
      B_delete.setBounds(330, 440, 90, 25);
      B_delete.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              if (id != null) {
                int confirm =
                    JOptionPane.showConfirmDialog(
                        mainFrame, "是否删除该用户?", "删除提示", JOptionPane.OK_CANCEL_OPTION);
                if (confirm == JOptionPane.OK_OPTION) {
                  Database.deleteData("member", "id", id);
                }
                T_title.setText("");
                T_director.setText("");
                T_actor.setText("");
                T_actress.setText("");
              }
              update_table();
            }
          });
      /*add(B_edit);
      B_edit.setMargin(new java.awt.Insets(1, 1, 1, 1));
      B_edit.setBounds(430,440,90,25);
      B_edit.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent event){
                	String[] data={T_title.getText(),T_director.getText(),T_actor.getText(),T_actress.getText()};
                	if(id!=null){
                	DBcore.updateData("movie_info", "no", id, detail_column, data);
                	}
                	DBcore.showDB("movie_info", movie_column,info_data,info_table);
                }
            });*/

      add(B_refresh);
      B_refresh.setMargin(new java.awt.Insets(1, 1, 1, 1));
      B_refresh.setBounds(530, 440, 90, 25);
      B_refresh.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              update_table();
            }
          });

      add(info_label);
      info_label.setBounds(10, 10, 300, 20);
      info_label.setFont(new Font("TimesRoman", Font.BOLD, 12));
      add(info_scroll);
      info_scroll.setBounds(5, 35, 615, 400);
      info_name.add(columnName[0]);
      info_name.add(columnName[1]);
      info_name.add(columnName[2]);
      info_name.add(columnName[3]);
      info_name.add(columnName[4]);
      DefaultTableModel info_model = new DefaultTableModel(info_data, info_name);
      info_table.setModel(info_model);
      info_table.getColumnModel().getColumn(0).setWidth(25);
      info_table.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              if (e.getClickCount() == 1) { // click to trigger the event
                show_selected();
                System.out.print(table_selected(0));
              }
            }
          });
      /*add(edit_panel);
      Border border=BorderFactory.createEtchedBorder(1);
      Border title1=BorderFactory.createTitledBorder(border,"Edit Area");
      edit_panel.setBorder(title1);
      edit_panel.setBounds(5,470,615,125);
      edit_panel.setLayout(null);
      edit_panel.add(L_title);
      edit_panel.add(L_director);
      edit_panel.add(L_actor);
      edit_panel.add(L_actress);
      edit_panel.add(T_title);
      edit_panel.add(T_director);
      edit_panel.add(T_actor);
      edit_panel.add(T_actress);
      L_title.setBounds(40,30,100,25);
      L_director.setBounds(325,30,100,25);
      L_actor.setBounds(40,75,100,25);
      L_actress.setBounds(325,75,100,25);
      T_title.setBounds(140,30,150,25);
      T_director.setBounds(425,30,150,25);
      T_actor.setBounds(140,75,150,25);
      T_actress.setBounds(425,75,150,25);*/
    }