List of usage examples for java.awt.event KeyAdapter KeyAdapter
KeyAdapter
From source file:ru.goodfil.catalog.ui.forms.OePanel.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner Evaluation license - ????? ??????? panel1 = new JPanel(); panel2 = new JPanel(); btnCreateBrand = new JButton(); btnEditBrand = new JButton(); btnRemoveBrand = new JButton(); btnUnionBrand = new JButton(); hSpacer1 = new JPanel(null); tbSearchBrand = new JTextField(); btnSearchBrand = new JButton(); scrollPane1 = new JScrollPane(); lstBrands = new JList(); lLstBrandsStatus = new JLabel(); panel3 = new JPanel(); panel4 = new JPanel(); btnCreateOe = new JButton(); btnEditOe = new JButton(); btnRemoveOe = new JButton(); btnUnionOe = new JButton(); hSpacer2 = new JPanel(null); tbSearchOe = new JTextField(); btnSearchOe = new JButton(); scrollPane2 = new JScrollPane(); lstOes = new JList(); lLstOesStatus = new JLabel(); popupMenu1 = new JPopupMenu(); menuItem1 = new JMenuItem(); menuItem2 = new JMenuItem(); menuItem3 = new JMenuItem(); menuItem4 = new JMenuItem(); popupMenu2 = new JPopupMenu(); menu1 = new JMenu(); menuItem5 = new JMenuItem(); menuItem6 = new JMenuItem(); CellConstraints cc = new CellConstraints(); //======== this ======== // JFormDesigner evaluation mark setBorder(/*from www .j a v a 2 s .co m*/ new javax.swing.border.CompoundBorder( new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0), "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.red), getBorder())); addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent e) { if ("border".equals(e.getPropertyName())) throw new RuntimeException(); } }); setLayout(new FormLayout("default:grow, $lcgap, default:grow", "fill:default:grow")); //======== panel1 ======== { panel1.setBorder(new TitledBorder( "\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u0438")); panel1.setLayout( new FormLayout("default:grow", "fill:21dlu, $lgap, fill:default:grow, $lgap, default")); //======== panel2 ======== { panel2.setLayout(new FormLayout("4*(21dlu), default:grow, 100dlu, 21dlu", "fill:default:grow")); //---- btnCreateBrand ---- btnCreateBrand .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/add_24.png"))); btnCreateBrand.setToolTipText( "\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440"); btnCreateBrand.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnCreateBrandActionPerformed(e); } }); panel2.add(btnCreateBrand, cc.xy(1, 1)); //---- btnEditBrand ---- btnEditBrand .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/edit_24.png"))); btnEditBrand.setToolTipText( "\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440"); btnEditBrand.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnEditBrandActionPerformed(e); } }); panel2.add(btnEditBrand, cc.xy(2, 1)); //---- btnRemoveBrand ---- btnRemoveBrand.setIcon( new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/delete_24.png"))); btnRemoveBrand.setToolTipText( "\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440"); btnRemoveBrand.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnRemoveBrandActionPerformed(e); } }); panel2.add(btnRemoveBrand, cc.xy(3, 1)); //---- btnUnionBrand ---- btnUnionBrand.setIcon( new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/recycle_24.png"))); btnUnionBrand.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnUnionBrandActionPerformed(e); } }); panel2.add(btnUnionBrand, cc.xy(4, 1)); panel2.add(hSpacer1, cc.xy(5, 1)); //---- tbSearchBrand ---- tbSearchBrand.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { tbSearchBrandKeyTyped(e); } @Override public void keyReleased(KeyEvent e) { tbSearchBrandKeyTyped(e); } @Override public void keyTyped(KeyEvent e) { tbSearchBrandKeyTyped(e); } }); tbSearchBrand.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { tbSearchBrandFocusGained(e); } @Override public void focusLost(FocusEvent e) { tbSearchBrandFocusGained(e); } }); panel2.add(tbSearchBrand, cc.xy(6, 1)); //---- btnSearchBrand ---- btnSearchBrand.setIcon( new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/find_next_24.png"))); btnSearchBrand.setToolTipText( "\u041f\u043e\u0438\u0441\u043a \u043c\u043e\u0442\u043e\u0440\u043e\u0432 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f \u0438\u0437 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0441\u0435\u0440\u0438\u0438"); btnSearchBrand.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnSearchBrandActionPerformed(e); } }); panel2.add(btnSearchBrand, cc.xy(7, 1)); } panel1.add(panel2, cc.xy(1, 1)); //======== scrollPane1 ======== { //---- lstBrands ---- lstBrands.setToolTipText( "\u0415\u0441\u043b\u0438 \u0448\u0440\u0438\u0444\u0442 \u0411\u0440\u0435\u043d\u0434\u0430 \u0432\u044b\u0434\u0435\u043b\u0435\u043d \u043f\u043e\u043b\u0443\u0436\u0438\u0440\u043d\u044b\u043c, \u0442\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u0435\u043d \u0432 \u043e\u0442\u0447\u0443\u0436\u0434\u0430\u0435\u043c\u043e\u0439 \u043a\u043e\u043f\u0438\u0438, \u0434\u043b\u044f \u0432\u044b\u0433\u0440\u0443\u0437\u043e\u043a. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043d\u0435 \u0432\u044b\u0434\u0435\u043b\u0435\u043d, \u0442\u043e \u0432\u0438\u0434\u0435\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442."); lstBrands.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { lstBrandsValueChanged(e); } }); lstBrands.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { lstBrandsKeyPressed(e); } }); lstBrands.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { lstBrandsMouseClicked(e); } }); scrollPane1.setViewportView(lstBrands); } panel1.add(scrollPane1, cc.xy(1, 3)); //---- lLstBrandsStatus ---- lLstBrandsStatus.setText("text"); panel1.add(lLstBrandsStatus, cc.xy(1, 5)); } add(panel1, cc.xy(1, 1)); //======== panel3 ======== { panel3.setBorder(new TitledBorder("\u041d\u043e\u043c\u0435\u0440\u0430 \u041e\u0415")); panel3.setLayout(new FormLayout("default:grow", "default, $lgap, fill:default:grow, $lgap, default")); //======== panel4 ======== { panel4.setLayout(new FormLayout("4*(21dlu), default:grow, 100dlu, 21dlu", "fill:21dlu")); //---- btnCreateOe ---- btnCreateOe .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/add_24.png"))); btnCreateOe.setToolTipText( "\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440"); btnCreateOe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnCreateOeActionPerformed(e); } }); panel4.add(btnCreateOe, cc.xy(1, 1)); //---- btnEditOe ---- btnEditOe .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/edit_24.png"))); btnEditOe.setToolTipText( "\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440"); btnEditOe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnEditOeActionPerformed(e); } }); panel4.add(btnEditOe, cc.xy(2, 1)); //---- btnRemoveOe ---- btnRemoveOe.setIcon( new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/delete_24.png"))); btnRemoveOe.setToolTipText( "\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440"); btnRemoveOe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnRemoveOeActionPerformed(e); } }); panel4.add(btnRemoveOe, cc.xy(3, 1)); //---- btnUnionOe ---- btnUnionOe.setIcon( new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/recycle_24.png"))); btnUnionOe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnUnionOeActionPerformed(e); } }); panel4.add(btnUnionOe, cc.xy(4, 1)); panel4.add(hSpacer2, cc.xy(5, 1)); //---- tbSearchOe ---- tbSearchOe.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { tbSearchOeKeyPressed(e); } @Override public void keyReleased(KeyEvent e) { tbSearchOeKeyPressed(e); } }); tbSearchOe.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { tbSearchOeFocusGained(e); } @Override public void focusLost(FocusEvent e) { tbSearchOeFocusGained(e); } }); panel4.add(tbSearchOe, cc.xy(6, 1)); //---- btnSearchOe ---- btnSearchOe.setIcon( new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/find_next_24.png"))); btnSearchOe.setToolTipText( "\u041f\u043e\u0438\u0441\u043a \u043c\u043e\u0442\u043e\u0440\u043e\u0432 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f \u0438\u0437 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0441\u0435\u0440\u0438\u0438"); btnSearchOe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnSearchOeActionPerformed(e); } }); panel4.add(btnSearchOe, cc.xy(7, 1)); } panel3.add(panel4, cc.xy(1, 1)); //======== scrollPane2 ======== { //---- lstOes ---- lstOes.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { lstOesKeyPressed(e); } }); lstOes.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { lstOesValueChanged(e); } }); lstOes.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { lstOesMouseClicked(e); } }); scrollPane2.setViewportView(lstOes); } panel3.add(scrollPane2, cc.xy(1, 3)); //---- lLstOesStatus ---- lLstOesStatus.setText("text"); panel3.add(lLstOesStatus, cc.xy(1, 5)); } add(panel3, cc.xy(3, 1)); //======== popupMenu1 ======== { popupMenu1.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuCanceled(PopupMenuEvent e) { } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { popupMenu1PopupMenuWillBecomeVisible(e); } }); //---- menuItem1 ---- menuItem1.setText( "\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0431\u0443\u0444\u0435\u0440"); menuItem1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { copyToClipboard(e); } }); popupMenu1.add(menuItem1); //---- menuItem2 ---- menuItem2.setText( "\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430"); menuItem2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { pasteFromClipboard(e); } }); popupMenu1.add(menuItem2); popupMenu1.addSeparator(); //---- menuItem3 ---- menuItem3.setText( "\u041f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u0431\u0443\u0444\u0435\u0440 (\u0421 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c)"); menuItem3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cutToClipboard(e); } }); popupMenu1.add(menuItem3); //---- menuItem4 ---- menuItem4.setText( "\u0412\u044b\u043d\u0435\u0441\u0442\u0438 \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430"); menuItem4.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { pasteFromClipboard(e); } }); popupMenu1.add(menuItem4); } //======== popupMenu2 ======== { //======== menu1 ======== { menu1.setText( "\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u043e\u0442\u0447\u0443\u0436\u0434\u0430\u0435\u043c\u043e\u0439 \u043a\u043e\u043f\u0438\u0438"); //---- menuItem5 ---- menuItem5.setText("\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c"); menuItem5.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { menuItemReprezentInStandalone(e); } }); menu1.add(menuItem5); //---- menuItem6 ---- menuItem6.setText("\u041d\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c"); menuItem6.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { menuItemDontReprezentInStandalone(e); } }); menu1.add(menuItem6); } popupMenu2.add(menu1); } // JFormDesigner - End of component initialization //GEN-END:initComponents }
From source file:net.rptools.maptool.launcher.MapToolLauncher.java
private JPanel buildAdvancedPanel() { final JPanel p = new JPanel(); p.setLayout(new BorderLayout()); p.setBorder(new LineBorder(Color.BLACK)); final JPanel controlPanel = new JPanel(); controlPanel.setLayout(new BorderLayout()); final JPanel argPanel = new JPanel(); argPanel.setLayout(new BorderLayout()); jtfArgs.setInfo(CopiedFromOtherJars.getText("msg.info.javaArgumentsHere")); //$NON-NLS-1$ jtfArgs.setText(extraArgs);/*ww w . j a v a2 s . c om*/ jtfArgs.setToolTipText(CopiedFromOtherJars.getText("msg.tooltip.javaArgumentsHere")); //$NON-NLS-1$ jtfArgs.setCaretPosition(0); jtfArgs.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { jbLaunch.requestFocusInWindow(); } } }); jtfArgs.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent arg0) { jtfArgs.selectAll(); } @Override public void focusLost(FocusEvent arg0) { jtfArgs.setCaretPosition(0); if (!jtfArgs.getText().trim().equals(extraArgs)) { extraArgs = jtfArgs.getText(); jcbEnableAssertions.setSelected(extraArgs.contains(ASSERTIONS_OPTION)); if (extraArgs.contains(DATADIR_OPTION)) { extraArgs = cleanExtraArgs(extraArgs); } updateCommand(); } } }); argPanel.add(jtfArgs, BorderLayout.CENTER); controlPanel.add(argPanel, BorderLayout.NORTH); final JPanel holdPanel = new JPanel(); holdPanel.setLayout(new GridLayout(0, 1)); jcbRelativePath.setText(CopiedFromOtherJars.getText("msg.info.useRelativePathnames")); //$NON-NLS-1$ jcbRelativePath.setToolTipText(CopiedFromOtherJars.getText("msg.tooltip.useRelativePathnames")); //$NON-NLS-1$ jcbRelativePath.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { updateCommand(); } }); // jcbRelativePath.setSelected(false); // since initComponents() is called after reading the config, don't do this here jcbConsole.setText(CopiedFromOtherJars.getText("msg.info.launchWithConsole")); //$NON-NLS-1$ jcbConsole.setToolTipText(CopiedFromOtherJars.getText("msg.tooltip.launchWithConsole")); //$NON-NLS-1$ jcbConsole.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { startConsole = jcbConsole.isSelected(); updateCommand(); } }); jcbConsole.setSelected(startConsole); jbPath.setText(jbPathText); jbPath.setToolTipText(CopiedFromOtherJars.getText("msg.tooltip.dirForAltJava")); //$NON-NLS-1$ jbPath.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (jbPath.getText().equalsIgnoreCase(CopiedFromOtherJars.getText("msg.info.setJavaVersion"))) { //$NON-NLS-1$ final JFileChooser jfc = new JFileChooser(); if (!javaDir.isEmpty()) { jfc.setCurrentDirectory(new File(javaDir)); } else { jfc.setCurrentDirectory(new File(".")); //$NON-NLS-1$ } jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); final int returnVal = jfc.showOpenDialog(jbPath); if (returnVal == JFileChooser.APPROVE_OPTION) { final File f = jfc.getSelectedFile(); final String test = f.getPath() + File.separator; // Lee: naive search for java command. will improve in the future final List<String> fileList = Arrays.asList(f.list()); boolean javaFound = false; for (final String fileName : fileList) { final File check = new File(f, fileName); final String lc = check.getName().toLowerCase(); if (lc.equals("java") || (IS_WINDOWS && lc.startsWith("java."))) { //$NON-NLS-1$ //$NON-NLS-2$ javaFound = true; break; } } if (javaFound) { jbPath.setText(CopiedFromOtherJars.getText("msg.info.resetToDefaultJava")); //$NON-NLS-1$ javaDir = test; updateCommand(); } else { logMsg(Level.SEVERE, "Java executable not found in {0}", //$NON-NLS-1$ "msg.error.javaCommandNotFound", f); //$NON-NLS-2$ } } } else { jbPath.setText(CopiedFromOtherJars.getText("msg.info.setJavaVersion")); //$NON-NLS-1$ javaDir = EMPTY; } } }); holdPanel.add(jcbRelativePath); holdPanel.add(jcbConsole); holdPanel.add(jbPath); controlPanel.add(holdPanel, BorderLayout.SOUTH); final JPanel logPanel = new JPanel(); logPanel.setLayout(new GridLayout(0, 1)); logPanel.setBorder( new TitledBorder(new LineBorder(Color.BLACK), CopiedFromOtherJars.getText("msg.logPanel.border"))); //$NON-NLS-1$ for (final LoggingConfig config : logConfigs) { config.chkbox.setText(config.getProperty("desc")); //$NON-NLS-1$ config.chkbox.setToolTipText(config.getProperty("ttip")); //$NON-NLS-1$ logPanel.add(config.chkbox); } p.add(logPanel, BorderLayout.CENTER); p.add(controlPanel, BorderLayout.SOUTH); return p; }
From source file:org.mbs3.juniuploader.gui.pnlSettings.java
private void initGUI() { try {/*from w w w .j a va 2s. c o m*/ GridBagLayout thisLayout = new GridBagLayout(); thisLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; thisLayout.rowHeights = new int[] { 11, 20, 18, 22, 22, 23, 23, 20, 18, 23, 22, 24, 6, 26, 4, 30, 8 }; thisLayout.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 0.0, 0.1, 0.0 }; thisLayout.columnWidths = new int[] { 10, 106, 90, 20, 20, 7, 100, 20, 7 }; this.setLayout(thisLayout); this.setPreferredSize(new java.awt.Dimension(659, 349)); { { grpMain = new ButtonGroup(); } { grpGUI = new ButtonGroup(); } { grpObjects = new ButtonGroup(); } { grpHTTP = new ButtonGroup(); } { } { } lblGUI = new JLabel(); this.add(lblGUI, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblGUI.setText("Graphical Interface"); } { lblMain = new JLabel(); this.add(lblMain, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblMain.setText("Main Program"); } { lblObj = new JLabel(); this.add(lblObj, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblObj.setText("Object Messages"); } { lblLObj = new JLabel(); this.add(lblLObj, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblLObj.setText("HTTP Messages"); } { lblFatal = new JLabel(); this.add(lblFatal, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblFatal.setText("Fatal Messages"); } { lblError = new JLabel(); this.add(lblError, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblError.setText("Errors"); } { lblWarn = new JLabel(); this.add(lblWarn, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblWarn.setText("Warnings"); } { lblInfo = new JLabel(); this.add(lblInfo, new GridBagConstraints(5, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblInfo.setText("Info Messages"); } { lblDebug = new JLabel(); this.add(lblDebug, new GridBagConstraints(6, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblDebug.setText("Debug Messages"); } { lblTrace = new JLabel(); this.add(lblTrace, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblTrace.setText("Trace Execution"); } { btnMainFatal = new JRadioButton(); this.add(btnMainFatal, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } grpMain.add(btnMainFatal); btnMainFatal.setActionCommand("fatal"); btnMainFatal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); { btnMainError = new JRadioButton(); this.add(btnMainError, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpMain.add(btnMainError); btnMainError.setActionCommand("error"); btnMainError.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnMainWarn = new JRadioButton(); this.add(btnMainWarn, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpMain.add(btnMainWarn); btnMainWarn.setActionCommand("warn"); btnMainWarn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnMainInfo = new JRadioButton(); this.add(btnMainInfo, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpMain.add(btnMainInfo); btnMainInfo.setActionCommand("info"); btnMainInfo.setSelected(true); btnMainInfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnMainDebug = new JRadioButton(); this.add(btnMainDebug, new GridBagConstraints(6, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpMain.add(btnMainDebug); btnMainDebug.setActionCommand("debug"); btnMainDebug.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnMainTrace = new JRadioButton(); this.add(btnMainTrace, new GridBagConstraints(7, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpMain.add(btnMainTrace); btnMainTrace.setActionCommand("trace"); btnMainTrace.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnGUIFatal = new JRadioButton(); this.add(btnGUIFatal, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpGUI.add(btnGUIFatal); btnGUIFatal.setActionCommand("fatal"); btnGUIFatal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnGUIError = new JRadioButton(); this.add(btnGUIError, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpGUI.add(btnGUIError); btnGUIError.setActionCommand("error"); btnGUIError.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnGUIWarn = new JRadioButton(); this.add(btnGUIWarn, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpGUI.add(btnGUIWarn); btnGUIWarn.setActionCommand("warn"); btnGUIWarn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnGUIInfo = new JRadioButton(); this.add(btnGUIInfo, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpGUI.add(btnGUIInfo); btnGUIInfo.setActionCommand("info"); btnGUIInfo.setSelected(true); btnGUIInfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnGUIDebug = new JRadioButton(); this.add(btnGUIDebug, new GridBagConstraints(6, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpGUI.add(btnGUIDebug); btnGUIDebug.setActionCommand("debug"); btnGUIDebug.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnGUITrace = new JRadioButton(); this.add(btnGUITrace, new GridBagConstraints(7, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpGUI.add(btnGUITrace); btnGUITrace.setActionCommand("trace"); btnGUITrace.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnObjFatal = new JRadioButton(); this.add(btnObjFatal, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpObjects.add(btnObjFatal); btnObjFatal.setActionCommand("fatal"); btnObjFatal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnObjError = new JRadioButton(); this.add(btnObjError, new GridBagConstraints(3, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpObjects.add(btnObjError); btnObjError.setActionCommand("error"); btnObjError.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnObjWarn = new JRadioButton(); this.add(btnObjWarn, new GridBagConstraints(4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpObjects.add(btnObjWarn); btnObjWarn.setActionCommand("warn"); btnObjWarn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnObjInfo = new JRadioButton(); this.add(btnObjInfo, new GridBagConstraints(5, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpObjects.add(btnObjInfo); btnObjInfo.setActionCommand("info"); btnObjInfo.setSelected(true); btnObjInfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnObjDebug = new JRadioButton(); this.add(btnObjDebug, new GridBagConstraints(6, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpObjects.add(btnObjDebug); btnObjDebug.setActionCommand("debug"); btnObjDebug.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnObjTrace = new JRadioButton(); this.add(btnObjTrace, new GridBagConstraints(7, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpObjects.add(btnObjTrace); btnObjTrace.setActionCommand("trace"); btnObjTrace.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnHTTPFatal = new JRadioButton(); this.add(btnHTTPFatal, new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpHTTP.add(btnHTTPFatal); btnHTTPFatal.setActionCommand("fatal"); btnHTTPFatal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnHTTPError = new JRadioButton(); this.add(btnHTTPError, new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpHTTP.add(btnHTTPError); btnHTTPError.setActionCommand("error"); btnHTTPError.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnHTTPWarn = new JRadioButton(); this.add(btnHTTPWarn, new GridBagConstraints(4, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpHTTP.add(btnHTTPWarn); btnHTTPWarn.setActionCommand("warn"); btnHTTPWarn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnHTTPInfo = new JRadioButton(); this.add(btnHTTPInfo, new GridBagConstraints(5, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpHTTP.add(btnHTTPInfo); btnHTTPInfo.setActionCommand("info"); btnHTTPInfo.setSelected(true); btnHTTPInfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnHTTPDebug = new JRadioButton(); this.add(btnHTTPDebug, new GridBagConstraints(6, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpHTTP.add(btnHTTPDebug); btnHTTPDebug.setActionCommand("debug"); btnHTTPDebug.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnHTTPTrace = new JRadioButton(); this.add(btnHTTPTrace, new GridBagConstraints(7, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpHTTP.add(btnHTTPTrace); btnHTTPTrace.setActionCommand("trace"); btnHTTPTrace.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { lblLogLevel = new JLabel(); this.add(lblLogLevel, new GridBagConstraints(1, 1, 7, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblLogLevel.setText("Set the level of logging for different parts of this application:"); } { lblDeLF = new JLabel(); this.add(lblDeLF, new GridBagConstraints(1, 8, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblDeLF.setText("Set the look and feel for the GUI of this application:"); } { LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels(); LookAndFeel lf = UIManager.getLookAndFeel(); DefaultComboBoxModel cmbLFModel = new DefaultComboBoxModel(); for (int i = 0; i < lfs.length; i++) { String n = lfs[i].getName(); cmbLFModel.addElement(n); if (lf.getName().equals(lfs[i].getName())) cmbLFModel.setSelectedItem(n); } cmbLF = new JComboBox(); this.add(cmbLF, new GridBagConstraints(1, 9, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbLF.setModel(cmbLFModel); cmbLF.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent evt) { cmbLFItemStateChanged(evt); } }); } { tfUserAgent = new JTextField(Util.getUserAgent()); this.add(tfUserAgent, new GridBagConstraints(1, 11, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); tfUserAgent.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent evt) { tfUserAgentKeyReleased(evt); } }); } { lblUserAgent = new JLabel(); this.add(lblUserAgent, new GridBagConstraints(1, 10, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblUserAgent.setText("User Agent"); } { btnExport = new JToggleButton(); this.add(btnExport, new GridBagConstraints(1, 15, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); btnExport.setText("Export All Settings and Data to File"); btnExport.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { btnExportActionPerformed(evt); } }); } { txtWarn = new JTextPane(); this.add(txtWarn, new GridBagConstraints(4, 15, 4, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtWarn.setText( "Note: This includes rules, form variables, sites, and ANYTHING else this program can remember from run to run."); txtWarn.setEditable(false); txtWarn.setBackground(new java.awt.Color(255, 255, 255)); txtWarn.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 0))); } } catch (Exception e) { e.printStackTrace(); } }
From source file:me.paddingdun.gen.code.gui.view.dbtable.TableView.java
private void afterShow(java.awt.event.ComponentEvent evt) {// GEN-FIRST:event_afterShow // table.addPropertyChangeListener("tableCellEditor", new // PropertyChangeListener() { ///*from ww w. jav a 2 s . co m*/ // @Override // public void propertyChange(PropertyChangeEvent evt) { // System.out.println("1[" +evt.getPropertyName()); // System.out.println("2[" +evt.getSource()); // System.out.println("3[" +(evt.getOldValue())); // System.out.println("4[" +evt.getNewValue()); // System.out.println("5[" +table.getCellEditor()); // } // }); // table.getCellEditor().addCellEditorListener(new CellEditorListener() // { // // @Override // public void editingStopped(ChangeEvent e) { // System.out.println("stop"); // } // // @Override // public void editingCanceled(ChangeEvent e) { // System.out.println("cancel"); // } // }); tableColumnTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { changeTableRow(); } }); // 38 up; // 40 down; // 37 left; // 39 right; // 10 enter; tableColumnTable.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == 10 || keyCode == 38 || keyCode == 40) changeTableRow(); } }); listColumnTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { changeListTableRow(); } }); // 38 up; // 40 down; // 37 left; // 39 right; // 10 enter; listColumnTable.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == 10 || keyCode == 38 || keyCode == 40) changeListTableRow(); } }); p.setDividerLocation(0.5); EventQueue.invokeLater(new Runnable() { public void run() { pt.setDividerLocation(0.5); EventQueue.invokeLater(new Runnable() { public void run() { pb.setDividerLocation(0.5); } }); } }); }
From source file:edu.ku.brc.af.ui.db.DatabaseLoginPanel.java
/** * Creates the UI for the login and hooks up any listeners. * @param isDlg whether the parent is a dialog (false mean JFrame) * @param iconName the icon that will be shown in the panel * @param engageUPPrefs whether it should load and save the username password into the prefs * @param helpContext the help context to use. *///w w w . j a v a 2 s. com protected void createUI(final boolean isDlg, final String iconName, final String helpContext) { final boolean isNotEmbedded = !DBConnection.getInstance().isEmbedded() && !UIRegistry.isMobile(); final AppPreferences localPrefs = AppPreferences.getLocalPrefs(); //Font cachedFont = UIManager.getFont("JLabel.font"); SkinItem skinItem = SkinsMgr.getSkinItem("LoginPanel"); if (skinItem != null) { skinItem.pushFG("Label.foreground"); } if (isNotEmbedded) { SpinnerModel portModel = new SpinnerNumberModel(3306, //initial value 0, //min Integer.MAX_VALUE, //max 1); //step portSpinner = new JSpinner(portModel); JSpinner.NumberEditor editor = new JSpinner.NumberEditor(portSpinner, "#"); portSpinner.setEditor(editor); portSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { DatabaseDriverInfo drvInfo = dbDrivers.get(dbDriverCBX.getSelectedIndex()); if (drvInfo != null && isNotEmbedded && portSpinner != null) { drvInfo.setPort((Integer) portSpinner.getValue()); } } }); setControlSize(portSpinner); } // First create the controls and hook up listeners dbPickList = new PropertiesPickListAdapter("login.databases"); //$NON-NLS-1$ svPickList = new PropertiesPickListAdapter("login.servers"); //$NON-NLS-1$ username = createTextField(15); password = createPasswordField(15); FocusAdapter focusAdp = new FocusAdapter() { @Override public void focusGained(FocusEvent e) { super.focusGained(e); JTextField tf = (JTextField) e.getSource(); tf.selectAll(); } }; username.addFocusListener(focusAdp); password.addFocusListener(focusAdp); databases = new ValComboBox(dbPickList); if (databases.getComboBox() instanceof Java2sAutoComboBox) { ((Java2sAutoComboBox) databases.getComboBox()).setCaseSensitive(true); } servers = new ValComboBox(svPickList); dbPickList.setComboBox(databases); svPickList.setComboBox(servers); setControlSize(password); setControlSize(databases); setControlSize(servers); if (masterUsrPwdProvider != null) { editKeyInfoBtn = UIHelper.createI18NButton("CONFIG_MSTR_KEY"); editKeyInfoBtn.setIcon(IconManager.getIcon("Key", IconManager.IconSize.Std20)); editKeyInfoBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (masterUsrPwdProvider != null && databases != null) { String itemName = null; if (databases.getComboBox().getSelectedItem() instanceof String) { itemName = (String) databases.getComboBox().getSelectedItem(); } else { PickListItemIFace pli = (PickListItemIFace) databases.getComboBox().getSelectedItem(); if (pli != null && pli.getValue() != null) { itemName = pli.getValue(); } } if (itemName != null) { masterUsrPwdProvider.editMasterInfo(username.getText(), itemName, false); } } } }); } rememberUsernameCBX = createCheckBox(getResourceString("rememberuser")); //$NON-NLS-1$ rememberUsernameCBX.setEnabled(engageUPPrefs); statusBar = new JStatusBar(); statusBar.setErrorIcon(IconManager.getIcon("Error", IconManager.IconSize.Std16)); //$NON-NLS-1$ cancelBtn = createButton(getResourceString("CANCEL")); //$NON-NLS-1$ loginBtn = createButton(getResourceString("Login")); //$NON-NLS-1$ helpBtn = createButton(getResourceString("HELP")); //$NON-NLS-1$ forwardImgIcon = IconManager.getIcon("Forward"); //$NON-NLS-1$ downImgIcon = IconManager.getIcon("Down"); //$NON-NLS-1$ moreBtn = new JCheckBox(getResourceString("LOGIN_DLG_MORE"), forwardImgIcon); // XXX I18N //$NON-NLS-1$ setControlSize(moreBtn); // Extra dbDrivers = DatabaseDriverInfo.getDriversList(); dbDriverCBX = createComboBox(dbDrivers); dbDriverCBX.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateUIControls(); DatabaseDriverInfo drvInfo = dbDrivers.get(dbDriverCBX.getSelectedIndex()); if (drvInfo != null && isNotEmbedded && portSpinner != null) { Integer defPort = drvInfo.getPortAsInt(); int portFromPref = localPrefs.getInt(LOGIN_PORT, defPort); portSpinner.setValue(portFromPref); drvInfo.setPort(portFromPref); } } }); if (dbDrivers.size() > 0) { if (dbDrivers.size() == 1) { dbDriverCBX.setSelectedIndex(0); dbDriverCBX.setEnabled(false); } else { String selectedStr = localPrefs.get("login.dbdriver_selected", "MySQL"); //$NON-NLS-1$ //$NON-NLS-2$ int inx = Collections.binarySearch(dbDrivers, new DatabaseDriverInfo(selectedStr, null, null, false, null)); dbDriverCBX.setSelectedIndex(inx > -1 ? inx : -1); } } else { JOptionPane.showConfirmDialog(null, getResourceString("NO_DBDRIVERS"), //$NON-NLS-1$ getResourceString("NO_DBDRIVERS_TITLE"), JOptionPane.CLOSED_OPTION); //$NON-NLS-1$ System.exit(1); } addFocusListenerForTextComp(username); addFocusListenerForTextComp(password); addKeyListenerFor(username, !isDlg); addKeyListenerFor(password, !isDlg); addKeyListenerFor(databases.getTextField(), !isDlg); addKeyListenerFor(servers.getTextField(), !isDlg); if (!isDlg) { addKeyListenerFor(loginBtn, true); } rememberUsernameCBX.setSelected(engageUPPrefs ? localPrefs.getBoolean("login.rememberuser", false) : false); //$NON-NLS-1$ cancelBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (dbListener != null) { dbListener.cancelled(); } } }); loginBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doLogin(); } }); HelpMgr.registerComponent(helpBtn, helpContext); //$NON-NLS-1$ moreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (extraPanel.isVisible()) { if (dbDriverCBX.getSelectedIndex() != -1) { extraPanel.setVisible(false); moreBtn.setIcon(forwardImgIcon); } } else { extraPanel.setVisible(true); moreBtn.setIcon(downImgIcon); } if (window != null) { window.pack(); } } }); // Ask the PropertiesPickListAdapter to set the index from the prefs dbPickList.setSelectedIndex(); svPickList.setSelectedIndex(); servers.getTextField().addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { updateUIControls(); } }); databases.getTextField().addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { updateUIControls(); } }); databases.getTextField().addFocusListener(new FocusAdapter() { String server = null; private String getServerStr() { String serverStr = null; Object serverObj = servers.getValue(); if (serverObj != null) { serverStr = serverObj.toString(); } return serverStr; } @Override public void focusGained(FocusEvent e) { server = getServerStr(); } @Override public void focusLost(FocusEvent e) { if (server != null) { String newVal = getServerStr(); if (newVal != null && !newVal.equals(server)) { setUsrPwdControlsFromPrefs(); } } } }); setUsrPwdControlsFromPrefs(); // Layout the form PanelBuilder formBuilder = new PanelBuilder(new FormLayout("p,3dlu,p:g", "p,2dlu,p,2dlu,p,2dlu,p,2dlu,p")); //$NON-NLS-1$ //$NON-NLS-2$ CellConstraints cc = new CellConstraints(); formBuilder.addSeparator(getResourceString("LOGINLABEL"), cc.xywh(1, 1, 3, 1)); //$NON-NLS-1$ addLine("username", username, formBuilder, cc, 3); //$NON-NLS-1$ addLine("password", password, formBuilder, cc, 5); //$NON-NLS-1$ formBuilder.add(moreBtn, cc.xy(3, 7)); PanelBuilder extraPanelBlder = new PanelBuilder(new FormLayout("p,3dlu,p:g", //$NON-NLS-1$ UIHelper.createDuplicateJGoodiesDef("p", "2dlu", isNotEmbedded ? 9 : 11))); //$NON-NLS-1$ //$NON-NLS-2$ extraPanel = extraPanelBlder.getPanel(); extraPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 4, 2)); //extraPanelBlder.addSeparator("", cc.xywh(1, 1, 3, 1)); //$NON-NLS-1$ int y = 1; y = addLine(null, rememberUsernameCBX, extraPanelBlder, cc, y); y = addLine("databases", databases, extraPanelBlder, cc, y); //$NON-NLS-1$ y = addLine("servers", servers, extraPanelBlder, cc, y); //$NON-NLS-1$ y = addLine("driver", dbDriverCBX, extraPanelBlder, cc, y); //$NON-NLS-1$ if (isNotEmbedded) { y = addLine("port", portSpinner, extraPanelBlder, cc, y); //$NON-NLS-1$ } if (editKeyInfoBtn != null) { PanelBuilder pb = new PanelBuilder(new FormLayout("p,f:p:g", "p")); pb.add(editKeyInfoBtn, cc.xy(1, 1)); y = addLine(null, pb.getPanel(), extraPanelBlder, cc, y); pb.getPanel().setOpaque(false); } extraPanel.setVisible(false); formBuilder.add(extraPanelBlder.getPanel(), cc.xywh(3, 9, 1, 1)); PanelBuilder outerPanel = new PanelBuilder(new FormLayout("p,3dlu,p:g", "t:p,2dlu,p,2dlu,p"), this); //$NON-NLS-1$ //$NON-NLS-2$ JLabel icon = StringUtils.isNotEmpty(iconName) ? new JLabel(IconManager.getIcon(iconName)) : null; if (icon != null) { icon.setBorder(BorderFactory.createEmptyBorder(10, 10, 2, 2)); } formBuilder.getPanel().setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 5)); if (icon != null) { outerPanel.add(icon, cc.xy(1, 1)); } JPanel btnPanel = ButtonBarFactory.buildOKCancelHelpBar(loginBtn, cancelBtn, helpBtn); outerPanel.add(formBuilder.getPanel(), cc.xy(3, 1)); outerPanel.add(btnPanel, cc.xywh(1, 3, 3, 1)); outerPanel.add(statusBar, cc.xywh(1, 5, 3, 1)); formBuilder.getPanel().setOpaque(false); outerPanel.getPanel().setOpaque(false); btnPanel.setOpaque(false); updateUIControls(); if (skinItem != null) { skinItem.popFG("Label.foreground"); } if (AppPreferences.getLocalPrefs().getBoolean(expandExtraPanelName, false)) { extraPanel.setVisible(true); moreBtn.setIcon(downImgIcon); } }
From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.ImportDialog.java
/** * Initializes the components composing the display. * /* ww w .j a v a2s .co m*/ * @param filters The filters to handle. * @param importerAction The cancel-all-imports action. */ private void initComponents(FileFilter[] filters, ImporterAction importerAction) { canvas = new QuotaCanvas(); sizeImportLabel = new JLabel(); diskSpacePane = new JPanel(); diskSpacePane.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); diskSpacePane.add(UIUtilities.setTextFont(TEXT_FREE_SPACE)); diskSpacePane.add(canvas); showThumbnails = new JCheckBox(TEXT_SHOW_THUMBNAILS); showThumbnails.setVisible(false); Registry registry = ImporterAgent.getRegistry(); Boolean loadThumbnails = (Boolean) registry.lookup(LOAD_THUMBNAIL); if (loadThumbnails != null) { if (loadThumbnails.booleanValue()) { showThumbnails.setVisible(true); showThumbnails.setSelected(loadThumbnails.booleanValue()); } } if (!isFastConnection()) // slow connection showThumbnails.setSelected(false); long groupId = -1; if (model.getSelectedGroup() != null) groupId = model.getSelectedGroup().getGroupId(); if (groupId < 0) groupId = ImporterAgent.getUserDetails().getGroupId(); locationDialog = new LocationDialog(owner, selectedContainer, type, objects, model, groupId, true); locationDialog.addPropertyChangeListener(this); int plugin = ImporterAgent.runAsPlugin(); if (plugin == LookupNames.IMAGE_J_IMPORT || plugin == LookupNames.IMAGE_J) { detachedDialog = new LocationDialog(owner, selectedContainer, type, objects, model, groupId, false); detachedDialog.addPropertyChangeListener(this); } tagSelectionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { Object src = e.getSource(); if (src instanceof JButton) { TagAnnotationData tag = tagsMap.get(src); if (tag != null) { tagsMap.remove(src); handleTagsSelection(tagsMap.values()); } } } }; tabbedPane = new JTabbedPane(); numberOfFolders = new NumericalTextField(); numberOfFolders.setMinimum(0); numberOfFolders.setText("0"); numberOfFolders.setColumns(3); numberOfFolders.addPropertyChangeListener(this); tagsMap = new LinkedHashMap<JButton, TagAnnotationData>(); IconManager icons = IconManager.getInstance(); refreshFilesButton = new JButton(TEXT_REFRESH_FILES); refreshFilesButton.setBackground(UIUtilities.BACKGROUND); refreshFilesButton.setToolTipText(TOOLTIP_REFRESH_FILES); refreshFilesButton.setActionCommand("" + CMD_REFRESH_FILES); refreshFilesButton.addActionListener(this); tagButton = new JButton(icons.getIcon(IconManager.PLUS_12)); UIUtilities.unifiedButtonLookAndFeel(tagButton); tagButton.addActionListener(this); tagButton.setActionCommand("" + CMD_TAG); tagButton.setToolTipText(TOOLTIP_ADD_TAGS); tagsPane = new JPanel(); tagsPane.setLayout(new BoxLayout(tagsPane, BoxLayout.Y_AXIS)); overrideName = new JCheckBox(TEXT_OVERRIDE_FILE_NAMING); overrideName.setToolTipText(UIUtilities.formatToolTipText(WARNING)); overrideName.setSelected(true); ButtonGroup group = new ButtonGroup(); fullName = new JRadioButton(TEXT_NAMING_FULL_PATH); group.add(fullName); partialName = new JRadioButton(); partialName.setText(TEXT_NAMING_PARTIAL_PATH); partialName.setSelected(true); group.add(partialName); table = new FileSelectionTable(this); table.addPropertyChangeListener(this); chooser = new GenericFileChooser(); JList list = (JList) UIUtilities.findComponent(chooser, JList.class); KeyAdapter ka = new KeyAdapter() { /** * Adds the files to the import queue. * * @see KeyListener#keyPressed(KeyEvent) */ public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { handleEnterKeyPressed(e.getSource()); } } }; if (list != null) list.addKeyListener(ka); if (list == null) { JTable t = (JTable) UIUtilities.findComponent(chooser, JTable.class); if (t != null) t.addKeyListener(ka); } try { File f = UIUtilities.getDefaultFolder(); if (f != null) chooser.setCurrentDirectory(f); } catch (Exception e) { // Ignore: could not set the default container } chooser.addPropertyChangeListener(this); chooser.setMultiSelectionEnabled(true); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); chooser.setControlButtonsAreShown(false); chooser.setApproveButtonText(TEXT_IMPORT); chooser.setApproveButtonToolTipText(TOOLTIP_IMPORT); bioFormatsFileFilters = new ArrayList<FileFilter>(); if (filters != null) { chooser.setAcceptAllFileFilterUsed(false); for (FileFilter fileFilter : filters) { if (fileFilter instanceof ComboFileFilter) { bioFormatsFileFiltersCombined = fileFilter; ComboFileFilter comboFilter = (ComboFileFilter) fileFilter; FileFilter[] extensionFilters = comboFilter.getFilters(); for (FileFilter combinedFilter : extensionFilters) { bioFormatsFileFilters.add(combinedFilter); } break; } } chooser.addChoosableFileFilter(bioFormatsFileFiltersCombined); for (FileFilter fileFilter : bioFormatsFileFilters) { chooser.addChoosableFileFilter(fileFilter); } chooser.setFileFilter(bioFormatsFileFiltersCombined); } else { chooser.setAcceptAllFileFilterUsed(true); } closeButton = new JButton(TEXT_CLOSE); closeButton.setToolTipText(TOOLTIP_CLOSE); closeButton.setActionCommand("" + CMD_CLOSE); closeButton.addActionListener(this); cancelImportButton = new JButton(importerAction); importerAction.setEnabled(false); importButton = new JButton(TEXT_IMPORT); importButton.setToolTipText(TOOLTIP_IMPORT); importButton.setActionCommand("" + CMD_IMPORT); importButton.addActionListener(this); importButton.setEnabled(false); pixelsSize = new ArrayList<NumericalTextField>(); NumericalTextField field; for (int i = 0; i < 3; i++) { field = new NumericalTextField(); field.setNumberType(Double.class); field.setColumns(2); pixelsSize.add(field); } List<Component> boxes = UIUtilities.findComponents(chooser, JComboBox.class); if (boxes != null) { JComboBox box; JComboBox filterBox = null; Iterator<Component> i = boxes.iterator(); while (i.hasNext()) { box = (JComboBox) i.next(); Object o = box.getItemAt(0); if (o instanceof FileFilter) { filterBox = box; break; } } if (filterBox != null) { filterBox.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { String value = KeyEvent.getKeyText(e.getKeyCode()); JComboBox box = (JComboBox) e.getSource(); int n = box.getItemCount(); FileFilter filter; FileFilter selectedFilter = null; String d; for (int j = 0; j < n; j++) { filter = (FileFilter) box.getItemAt(j); d = filter.getDescription(); if (d.startsWith(value)) { selectedFilter = filter; break; } } if (selectedFilter != null) box.setSelectedItem(selectedFilter); } }); } } }
From source file:org.ut.biolab.medsavant.client.view.component.SearchableTablePanel.java
/** * The given action will be executed when the selection changes AND a * scrolling key (pg-up, pg-down, arrow keys, num lock arrow keys) is not * being held down. This method should be used as a scroll-safe alternative * to registering a selection listener.//w w w .j a v a2 s . com * * This makes it safe for the user to scroll through the scroll panel * without repeating the action unnecessarily. The action executes in a new * thread. */ public void scrollSafeSelectAction(final Runnable onSelectTask) { final KeyTimer keyTimer = new KeyTimer(KEY_PRESS_TIMER_INTERVAL, new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { keydown = false; waitlong = false; //printTime("Starting Worker"); resetSelectionChangedWorker(onSelectTask); } }); keyTimer.setRepeats(false); getTable().addKeyListener(new KeyAdapter() { private long lastDelta = -1; private long lastTime = System.currentTimeMillis(); private int deltaSame = 0; private boolean first = true; @Override public void keyPressed(KeyEvent ke) { super.keyPressed(ke); if (!ArrayUtils.contains(SCROLLING_KEYS, ke.getKeyCode())) { //System.out.println("Detected key press that wasn't a scrolling key! (keycode=" + ke.getKeyCode() + ")"); return; } long currentTime = System.currentTimeMillis(); long delta = currentTime - lastTime; if (Math.abs(delta - lastDelta) < KEY_PRESS_INTERVAL_EPSILON) { deltaSame++; } else { deltaSame = 0; } if (deltaSame > KEY_PRESS_TIMER_INTERVAL_AUTOADJUST_RUNS) { //If this is the first time we've detected an interval, or if the detected interval //is getting close to the current (padded) interval, then change the current interval to //the detected one + padding. if (first || (delta - KEY_PRESS_TIMER_INTERVAL) > (KEY_PRESS_TIMER_INTERVAL_AUTOADJUST_PADDING / 2.0f)) { KEY_PRESS_TIMER_INTERVAL = (int) delta + KEY_PRESS_TIMER_INTERVAL_AUTOADJUST_PADDING; LOG.info("Detected " + deltaSame + " keypresses with delta ~" + delta + ", setting new repeat-interval to " + KEY_PRESS_TIMER_INTERVAL); first = false; } deltaSame = 0; } lastDelta = delta; lastTime = currentTime; keydown = true; stopSelectionChangedWorker(); if (keyTimer.isRunning()) { keyTimer.stop("keyPressed stop"); if (waitlong) { waitlong = false; keyTimer.setInitialDelay(KEY_PRESS_TIMER_INTERVAL_LONG); } else { keyTimer.setInitialDelay(KEY_PRESS_TIMER_INTERVAL); } keyTimer.restart("keyPressed restart"); } else { waitlong = false; keyTimer.setInitialDelay(KEY_PRESS_TIMER_INTERVAL_LONG); keyTimer.start("keyTimer start"); } } //In Linux, holding a keydown fires pairs of keyPressed and keyReleased events //continually, so we cannot rely on 'keyReleased'. /*@Override public void keyReleased(KeyEvent ke) { super.keyReleased(ke); //To change body of generated methods, choose Tools | Templates. keydown = false; }*/ }); getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } if (keydown == false) { if (!keyTimer.isRunning()) { waitlong = true; // printTime("valueChanged, setting waitlong=true: "); keyTimer.setInitialDelay(KEY_PRESS_TIMER_INTERVAL); keyTimer.start("valueChanged start"); } } } }); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.FormPane.java
/** * Creates the proper UI component for the Mapping item. * @param dbFieldType the field type//from ww w . j a va 2 s .co m * @param caption the caption * @param fieldName the name of the field * @param dataFieldLength the length of the definition for that field * @param fieldType the field type * @return a UI component for editing */ protected JComponent createUIComp(final Class<?> dbFieldTypeArg, final String caption, final String fieldName, final Short fieldType, final Short fieldLength, final short columns, final short rows, final WorkbenchTemplateMappingItem wbtmi) { short uiType = WorkbenchTemplateMappingItem.UNKNOWN; //System.out.println(wbtmi.getCaption()+" "+wbtmi.getDataType()+" "+wbtmi.getFieldLength()); Class<?> dbFieldType = dbFieldTypeArg; if (dbFieldType == null) { // if we can't find a class for the field (i.e. Genus Species, or other 'fake' fields), we say it's a string dbFieldType = String.class; } JComponent comp; Component focusComp; // handle dates if (dbFieldType.equals(Calendar.class) || dbFieldType.equals(Date.class)) { //ValFormattedTextField txt = new ValFormattedTextField("Date"); //txt.setColumns(columns == -1 ? DEFAULT_TEXTFIELD_COLS : columns); ValTextField txt = new ValTextField(columns); txt.getDocument().addDocumentListener(docListener); comp = txt; focusComp = comp; uiType = WorkbenchTemplateMappingItem.TEXTFIELD_DATE; } // else if (dbFieldType.equals(Boolean.class)) // strings // { // ValCheckBox checkBox = new ValCheckBox(caption, false, false); // checkBox.addChangeListener(changeListener); // comp = checkBox; // focusComp = comp; // uiType = WorkbenchTemplateMappingItem.CHECKBOX; // } else if (useComboBox(wbtmi)) { //ValComboBox comboBox = new ValComboBox(getValues(wbtmi), true); final JComboBox comboBox = new JComboBox(getValues(wbtmi)); comboBox.setName("Form Combo"); comboBox.setEditable(true); comboBox.addActionListener(new ActionListener() { /* (non-Javadoc) * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @Override public void actionPerformed(ActionEvent arg0) { if (arg0.getSource() == comboBox) { //System.out.println("ComboBox Action!" + ((JComboBox )arg0.getSource()).getName()); stateChange(); } } }); // comboBox.getEditor().getEditorComponent().addFocusListener(new FocusListener() { // // /* (non-Javadoc) // * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent) // */ // @Override // public void focusGained(FocusEvent arg0) { // System.out.println("FOCUS GAINED"); // // } // // /* (non-Javadoc) // * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent) // */ // @Override // public void focusLost(FocusEvent arg0) { // System.out.println("FOCUS LOST"); // // } // // }); comp = comboBox; focusComp = comp; uiType = WorkbenchTemplateMappingItem.COMBOBOX; } else if (useTextField(fieldName, fieldType, fieldLength)) { ValTextField txt = new ValTextField(columns); txt.getDocument().addDocumentListener(docListener); txt.setInputVerifier(new LengthInputVerifier(caption, fieldLength)); comp = txt; focusComp = comp; uiType = WorkbenchTemplateMappingItem.TEXTFIELD; } else { JScrollPane taScrollPane = createTextArea(columns, rows); ((JTextArea) taScrollPane.getViewport().getView()) .setInputVerifier(new LengthInputVerifier(caption, fieldLength)); comp = taScrollPane; focusComp = taScrollPane.getViewport().getView(); uiType = WorkbenchTemplateMappingItem.TEXTAREA; } wbtmi.setFieldType(uiType); focusComp.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { selectControl(e.getSource()); } public void focusLost(FocusEvent e) { //stateChange(); } }); comp.setEnabled(!readOnly); focusComp.setEnabled(!readOnly); comp.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (!readOnly) { if ((e.isControlDown() || e.isMetaDown()) && e.getKeyCode() == KeyEvent.VK_N) { workbenchPane.addRowAfter(); } } super.keyTyped(e); } }); return comp; }
From source file:gtu._work.ui.PropertyEditUI.java
private void initGUI() { try {//from w ww. java2 s . c om setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); BorderLayout thisLayout = new BorderLayout(); this.setTitle("PropertyEditUI"); getContentPane().setLayout(thisLayout); { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu1 = new JMenu(); jMenuBar1.add(jMenu1); jMenu1.setText("File"); { jMenuItem1 = new JMenuItem(); jMenu1.add(jMenuItem1); jMenuItem1.setText("open directory"); jMenuItem1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JCommonUtil._jFileChooser_selectDirectoryOnly(); loadCurrentFile(file); } }); } { openDirectoryAndChildren = new JMenuItem(); jMenu1.add(openDirectoryAndChildren); openDirectoryAndChildren.setText("open directory and children"); openDirectoryAndChildren.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out.println("openDirectoryAndChildren.actionPerformed, event=" + evt); File file = JCommonUtil._jFileChooser_selectDirectoryOnly(); if (file == null) { // file = // PropertiesUtil.getJarCurrentPath(getClass());//XXX file = new File("D:\\my_tool\\english"); JCommonUtil._jOptionPane_showMessageDialog_info("load C:\\L-CONFIG !"); } DefaultListModel model = new DefaultListModel(); List<File> list = new ArrayList<File>(); FileUtil.searchFileMatchs(file, ".*\\.properties", list); for (File f : list) { File_ ff = new File_(); ff.file = f; model.addElement(ff); } backupFileList = list; fileList.setModel(model); } }); } { jMenuItem2 = new JMenuItem(); jMenu1.add(jMenuItem2); jMenuItem2.setText("save"); jMenuItem2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out.println("jMenu3.actionPerformed, event=" + evt); if (currentFile == null) { return; } if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "save to " + currentFile.getName(), "SAVE")) { try { Properties prop = new Properties(); // try { // prop.load(new // FileInputStream(currentFile)); // } catch (Exception e) { // e.printStackTrace(); // JCommonUtil.handleException(e); // return; // } loadModelToProperties(prop); prop.store(new FileOutputStream(currentFile), getTitle()); } catch (Exception e) { e.printStackTrace(); JCommonUtil.handleException(e); } } } }); } { jMenuItem3 = new JMenuItem(); jMenu1.add(jMenuItem3); jMenuItem3.setText("save to target"); jMenuItem3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JFileChooserUtil.newInstance().selectFileOnly().showSaveDialog() .getApproveSelectedFile(); if (file == null) { JCommonUtil._jOptionPane_showMessageDialog_error("file name is not correct!"); return; } if (!file.getName().contains(".properties")) { file = new File(file.getParent(), file.getName() + ".properties"); } try { Properties prop = new Properties(); // try { // prop.load(new // FileInputStream(currentFile)); // } catch (Exception e) { // e.printStackTrace(); // JCommonUtil.handleException(e); // return; // } loadModelToProperties(prop); prop.store(new FileOutputStream(file), getTitle()); } catch (Exception e) { e.printStackTrace(); JCommonUtil.handleException(e); } } }); } { jMenuItem4 = new JMenuItem(); jMenu1.add(jMenuItem4); jMenuItem4.setText("save file(sorted)"); jMenuItem4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (currentFile == null) { return; } try { BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(currentFile))); List<String> sortList = new ArrayList<String>(); for (String line = null; (line = reader.readLine()) != null;) { sortList.add(line); } reader.close(); Collections.sort(sortList); StringBuilder sb = new StringBuilder(); for (String line : sortList) { sb.append(line + "\n"); } FileUtil.saveToFile(currentFile, sb.toString(), "UTF8"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }); } { jMenuItem5 = new JMenuItem(); jMenu1.add(jMenuItem5); jMenuItem5.setText(""); jMenuItem5.addActionListener(new ActionListener() { private void setMeaning(String meaning, int rowPos) { propTable.getRowSorter().getModel().setValueAt(meaning, rowPos, 2); } private void setMeaningEn1(String english, int rowPos, List<String> errSb) { EnglishTester_Diectory eng = new EnglishTester_Diectory(); try { WordInfo wordInfo = eng.parseToWordInfo(english); String meaning = getChs2Big5(wordInfo.getMeaning()); if (hasChinese(meaning)) { setMeaning(meaning, rowPos); } else { setMeaningEn2(english, rowPos, errSb); } } catch (Exception e) { errSb.add(english); e.printStackTrace(); } } private void setMeaningEn2(String english, int rowPos, List<String> errSb) { EnglishTester_Diectory2 eng2 = new EnglishTester_Diectory2(); try { WordInfo2 wordInfo = eng2.parseToWordInfo(english); String meaning = getChs2Big5(StringUtils.join(wordInfo.getMeaningList(), ";")); setMeaning(meaning, rowPos); } catch (Exception e) { errSb.add(english); e.printStackTrace(); } } private boolean hasChinese(String val) { return new StringUtil_().getChineseWord(val, true).length() > 0; } private Properties loadFromMemoryBank() { try { Properties prop = new Properties(); File f1 = new File( "D:/gtu001_dropbox/Dropbox/Apps/gtu001_test/etc_config/EnglishSearchUI_MemoryBank.properties"); File f2 = new File( "e:/gtu001_dropbox/Dropbox/Apps/gtu001_test/etc_config/EnglishSearchUI_MemoryBank.properties"); for (File f : new File[] { f1, f2 }) { if (f.exists()) { HermannEbbinghaus_Memory memory = new HermannEbbinghaus_Memory(); memory.init(f); List<MemData> memLst = memory.getAllMemData(true); for (MemData d : memLst) { prop.setProperty(d.getKey(), getChs2Big5(d.getRemark())); } break; } } return prop; } catch (Exception ex) { throw new RuntimeException(ex); } } public void actionPerformed(ActionEvent evt) { if (currentFile == null) { return; } // Properties memoryProp = loadFromMemoryBank(); Properties memoryProp = new Properties(); List<String> errSb = new ArrayList<String>(); for (int row = 0; row < propTable.getModel().getRowCount(); row++) { int rowPos = propTable.getRowSorter().convertRowIndexToModel(row); String english = StringUtils.trimToEmpty( (String) propTable.getRowSorter().getModel().getValueAt(rowPos, 1)) .toLowerCase(); String desc = (String) propTable.getRowSorter().getModel().getValueAt(rowPos, 2); if (memoryProp.containsKey(english) && StringUtils.isNotBlank(memoryProp.getProperty(english))) { setMeaning(memoryProp.getProperty(english), rowPos); } else { if (StringUtils.isBlank(desc) || !hasChinese(desc)) { if (!english.contains(" ")) { setMeaningEn1(english, rowPos, errSb); } else { setMeaningEn2(english, rowPos, errSb); } } } if (StringUtils.trimToEmpty(desc).contains("?")) { setMeaning("", rowPos); } } if (!errSb.isEmpty()) { JCommonUtil._jOptionPane_showMessageDialog_error(":\n" + errSb); } } }); } { JMenuItem jMenuItem6 = new JMenuItem(); jMenu1.add(jMenuItem6); jMenuItem6.setText(""); jMenuItem6.addActionListener(new ActionListener() { private void setMeaning(String meaning, int rowPos) { propTable.getRowSorter().getModel().setValueAt(meaning, rowPos, 2); } public void actionPerformed(ActionEvent evt) { for (int row = 0; row < propTable.getModel().getRowCount(); row++) { int rowPos = propTable.getRowSorter().convertRowIndexToModel(row); String english = StringUtils.trimToEmpty( (String) propTable.getRowSorter().getModel().getValueAt(rowPos, 1)) .toLowerCase(); String desc = (String) propTable.getRowSorter().getModel().getValueAt(rowPos, 2); if (StringUtils.trimToEmpty(desc).contains("?")) { setMeaning("", rowPos); } } } }); } } } { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("editor", null, jPanel2, null); { jScrollPane1 = new JScrollPane(); jPanel2.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(550, 314)); { TableModel propTableModel = new DefaultTableModel( new String[][] { { "", "", "" }, { "", "", "" } }, new String[] { "index", "Key", "value" }); propTable = new JTable(); JTableUtil.defaultSetting_AutoResize(propTable); jScrollPane1.setViewportView(propTable); propTable.setModel(propTableModel); propTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { JTableUtil xxxxxx = JTableUtil.newInstance(propTable); int[] rows = xxxxxx.getSelectedRows(); for (int ii : rows) { System.out.println(xxxxxx.getModel().getValueAt(ii, 1)); } JPopupMenuUtil.newInstance(propTable).applyEvent(evt) .addJMenuItem(JTableUtil.newInstance(propTable).getDefaultJMenuItems()) .show(); } }); } } { queryText = new JTextField(); jPanel2.add(queryText, BorderLayout.NORTH); queryText.getDocument() .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() { @Override public void process(DocumentEvent event) { if (currentFile == null) { return; } Properties prop = new Properties(); try { prop.load(new FileInputStream(currentFile)); } catch (Exception e) { e.printStackTrace(); JCommonUtil.handleException(e); return; } loadPropertiesToModel(prop); String text = JCommonUtil.getDocumentText(event); Pattern pattern = null; try { pattern = Pattern.compile(text); } catch (Exception ex) { } DefaultTableModel model = JTableUtil.newInstance(propTable).getModel(); for (int ii = 0; ii < model.getRowCount(); ii++) { String key = (String) model.getValueAt(ii, 1); String value = (String) model.getValueAt(ii, 2); if (key.contains(text)) { continue; } if (value.contains(text)) { continue; } if (pattern != null) { if (pattern.matcher(key).find()) { continue; } if (pattern.matcher(value).find()) { continue; } } model.removeRow(propTable.convertRowIndexToModel(ii)); ii--; } } })); } } { jPanel3 = new JPanel(); BorderLayout jPanel3Layout = new BorderLayout(); jPanel3.setLayout(jPanel3Layout); jTabbedPane1.addTab("folder", null, jPanel3, null); { jScrollPane2 = new JScrollPane(); jPanel3.add(jScrollPane2, BorderLayout.CENTER); jScrollPane2.setPreferredSize(new java.awt.Dimension(550, 314)); { fileList = new JList(); jScrollPane2.setViewportView(fileList); fileList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(fileList).defaultJListKeyPressed(evt); } }); fileList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { final File_ file = JListUtil.getLeadSelectionObject(fileList); if (evt.getButton() == MouseEvent.BUTTON1) { Properties prop = new Properties(); currentFile = file.file; setTitle(currentFile.getName()); try { prop.load(new FileInputStream(file.file)); } catch (Exception e) { e.printStackTrace(); } loadPropertiesToModel(prop); } if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 2) { try { Runtime.getRuntime().exec(String.format("cmd /c \"%s\"", file.file)); } catch (IOException e1) { e1.printStackTrace(); } } final File parent = file.file.getParentFile(); JMenuItem openTargetDir = new JMenuItem(); openTargetDir.setText("open : " + parent); openTargetDir.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Desktop.getDesktop().open(parent); } catch (IOException e1) { JCommonUtil.handleException(e1); } } }); JPopupMenuUtil.newInstance(fileList).addJMenuItem(openTargetDir).applyEvent(evt) .show(); } }); } } { fileQueryText = new JTextField(); jPanel3.add(fileQueryText, BorderLayout.NORTH); fileQueryText.getDocument() .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() { @Override public void process(DocumentEvent event) { String text = JCommonUtil.getDocumentText(event); DefaultListModel model = new DefaultListModel(); for (File f : backupFileList) { if (f.getName().contains(text)) { File_ ff = new File_(); ff.file = f; model.addElement(ff); } } fileList.setModel(model); } })); } { contentQueryText = new JTextField(); jPanel3.add(contentQueryText, BorderLayout.SOUTH); contentQueryText.addActionListener(new ActionListener() { void addModel(File f, DefaultListModel model) { File_ ff = new File_(); ff.file = f; model.addElement(ff); } public void actionPerformed(ActionEvent evt) { DefaultListModel model = new DefaultListModel(); String text = contentQueryText.getText(); if (StringUtils.isEmpty(contentQueryText.getText())) { return; } Pattern pattern = Pattern.compile(text); Properties pp = null; for (File f : backupFileList) { pp = new Properties(); try { pp.load(new FileInputStream(f)); for (String key : pp.stringPropertyNames()) { if (key.isEmpty()) { continue; } if (pp.getProperty(key) == null || pp.getProperty(key).isEmpty()) { continue; } if (key.contains(text)) { addModel(f, model); break; } if (pp.getProperty(key).contains(text)) { addModel(f, model); break; } if (pattern.matcher(key).find()) { addModel(f, model); break; } if (pattern.matcher(pp.getProperty(key)).find()) { addModel(f, model); break; } } } catch (Exception e) { e.printStackTrace(); } } fileList.setModel(model); } }); } } } JCommonUtil.setJFrameIcon(this, "resource/images/ico/english.ico"); JCommonUtil.setJFrameCenter(this); pack(); this.setSize(571, 408); loadCurrentFile(null); } catch (Exception e) { e.printStackTrace(); } }
From source file:op.care.prescription.DlgOnDemand.java
/** * This method is called from within the constructor to * initialize the form.//from www .j a va2 s. c o m * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the PrinterForm Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new JPanel(); txtMed = new JXSearchField(); cmbMed = new JComboBox<>(); panel4 = new JPanel(); btnMedWizard = new JButton(); cmbIntervention = new JComboBox<>(); txtSit = new JXSearchField(); cmbSit = new JComboBox<>(); panel3 = new JPanel(); btnAddSit = new JButton(); txtIntervention = new JXSearchField(); jPanel2 = new JPanel(); lblNumber = new JLabel(); lblDose = new JLabel(); lblMaxPerDay = new JLabel(); txtMaxTimes = new JTextField(); lblX = new JLabel(); txtEDosis = new JTextField(); lblCheckResultAfter = new JLabel(); cmbCheckAfter = new JComboBox<>(); jPanel3 = new JPanel(); pnlOFF = new JPanel(); rbActive = new JRadioButton(); rbDate = new JRadioButton(); txtOFF = new JTextField(); jScrollPane3 = new JScrollPane(); txtBemerkung = new JTextPane(); lblText = new JLabel(); pnlON = new JPanel(); cmbDocON = new JComboBox<>(); cmbHospitalON = new JComboBox<>(); panel1 = new JPanel(); btnClose = new JButton(); btnSave = new JButton(); //======== this ======== setModalityType(Dialog.ModalityType.APPLICATION_MODAL); setResizable(false); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); Container contentPane = getContentPane(); contentPane.setLayout(new FormLayout("14dlu, $lcgap, default, 6dlu, 355dlu, $lcgap, 14dlu", "14dlu, $lgap, fill:default:grow, $lgap, fill:default, $lgap, 14dlu")); //======== jPanel1 ======== { jPanel1.setBorder(null); jPanel1.setLayout(new FormLayout("68dlu, $lcgap, pref:grow, $lcgap, pref", "3*(16dlu, $lgap), default, $lgap, fill:113dlu:grow, $lgap, 60dlu")); //---- txtMed ---- txtMed.setFont(new Font("Arial", Font.PLAIN, 14)); txtMed.setPrompt("Medikamente"); txtMed.setFocusBehavior(PromptSupport.FocusBehavior.HIGHLIGHT_PROMPT); txtMed.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { txtMedActionPerformed(e); } }); txtMed.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtMedFocusGained(e); } }); jPanel1.add(txtMed, CC.xy(1, 1)); //---- cmbMed ---- cmbMed.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); cmbMed.setFont(new Font("Arial", Font.PLAIN, 14)); cmbMed.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { cmbMedItemStateChanged(e); } }); jPanel1.add(cmbMed, CC.xy(3, 1)); //======== panel4 ======== { panel4.setLayout(new BoxLayout(panel4, BoxLayout.LINE_AXIS)); //---- btnMedWizard ---- btnMedWizard.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png"))); btnMedWizard.setBorderPainted(false); btnMedWizard.setBorder(null); btnMedWizard.setContentAreaFilled(false); btnMedWizard.setToolTipText("Neues Medikament eintragen"); btnMedWizard.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnMedWizard.setSelectedIcon( new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png"))); btnMedWizard.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnMedActionPerformed(e); } }); panel4.add(btnMedWizard); } jPanel1.add(panel4, CC.xy(5, 1)); //---- cmbIntervention ---- cmbIntervention .setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); cmbIntervention.setFont(new Font("Arial", Font.PLAIN, 14)); jPanel1.add(cmbIntervention, CC.xywh(3, 5, 3, 1)); //---- txtSit ---- txtSit.setPrompt("Situationen"); txtSit.setFont(new Font("Arial", Font.PLAIN, 14)); txtSit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { txtSitActionPerformed(e); } }); jPanel1.add(txtSit, CC.xy(1, 3)); //---- cmbSit ---- cmbSit.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); cmbSit.setFont(new Font("Arial", Font.PLAIN, 14)); cmbSit.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { cmbSitItemStateChanged(e); } }); cmbSit.addPropertyChangeListener("model", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent e) { cmbSitPropertyChange(e); } }); jPanel1.add(cmbSit, CC.xy(3, 3)); //======== panel3 ======== { panel3.setLayout(new BoxLayout(panel3, BoxLayout.LINE_AXIS)); //---- btnAddSit ---- btnAddSit.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png"))); btnAddSit.setBorderPainted(false); btnAddSit.setBorder(null); btnAddSit.setContentAreaFilled(false); btnAddSit.setToolTipText("Neue Situation eintragen"); btnAddSit.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnAddSit.setSelectedIcon( new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png"))); btnAddSit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnSituationActionPerformed(e); } }); panel3.add(btnAddSit); } jPanel1.add(panel3, CC.xy(5, 3, CC.RIGHT, CC.DEFAULT)); //---- txtIntervention ---- txtIntervention.setFont(new Font("Arial", Font.PLAIN, 14)); txtIntervention.setPrompt("Massnahmen"); txtIntervention.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { txtMassActionPerformed(e); } }); jPanel1.add(txtIntervention, CC.xy(1, 5)); //======== jPanel2 ======== { jPanel2.setLayout(new FormLayout("default, $lcgap, pref, $lcgap, default, $lcgap, 37dlu:grow", "23dlu, fill:22dlu, $ugap, default")); //---- lblNumber ---- lblNumber.setText("Anzahl"); jPanel2.add(lblNumber, CC.xy(3, 1)); //---- lblDose ---- lblDose.setText("Dosis"); jPanel2.add(lblDose, CC.xy(7, 1, CC.CENTER, CC.DEFAULT)); //---- lblMaxPerDay ---- lblMaxPerDay.setText("Max. Tagesdosis:"); jPanel2.add(lblMaxPerDay, CC.xy(1, 2)); //---- txtMaxTimes ---- txtMaxTimes.setHorizontalAlignment(SwingConstants.CENTER); txtMaxTimes.setText("1"); txtMaxTimes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { txtMaxTimesActionPerformed(e); } }); txtMaxTimes.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtMaxTimesFocusGained(e); } @Override public void focusLost(FocusEvent e) { txtMaxTimesFocusLost(e); } }); jPanel2.add(txtMaxTimes, CC.xy(3, 2)); //---- lblX ---- lblX.setText("x"); jPanel2.add(lblX, CC.xy(5, 2)); //---- txtEDosis ---- txtEDosis.setHorizontalAlignment(SwingConstants.CENTER); txtEDosis.setText("1.0"); txtEDosis.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtEDosisFocusGained(e); } @Override public void focusLost(FocusEvent e) { txtEDosisFocusLost(e); } }); txtEDosis.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { txtEDosisActionPerformed(e); } }); jPanel2.add(txtEDosis, CC.xy(7, 2)); //---- lblCheckResultAfter ---- lblCheckResultAfter.setText("Nachkontrolle:"); jPanel2.add(lblCheckResultAfter, CC.xy(1, 4)); //---- cmbCheckAfter ---- cmbCheckAfter.setModel(new DefaultComboBoxModel<>(new String[] { "keine Nachkontrolle", "nach 1 Stunde", "nach 2 Stunden", "nach 3 Stunden" })); jPanel2.add(cmbCheckAfter, CC.xywh(3, 4, 5, 1)); } jPanel1.add(jPanel2, CC.xywh(1, 9, 5, 1, CC.CENTER, CC.TOP)); } contentPane.add(jPanel1, CC.xy(5, 3)); //======== jPanel3 ======== { jPanel3.setBorder(null); jPanel3.setLayout(new FormLayout("149dlu", "3*(fill:default, $lgap), fill:100dlu:grow")); //======== pnlOFF ======== { pnlOFF.setBorder(new TitledBorder("Absetzung")); pnlOFF.setLayout(new FormLayout("pref, 86dlu:grow", "fill:17dlu, $lgap, fill:17dlu")); //---- rbActive ---- rbActive.setText("text"); rbActive.setSelected(true); rbActive.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { rbActiveItemStateChanged(e); } }); pnlOFF.add(rbActive, CC.xywh(1, 1, 2, 1)); //---- rbDate ---- rbDate.setText(null); rbDate.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { rbDateItemStateChanged(e); } }); pnlOFF.add(rbDate, CC.xy(1, 3)); //---- txtOFF ---- txtOFF.setEnabled(false); txtOFF.setFont(new Font("Arial", Font.PLAIN, 14)); txtOFF.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { txtOFFFocusLost(e); } }); pnlOFF.add(txtOFF, CC.xy(2, 3)); } jPanel3.add(pnlOFF, CC.xy(1, 3)); //======== jScrollPane3 ======== { //---- txtBemerkung ---- txtBemerkung.addCaretListener(new CaretListener() { @Override public void caretUpdate(CaretEvent e) { txtBemerkungCaretUpdate(e); } }); jScrollPane3.setViewportView(txtBemerkung); } jPanel3.add(jScrollPane3, CC.xy(1, 7)); //---- lblText ---- lblText.setText("Bemerkung:"); jPanel3.add(lblText, CC.xy(1, 5)); //======== pnlON ======== { pnlON.setBorder(new TitledBorder("Ansetzung")); pnlON.setLayout(new FormLayout("119dlu:grow", "17dlu, $lgap, fill:17dlu")); //---- cmbDocON ---- cmbDocON.setModel( new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); cmbDocON.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { cmbDocONKeyPressed(e); } }); pnlON.add(cmbDocON, CC.xy(1, 1)); //---- cmbHospitalON ---- cmbHospitalON.setModel( new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); pnlON.add(cmbHospitalON, CC.xy(1, 3)); } jPanel3.add(pnlON, CC.xy(1, 1)); } contentPane.add(jPanel3, CC.xy(3, 3)); //======== panel1 ======== { panel1.setLayout(new BoxLayout(panel1, BoxLayout.LINE_AXIS)); //---- btnClose ---- btnClose.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png"))); btnClose.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnClose.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnCloseActionPerformed(e); } }); panel1.add(btnClose); //---- btnSave ---- btnSave.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png"))); btnSave.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnSaveActionPerformed(e); } }); panel1.add(btnSave); } contentPane.add(panel1, CC.xy(5, 5, CC.RIGHT, CC.DEFAULT)); setSize(1035, 515); setLocationRelativeTo(getOwner()); //---- bgMedikament ---- ButtonGroup bgMedikament = new ButtonGroup(); bgMedikament.add(rbActive); bgMedikament.add(rbDate); }