databasesyncdesktopview.java#1.2
来自「数据库远程同步软件NetBeans项目源文件 项目采用Jdesktop集成组件」· 2 代码 · 共 383 行 · 第 1/2 页
2
383 行
menuBar.add(helpMenu); statusPanel.setName("statusPanel"); // NOI18N statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N statusMessageLabel.setName("statusMessageLabel"); // NOI18N statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N progressBar.setName("progressBar"); // NOI18N javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel); statusPanel.setLayout(statusPanelLayout); statusPanelLayout.setHorizontalGroup( statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 410, Short.MAX_VALUE) .addGroup(statusPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(statusMessageLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 240, Short.MAX_VALUE) .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(statusAnimationLabel) .addContainerGap()) ); statusPanelLayout.setVerticalGroup( statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(statusPanelLayout.createSequentialGroup() .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(statusMessageLabel) .addComponent(statusAnimationLabel) .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(3, 3, 3)) ); setComponent(mainPanel); setMenuBar(menuBar); setStatusBar(statusPanel); }// </editor-fold>//GEN-END:initComponents private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed // TODO add your handling code here: DataBaseSyncDesktopApplication app = DataBaseSyncDesktopApplication.getApplication(); if (app.getDataBaseSyncTimer().isEmpty()) { Object[] options = {"OK", "CANCEL"}; int seleted = JOptionPane.showOptionDialog(null, "当前还没有添加任务,需要添加任务吗", "Warning", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); System.out.println("seleted=" + seleted); if (seleted == 0) { AddContextFile(); } } else { app.startTimerAll(); } }//GEN-LAST:event_jMenuItem2ActionPerformed @Action public void AddContextFile() { if (chooseFile == null) { JFrame mainFrame = DataBaseSyncDesktopApplication.getAppFrame().getFrame(); chooseFile = new ChoosePropertiesAboutBox(mainFrame); chooseFile.setLocationRelativeTo(mainFrame); } DataBaseSyncDesktopApplication.getApplication().show(chooseFile); if (chooseFile.getStringbuffer() != null) { jTextArea1.append(chooseFile.getStringbuffer().toString()); } } protected void init() { SystemTray tray = SystemTray.getDefaultSystemTray(); final TrayIcon trayIcon = new TrayIcon(getTrayIcon(), "Tray Demo", getPopupMenu()); trayIcon.setIconAutoSize(true); trayIcon.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DataBaseSyncDesktopApplication.getApplication().show(DataBaseSyncDesktopApplication.getAppFrame()); } }); tray.addTrayIcon(trayIcon); getBtnAlert().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { trayIcon.displayMessage("Alert", "This is an Alert Message", TrayIcon.INFO_MESSAGE_TYPE); } }); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { frame.setVisible(false); } }); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.out.println("windowClosing"); frame.setVisible(false); } }); } public void windowClosed(WindowEvent e) { frame.setVisible(false); } public void windowClosing(WindowEvent e) { frame.setVisible(false); } private ImageIcon getTrayIcon() { return new ImageIcon(DataBaseSyncDesktopView.class.getResource("resources/icon.png")); } private JPopupMenu getPopupMenu() { JPopupMenu pop = new JPopupMenu(); JMenuItem option1 = new JMenuItem("Option 1"); option1.setMnemonic('o'); option1.setIcon(new ImageIcon(DataBaseSyncDesktopView.class.getResource("resources/menu_o.png"))); pop.add(option1); JMenu menu = new JMenu("Choices"); menu.setIcon(new ImageIcon(DataBaseSyncDesktopView.class.getResource("resources/menu_q.png"))); JRadioButtonMenuItem radio1 = new JRadioButtonMenuItem("Choice 1"); JRadioButtonMenuItem radio2 = new JRadioButtonMenuItem("Choice 2"); JRadioButtonMenuItem radio3 = new JRadioButtonMenuItem("Choice 3"); menu.add(radio1); menu.add(radio2); menu.add(radio3); pop.add(menu); JMenuItem exit = new JMenuItem("Exit"); exit.setIcon(new ImageIcon(DataBaseSyncDesktopView.class.getResource("resources/menu_x.png"))); exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); pop.add(new JSeparator()); pop.add(exit); return pop; } /** * This method initializes btnAlert * * @return javax.swing.JButton */ private javax.swing.JButton getBtnAlert() { if (btnAlert == null) { btnAlert = new javax.swing.JButton(); btnAlert.setText("Alert"); } return btnAlert; } private javax.swing.JFrame frame; private javax.swing.JButton btnAlert; // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JMenuItem jMenuItem1; private javax.swing.JMenuItem jMenuItem2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextArea jTextArea1; private javax.swing.JPanel mainPanel; private javax.swing.JMenuBar menuBar; private javax.swing.JProgressBar progressBar; private javax.swing.JLabel statusAnimationLabel; private javax.swing.JLabel statusMessageLabel; private javax.swing.JPanel statusPanel; // End of variables declaration//GEN-END:variables private final Timer messageTimer; private final Timer busyIconTimer; private final Icon idleIcon; private final Icon[] busyIcons = new Icon[15]; private int busyIconIndex = 0; private JDialog aboutBox; private ChoosePropertiesAboutBox chooseFile;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?