Exemple #1
0
 public void actionPerformed(ActionEvent e) {
   for (int k = 0; k <= 4; k++) {
     // 先將全部顏色按鈕還原為浮凸狀
     btnCr[k].setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
     if (e.getSource() == btnCr[k]) {
       pane.setBackground(cr[k]);
       // 被點按的顏色按鈕呈凹陷狀
       btnCr[k].setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
     }
   }
 }
 @Override
 public JComponent createBannerPanel() {
   BannerPanel headerPanel1 = new BannerPanel("<b>This is a BannerPanel</b>");
   headerPanel1.setFont(new Font("Tahoma", Font.PLAIN, 11));
   headerPanel1.setBackground(Color.WHITE);
   headerPanel1.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
   return headerPanel1;
 }
Exemple #3
0
 public StatusPanel(JLabel label) {
   super();
   this.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
   this.setLayout(new FlowLayout(FlowLayout.LEFT));
   this.setBackground(bgColor);
   this.add(new JLabel("Status: "));
   this.add(label);
   label.setFont(new Font("Monospaced", Font.BOLD, 14));
 }
  Graphic(int width, int height, int ux, int uy) {
    frameWidth = width;
    frameHeight = height;

    unityX = ux;
    unityY = uy;

    this.setOpaque(true);
    this.setPreferredSize(new Dimension(frameWidth, frameHeight));
    this.setBorder(BorderFactory.createBevelBorder(1));

    instance = this;

    function = new FunctionGraphic(new MyTestFunction());
  }
    Title(String title) {
      super();
      setText(title);
      setHorizontalAlignment(SwingConstants.CENTER);
      setBorder(
          BorderFactory.createBevelBorder(
              BevelBorder.RAISED,
              UIManager.getColor("activeCaptionBorder"),
              UIManager.getColor("inactiveCaptionBorder")));

      // Forward mouse events to titlebar for moves.
      addMouseMotionListener(
          new MouseMotionListener() {
            public void mouseDragged(MouseEvent e) {
              forwardEventToParent(e);
            }

            public void mouseMoved(MouseEvent e) {
              forwardEventToParent(e);
            }
          });
      addMouseListener(
          new MouseListener() {
            public void mouseClicked(MouseEvent e) {
              forwardEventToParent(e);
            }

            public void mousePressed(MouseEvent e) {
              forwardEventToParent(e);
            }

            public void mouseReleased(MouseEvent e) {
              forwardEventToParent(e);
            }

            public void mouseEntered(MouseEvent e) {
              forwardEventToParent(e);
            }

            public void mouseExited(MouseEvent e) {
              forwardEventToParent(e);
            }
          });
    }
Exemple #6
0
  private void initUI() {
    names = new Vector<String>();
    names.add("单号");
    names.add("单据类型");
    names.add("单据简述");
    defaultTableModel = new EditableTableModel(names, 0);
    table = new MyTable(defaultTableModel);
    table.getColumnModel().getColumn(2).setPreferredWidth(300); // 设置单据简述一列较宽
    table.getColumnModel().getColumn(0).setWidth(50);
    table.getColumnModel().getColumn(1).setWidth(50);
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); // 设置可多选
    this.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = new Insets(10, 10, 10, 10);
    gbc.anchor = GridBagConstraints.EAST;

    gbc.weightx = gbc.weighty = 1.0;
    gbc.gridx = gbc.gridy = 0;
    gbc.gridwidth = 3;
    this.add(new JScrollPane(table), gbc);

    gbc.weightx = gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.NONE;
    gbc.gridwidth = 1;
    gbc.gridy++;
    this.add(approvebt, gbc);
    gbc.gridx++;
    this.add(disappbt, gbc);
    gbc.gridx++;
    this.add(refreshbt, gbc);

    this.setOpaque(false);
    this.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createBevelBorder(ALLBITS),
            "审批单据",
            TitledBorder.LEFT,
            TitledBorder.TOP,
            new Font("", Font.BOLD, 25)));
  }
  public BankAccountPanel(MainFrame par) {
    this.parent = par;
    this.setOpaque(false);
    this.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createBevelBorder(ALLBITS),
            "银行账户",
            TitledBorder.LEFT,
            TitledBorder.TOP,
            new Font("", Font.BOLD, 25)));

    initUI();
    setHotKey();

    addbt.addActionListener(this);
    deletebt.addActionListener(this);
    refreshbt.addActionListener(this);

    initBL();
    refresh();
  }
Exemple #8
0
  CGFrame() {
    pane.setBounds(20, 20, 200, 200);
    // 設定pane畫布的框線厚度為 4 像素
    pane.setBorder(BorderFactory.createLineBorder(Color.blue, 4));
    add(pane);

    for (int i = 0; i <= 4; i++) {
      btnCr[i] = new JButton();
      btnCr[i].setBounds(21 + i * 42, 230, 30, 30);
      // 設定顏色按鈕目前全部呈浮凸狀
      btnCr[i].setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
      btnCr[i].setBackground(cr[i]);
      add(btnCr[i]);
      btnCr[i].addActionListener(this);
    }

    setTitle("點選顏色");
    setLayout(null);
    setBounds(50, 50, 248, 310);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
  }
  public static void main(String[] args) {
    // create a JFrame to hold everything
    JFrame frame = new JFrame("Borders");

    // Create labels with borders.
    int center = SwingConstants.CENTER;
    JLabel labelOne = new JLabel("raised BevelBorder", center);
    labelOne.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
    JLabel labelTwo = new JLabel("EtchedBorder", center);
    labelTwo.setBorder(BorderFactory.createEtchedBorder());
    JLabel labelThree = new JLabel("MatteBorder", center);
    labelThree.setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink));
    JLabel labelFour = new JLabel("TitledBorder", center);
    Border etch = BorderFactory.createEtchedBorder();
    labelFour.setBorder(BorderFactory.createTitledBorder(etch, "Title"));
    JLabel labelFive = new JLabel("TitledBorder", center);
    Border low = BorderFactory.createLoweredBevelBorder();
    labelFive.setBorder(
        BorderFactory.createTitledBorder(low, "Title", TitledBorder.RIGHT, TitledBorder.BOTTOM));
    JLabel labelSix = new JLabel("CompoundBorder", center);
    Border one = BorderFactory.createEtchedBorder();
    Border two = BorderFactory.createMatteBorder(4, 4, 4, 4, Color.blue);
    labelSix.setBorder(BorderFactory.createCompoundBorder(one, two));

    // add components to the content pane
    Container c = frame.getContentPane(); // unecessary in 1.5+
    c.setLayout(new GridLayout(3, 2));
    c.add(labelOne);
    c.add(labelTwo);
    c.add(labelThree);
    c.add(labelFour);
    c.add(labelFive);
    c.add(labelSix);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
  }
Exemple #10
0
 public void init() {
   jf.setLayout(new GridLayout(2, 4));
   // 使用静态工厂方法创建BevelBorder
   Border bb =
       BorderFactory.createBevelBorder(
           BevelBorder.RAISED, Color.RED, Color.GREEN, Color.BLUE, Color.GRAY);
   jf.add(getPanelWithBorder(bb, "BevelBorder"));
   // 使用静态工厂方法创建LineBorder
   Border lb = BorderFactory.createLineBorder(Color.ORANGE, 10);
   jf.add(getPanelWithBorder(lb, "LineBorder"));
   // 使用静态工厂方法创建EmptyBorder,EmptyBorder就是在组件四周留空
   Border eb = BorderFactory.createEmptyBorder(20, 5, 10, 30);
   jf.add(getPanelWithBorder(eb, "EmptyBorder"));
   // 使用静态工厂方法创建EtchedBorder
   Border etb = BorderFactory.createEtchedBorder(EtchedBorder.RAISED, Color.RED, Color.GREEN);
   jf.add(getPanelWithBorder(etb, "EtchedBorder"));
   // 直接创建TitledBorder,TitledBorder边框就是为原有的边框增加标题
   TitledBorder tb =
       new TitledBorder(
           lb,
           "测试标题",
           TitledBorder.LEFT,
           TitledBorder.BOTTOM,
           new Font("StSong", Font.BOLD, 18),
           Color.BLUE);
   jf.add(getPanelWithBorder(tb, "TitledBorder"));
   // 直接创建MatteBorder,MatteBorder边框是EmptyBorder的子类,
   // 它可以指定留空区域的颜色或背景,此处是指定颜色
   MatteBorder mb = new MatteBorder(20, 5, 10, 30, Color.GREEN);
   jf.add(getPanelWithBorder(mb, "MatteBorder"));
   // 直接创建CompoundBorder,CompoundBorder边框将两个边框组合成新边框
   CompoundBorder cb = new CompoundBorder(new LineBorder(Color.RED, 8), tb);
   jf.add(getPanelWithBorder(cb, "CompoundBorder"));
   jf.pack();
   jf.setVisible(true);
 }
Exemple #11
0
  /** initialize GUI components */
  private JPanel initComponents() {
    JPanel panel = new JPanel();
    JScrollPane jScrollPane1 = new JScrollPane();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();

    jScrollPane1.setViewportView(jEditorPaneAbout);

    jButtonOk.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jButtonOkActionPerformed(e);
          }
        });

    jButtonOk.setText("OK");
    jLabel1.setText("Application:");
    jLabel2.setText("Version:");

    jTextFieldApplication.setBackground(new Color(255, 255, 255));
    jTextFieldApplication.setEditable(false);
    jTextFieldApplication.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));

    jTextFieldVersion.setBackground(new Color(255, 255, 255));
    jTextFieldVersion.setEditable(false);
    jTextFieldVersion.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));

    jEditorPaneAbout.setEditable(false);

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(panel);
    panel.setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(
                layout
                    .createSequentialGroup()
                    .add(
                        layout
                            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(
                                layout
                                    .createSequentialGroup()
                                    .addContainerGap()
                                    .add(
                                        layout
                                            .createParallelGroup(
                                                org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(
                                                jScrollPane1,
                                                org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                289,
                                                Short.MAX_VALUE)
                                            .add(
                                                layout
                                                    .createSequentialGroup()
                                                    .add(
                                                        layout
                                                            .createParallelGroup(
                                                                org.jdesktop.layout.GroupLayout
                                                                    .LEADING)
                                                            .add(
                                                                jTextFieldApplication,
                                                                org.jdesktop.layout.GroupLayout
                                                                    .PREFERRED_SIZE,
                                                                145,
                                                                org.jdesktop.layout.GroupLayout
                                                                    .PREFERRED_SIZE)
                                                            .add(jLabel1))
                                                    .add(4, 4, 4)
                                                    .add(
                                                        layout
                                                            .createParallelGroup(
                                                                org.jdesktop.layout.GroupLayout
                                                                    .LEADING)
                                                            .add(jLabel2)
                                                            .add(
                                                                jTextFieldVersion,
                                                                org.jdesktop.layout.GroupLayout
                                                                    .DEFAULT_SIZE,
                                                                140,
                                                                Short.MAX_VALUE)))))
                            .add(
                                layout
                                    .createSequentialGroup()
                                    .add(106, 106, 106)
                                    .add(
                                        jButtonOk,
                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                        101,
                                        Short.MAX_VALUE)
                                    .add(94, 94, 94)))
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .add(
                        layout
                            .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel1)
                            .add(jLabel2))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(
                        layout
                            .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(
                                jTextFieldApplication,
                                org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(
                                jTextFieldVersion,
                                org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(
                        jScrollPane1,
                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                        300,
                        Short.MAX_VALUE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jButtonOk)
                    .addContainerGap()));
    return panel;
  }
 private void jbInit() throws Exception {
   ////////////////////////////////////////////////////////
   // Init LAF
   ////////////////////////////////////////////////////////
   ButtonGroup grpLAF = new ButtonGroup();
   ActionListener lsnLAF =
       new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           int iIndex = mvtLAFItem.indexOf(evt.getSource());
           if (iIndex >= 0) changeLAF(iIndex);
         }
       };
   ////////////////////////////////////////////////////////
   UIManager.LookAndFeelInfo laf =
       new UIManager.LookAndFeelInfo(
           "Kunststoff", "com.incors.plaf.kunststoff.KunststoffLookAndFeel");
   marrLaf = UIManager.getInstalledLookAndFeels();
   int iIndex = 0;
   while (iIndex < marrLaf.length && !marrLaf[iIndex].getName().equals(laf.getName())) iIndex++;
   if (iIndex >= marrLaf.length) {
     UIManager.installLookAndFeel(laf);
     marrLaf = UIManager.getInstalledLookAndFeels();
   }
   for (iIndex = 0; iIndex < marrLaf.length; iIndex++) {
     JMenuItem mnu = new JRadioButtonMenuItem(marrLaf[iIndex].getName());
     mnu.addActionListener(lsnLAF);
     mvtLAFItem.addElement(mnu);
     mnuUI.add(mnu);
     grpLAF.add(mnu);
   }
   mnuUI.addSeparator();
   ////////////////////////////////////////////////////////
   // Init language
   ////////////////////////////////////////////////////////
   ButtonGroup grpLanguage = new ButtonGroup();
   ActionListener lsnLanguage =
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           int iIndex = mvtLanguageItem.indexOf(e.getSource());
           if (iIndex >= 0) changeDictionary((String) mvtLanguage.elementAt(iIndex));
         }
       };
   ////////////////////////////////////////////////////////
   String[] str = MonitorDictionary.getSupportedLanguage();
   for (iIndex = 0; iIndex < str.length; iIndex++) {
     JMenuItem mnu =
         new JRadioButtonMenuItem(MonitorDictionary.getDictionary(str[iIndex]).getLanguage());
     mnu.addActionListener(lsnLanguage);
     mvtLanguage.addElement(str[iIndex]);
     mvtLanguageItem.addElement(mnu);
     mnuUI.add(mnu);
     grpLanguage.add(mnu);
   }
   ////////////////////////////////////////////////////////
   // Add to main menu
   ////////////////////////////////////////////////////////
   mnuMain.removeAll();
   mnuMain.add(mnuSystem);
   mnuSystem.add(mnuSystem_Login);
   mnuSystem.add(mnuSystem_ChangePassword);
   mnuSystem.addSeparator();
   mnuSystem.add(mnuSystem_StopServer);
   mnuSystem.add(mnuSystem_EnableThreads);
   mnuMain.add(mnuUI);
   mnuMain.add(mnuHelp);
   mnuHelp.add(mnuHelp_About);
   ////////////////////////////////////////////////////////
   mnuMain.add(chkVietnamese);
   mnuMain.add(lblStatus);
   ////////////////////////////////////////////////////////
   pnlThread.setTabPlacement(JTabbedPane.LEFT);
   pnlThread.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
   ////////////////////////////////////////////////////////
   tblUser.addColumn("", 1, false);
   tblUser.addColumn("", 2, false, Global.FORMAT_DATE_TIME);
   tblUser.addColumn("", 3, false);
   ////////////////////////////////////////////////////////
   JPanel pnlMessage = new JPanel();
   pnlMessage.setLayout(new GridBagLayout());
   pnlMessage.add(
       new JScrollPane(txtBoard),
       new GridBagConstraints(
           0,
           0,
           2,
           1,
           1.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(2, 2, 2, 2),
           0,
           0));
   pnlMessage.add(
       txtMessage,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           1.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(2, 2, 2, 2),
           0,
           0));
   pnlMessage.add(
       btnSend,
       new GridBagConstraints(
           1,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(2, 2, 2, 2),
           0,
           0));
   txtBoard.setEditable(false);
   txtBoard.setAutoscrolls(true);
   txtBoard.setContentType("text/html");
   clearAll(txtBoard);
   ////////////////////////////////////////////////////////
   JPanel pnlUserButton = new JPanel(new GridLayout(1, 2, 4, 4));
   pnlUserButton.add(btnKick);
   pnlUserButton.add(btnRefresh);
   ////////////////////////////////////////////////////////
   JPanel pnlManager = new JPanel(new GridBagLayout());
   pnlManager.add(
       new JScrollPane(tblUser),
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           1.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(2, 2, 2, 2),
           0,
           0));
   pnlManager.add(
       pnlUserButton,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(4, 2, 4, 2),
           0,
           0));
   ////////////////////////////////////////////////////////
   pnlUser.setDividerLocation(320);
   pnlUser.setLeftComponent(pnlManager);
   pnlUser.setRightComponent(pnlMessage);
   pnlUser.setOneTouchExpandable(true);
   ////////////////////////////////////////////////////////
   setOrientation(JSplitPane.VERTICAL_SPLIT);
   setOneTouchExpandable(true);
   pnlThread.setVisible(false);
   pnlUser.setVisible(false);
   setTopComponent(pnlThread);
   setBottomComponent(pnlUser);
   ////////////////////////////////////////////////////////
   pmn.add(mnuSelectAll);
   pmn.addSeparator();
   pmn.add(mnuClearSelected);
   pmn.add(mnuClearAll);
   ////////////////////////////////////////////////////////
   setBorder(BorderFactory.createEmptyBorder());
   pnlUser.setBorder(BorderFactory.createEmptyBorder());
   pnlManager.setBorder(
       BorderFactory.createBevelBorder(
           javax.swing.border.BevelBorder.RAISED,
           Color.white,
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background")));
   pnlMessage.setBorder(
       BorderFactory.createBevelBorder(
           javax.swing.border.BevelBorder.RAISED,
           Color.white,
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background")));
   ////////////////////////////////////////////////////////
   Skin.applySkin(mnuMain);
   Skin.applySkin(tblUser);
   Skin.applySkin(pmn);
   Skin.applySkin(this);
   ////////////////////////////////////////////////////////
   // Default setting
   ////////////////////////////////////////////////////////
   Hashtable prt = null;
   try {
     prt = Global.loadHashtable(Global.FILE_CONFIG);
   } catch (Exception e) {
     prt = new Hashtable();
   }
   changeLAF(Integer.parseInt(StringUtil.nvl(prt.get("LAF"), "0")));
   changeDictionary(StringUtil.nvl(prt.get("Language"), "VN"));
   Skin.LANGUAGE_CHANGE_LISTENER = this;
   MonitorProcessor.setRootObject(this);
   updateKeyboardUI();
   ////////////////////////////////////////////////////////
   // Event handler
   ////////////////////////////////////////////////////////
   tblUser.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getClickCount() > 1) btnKick.doClick();
         }
       });
   ////////////////////////////////////////////////////////
   btnRefresh.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           try {
             DDTP request = new DDTP();
             request.setRequestID(String.valueOf(System.currentTimeMillis()));
             DDTP response = channel.sendRequest("ThreadProcessor", "queryUserList", request);
             if (response != null) {
               tblUser.setData((Vector) response.getReturn());
               if (mstrChannel != null) removeUser(mstrChannel);
             }
           } catch (Exception e) {
             e.printStackTrace();
             MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
           }
         }
       });
   ////////////////////////////////////////////////////////
   btnKick.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           int iSelected = tblUser.getSelectedRow();
           if (iSelected < 0) return;
           int iResult =
               MessageBox.showConfirmDialog(
                   pnlThread,
                   mdic.getString("ConfirmKick"),
                   Global.APP_NAME,
                   MessageBox.YES_NO_OPTION);
           if (iResult == MessageBox.NO_OPTION) return;
           try {
             String strChannel = (String) tblUser.getRow(iSelected).elementAt(0);
             DDTP request = new DDTP();
             request.setRequestID(String.valueOf(System.currentTimeMillis()));
             request.setString("strChannel", strChannel);
             DDTP response = channel.sendRequest("ThreadProcessor", "kickUser", request);
           } catch (Exception e) {
             e.printStackTrace();
             MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
           }
         }
       });
   ////////////////////////////////////////////////////////
   txtMessage.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           btnSend.doClick();
         }
       });
   ////////////////////////////////////////////////////////
   btnSend.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           if (txtMessage.getText().length() == 0) return;
           try {
             DDTP request = new DDTP();
             request.setString("strMessage", txtMessage.getText());
             channel.sendRequest("ThreadProcessor", "sendMessage", request);
             txtMessage.setText("");
           } catch (Exception e) {
             e.printStackTrace();
             MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
           }
         }
       });
   ////////////////////////////////////////////////////////
   mnuClearAll.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           clearAll(txtBoard);
         }
       });
   ////////////////////////////////////////////////////////
   mnuClearSelected.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           txtBoard.setEditable(true);
           txtBoard.replaceSelection("");
           txtBoard.setEditable(false);
         }
       });
   ////////////////////////////////////////////////////////
   mnuSelectAll.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           txtBoard.requestFocus();
           txtBoard.selectAll();
         }
       });
   ////////////////////////////////////////////////////////
   txtBoard.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getButton() == e.BUTTON3) pmn.show(txtBoard, e.getX(), e.getY());
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_Login.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           login();
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_ChangePassword.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           changePassword();
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_StopServer.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           stopServer();
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_EnableThreads.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           manageThreads();
         }
       });
   ////////////////////////////////////////////////////////
   mnuHelp_About.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           WindowManager.centeredWindow(new DialogAbout(PanelThreadManager.this));
         }
       });
   ////////////////////////////////////////////////////////
   chkVietnamese.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           switchKeyboard();
         }
       });
 }
Exemple #13
0
  public SceneLayoutApp() {
    super();
    new Pair();
    final JFrame frame = new JFrame("Scene Layout");

    final JPanel panel = new JPanel(new BorderLayout());
    frame.setContentPane(panel);
    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setMaximumSize(screenSize);
    frame.setSize(screenSize);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JMenuBar mb = new JMenuBar();
    frame.setJMenuBar(mb);

    final JMenu jMenu = new JMenu("File");
    mb.add(jMenu);
    mb.add(new JMenu("Edit"));
    mb.add(new JMenu("Help"));
    JMenu menu = new JMenu("Look and Feel");

    //
    // Get all the available look and feel that we are going to use for
    // creating the JMenuItem and assign the action listener to handle
    // the selection of menu item to change the look and feel.
    //
    UIManager.LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
    for (int i = 0; i < lookAndFeelInfos.length; i++) {
      final UIManager.LookAndFeelInfo lookAndFeelInfo = lookAndFeelInfos[i];
      JMenuItem item = new JMenuItem(lookAndFeelInfo.getName());
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              try {
                //
                // Set the look and feel for the frame and update the UI
                // to use a new selected look and feel.
                //
                UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
                SwingUtilities.updateComponentTreeUI(frame);
              } catch (ClassNotFoundException e1) {
                e1.printStackTrace();
              } catch (InstantiationException e1) {
                e1.printStackTrace();
              } catch (IllegalAccessException e1) {
                e1.printStackTrace();
              } catch (UnsupportedLookAndFeelException e1) {
                e1.printStackTrace();
              }
            }
          });
      menu.add(item);
    }

    mb.add(menu);
    jMenu.add(new JMenuItem(new scene.action.QuitAction()));

    panel.add(new JScrollPane(desktopPane), BorderLayout.CENTER);
    final JToolBar bar = new JToolBar();

    panel.add(bar, BorderLayout.NORTH);

    final JComboBox comboNewWindow =
        new JComboBox(
            new String[] {"320:180", "320:240", "640:360", "640:480", "1280:720", "1920:1080"});

    comboNewWindow.addActionListener(new CreateSceneWindowAction());

    comboNewWindow.setBorder(BorderFactory.createTitledBorder("Create New Window"));
    bar.add(comboNewWindow);
    bar.add(
        new AbstractAction("Progress Bars") {

          /** Invoked when an action occurs. */
          @Override
          public void actionPerformed(ActionEvent e) {
            new ProgressBarAnimator();
          }
        });
    bar.add(
        new AbstractAction("Sliders") {

          /** Invoked when an action occurs. */
          @Override
          public void actionPerformed(ActionEvent e) {
            new SliderBarAnimator();
          }
        });

    final JCheckBox permaViz = new JCheckBox();
    permaViz.setText("Show the dump window");
    permaViz.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

    dumpWindow = new JInternalFrame("perma dump window");
    dumpWindow.setContentPane(new JScrollPane(permText));

    permaViz.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dumpWindow.setVisible(permaViz.isSelected());
          }
        });

    comboNewWindow.setMaximumSize(comboNewWindow.getPreferredSize());

    permaViz.setSelected(false);
    bar.add(new CreateWebViewV1Action());
    bar.add(new CreateWebViewV2Action());
    bar.add(permaViz);
    desktopPane.add(dumpWindow);
    dumpWindow.setSize(400, 400);
    dumpWindow.setResizable(true);
    dumpWindow.setClosable(false);
    dumpWindow.setIconifiable(false);
    final JMenuBar m = new JMenuBar();
    final JMenu cmenu = new JMenu("Create");
    m.add(cmenu);
    final JMenuItem menuItem =
        new JMenuItem(
            new AbstractAction("new") {
              @Override
              public void actionPerformed(ActionEvent e) {
                Runnable runnable =
                    new Runnable() {
                      public void run() {
                        Object[] in = (Object[]) XSTREAM.fromXML(permText.getText());

                        final JInternalFrame ff = new JInternalFrame();

                        final ScenePanel c = new ScenePanel();
                        ff.setContentPane(c);
                        desktopPane.add(ff);
                        final Dimension d = (Dimension) in[0];
                        c.setMaximumSize(d);
                        c.setPreferredSize(d);

                        ff.setSize(d.width + 50, d.height + 50);
                        ScenePanel.panes.put(c, (List<Pair<Point, ArrayList<URL>>>) in[1]);

                        c.invalidate();
                        c.repaint();

                        ff.pack();
                        ff.setClosable(true);

                        ff.setMaximizable(false);
                        ff.setIconifiable(false);
                        ff.setResizable(false);
                        ff.show();
                      }
                    };

                SwingUtilities.invokeLater(runnable);
              }
            });
    cmenu.add(menuItem);
    //        JMenuBar menuBar = new JMenuBar();

    //        getContentPane().add(menuBar);

    dumpWindow.setJMenuBar(m);
    frame.setVisible(true);
  }
  @SuppressWarnings("serial")
  public JTableRenderer(final Object cell, final GraphComponent graphContainer) {
    this.cell = cell;
    this.graphContainer = graphContainer;
    this.graph = graphContainer.getGraph();
    setLayout(new BorderLayout());
    setBorder(
        BorderFactory.createCompoundBorder(
            ShadowBorder.getSharedInstance(), BorderFactory.createBevelBorder(BevelBorder.RAISED)));

    JPanel title = new JPanel();
    title.setBackground(new Color(149, 173, 239));
    title.setOpaque(true);
    title.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 1));
    title.setLayout(new BorderLayout());

    JLabel icon =
        new JLabel(new ImageIcon(JTableRenderer.class.getResource(IMAGE_PATH + "preferences.gif")));
    icon.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 1));
    title.add(icon, BorderLayout.WEST);

    JLabel label = new JLabel(String.valueOf(graph.getLabel(cell)));
    label.setForeground(Color.WHITE);
    label.setFont(title.getFont().deriveFont(Font.BOLD, 11));
    label.setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 2));
    title.add(label, BorderLayout.CENTER);

    JPanel toolBar2 = new JPanel();
    toolBar2.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 2));
    toolBar2.setOpaque(false);
    JButton button =
        new JButton(
            new AbstractAction(
                "", new ImageIcon(JTableRenderer.class.getResource(IMAGE_PATH + "minimize.gif"))) {

              public void actionPerformed(ActionEvent e) {
                graph.foldCells(graph.isCellCollapsed(cell), false, new Object[] {cell});
                ((JButton) e.getSource())
                    .setIcon(
                        new ImageIcon(
                            JTableRenderer.class.getResource(
                                IMAGE_PATH
                                    + ((graph.isCellCollapsed(cell))
                                        ? "maximize.gif"
                                        : "minimize.gif"))));
              }
            });
    button.setPreferredSize(new Dimension(16, 16));
    button.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    button.setToolTipText("Collapse/Expand");
    button.setOpaque(false);
    toolBar2.add(button);

    title.add(toolBar2, BorderLayout.EAST);
    add(title, BorderLayout.NORTH);

    // CellStyle style =
    // graph.getStylesheet().getCellStyle(graph.getModel(),
    // cell);
    // if (style.getStyleClass() == null) {
    table = new MyTable();
    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));

    if (graph.getModel().getChildCount(cell) == 0) {
      scrollPane.getViewport().setBackground(Color.WHITE);
      setOpaque(true);
      add(scrollPane, BorderLayout.CENTER);
    }

    scrollPane
        .getVerticalScrollBar()
        .addAdjustmentListener(
            new AdjustmentListener() {

              public void adjustmentValueChanged(AdjustmentEvent e) {
                graphContainer.refresh();
              }
            });

    label = new JLabel(new ImageIcon(JTableRenderer.class.getResource(IMAGE_PATH + "resize.gif")));
    label.setCursor(new Cursor(Cursor.NW_RESIZE_CURSOR));

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(label, BorderLayout.EAST);

    add(panel, BorderLayout.SOUTH);

    ResizeHandler resizeHandler = new ResizeHandler();
    label.addMouseListener(resizeHandler);
    label.addMouseMotionListener(resizeHandler);

    setMinimumSize(new Dimension(20, 30));
  }
  private static JPanel createOptionsPanel() {
    JLabel header = new JLabel("Options");
    header.setFont(header.getFont().deriveFont(Font.BOLD, 13));
    header.setOpaque(true);
    header.setBackground(new Color(0, 0, 128));
    header.setForeground(Color.WHITE);
    header.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createBevelBorder(
                BevelBorder.LOWERED, Color.white, Color.lightGray, Color.lightGray, Color.gray),
            BorderFactory.createEmptyBorder(0, 5, 0, 0)));
    header.setPreferredSize(new Dimension(100, 30));
    final JRadioButton style1 = new JRadioButton("Toolbar Style");
    final JRadioButton style2 = new JRadioButton("Toolbox Style");
    final JRadioButton style3 = new JRadioButton("Flat Style");
    final JRadioButton style4 = new JRadioButton("Hyperlink Style");
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(style1);
    buttonGroup.add(style2);
    buttonGroup.add(style3);
    buttonGroup.add(style4);
    JPanel switchPanel = new JPanel(new GridLayout(4, 1, 3, 3));
    switchPanel.add(style1);
    switchPanel.add(style2);
    switchPanel.add(style3);
    switchPanel.add(style4);
    style1.setSelected(true);

    style1.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (style1.isSelected()) {
              for (int i = 0; i < _buttons.length; i++) {
                JideButton button = _buttons[i];
                button.setButtonStyle(JideButton.TOOLBAR_STYLE);
              }
            }
          }
        });
    style2.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (style2.isSelected()) {
              for (int i = 0; i < _buttons.length; i++) {
                JideButton button = _buttons[i];
                button.setButtonStyle(JideButton.TOOLBOX_STYLE);
              }
            }
          }
        });
    style3.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (style3.isSelected()) {
              for (int i = 0; i < _buttons.length; i++) {
                JideButton button = _buttons[i];
                button.setButtonStyle(JideButton.FLAT_STYLE);
              }
            }
          }
        });
    style4.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (style4.isSelected()) {
              for (int i = 0; i < _buttons.length; i++) {
                JideButton button = _buttons[i];
                button.setButtonStyle(JideButton.HYPERLINK_STYLE);
              }
            }
          }
        });
    switchPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    JPanel panel = new JPanel();
    panel.setLayout(new JideBoxLayout(panel, JideBoxLayout.Y_AXIS));
    panel.add(header);
    panel.add(switchPanel);
    panel.add(Box.createGlue(), JideBoxLayout.VARY);
    return panel;
  }