List of usage examples for java.awt.event MouseAdapter MouseAdapter
MouseAdapter
From source file:gtu._work.mvn.MavenRepositoryUI.java
private void initGUI() { try {//from w w w. ja va2s. c o m { } BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); scanList = new JList(); jTabbedPane1.addTab("repository", null, jPanel1, null); { scanText = new JTextField(); jPanel1.add(scanText, BorderLayout.NORTH); } { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); { ListModel scanListModel = new DefaultListModel(); jScrollPane1.setViewportView(scanList); scanList.setModel(scanListModel); scanList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { defaultJListClick(scanList, evt); } }); } } } { jPanel4 = new JPanel(); BorderLayout jPanel4Layout = new BorderLayout(); jPanel4.setLayout(jPanel4Layout); jTabbedPane1.addTab("repository only jar", null, jPanel4, null); jPanel4.setPreferredSize(new java.awt.Dimension(520, 298)); { scanText2 = new JTextField(); jPanel4.add(scanText2, BorderLayout.NORTH); } { jScrollPane3 = new JScrollPane(); jPanel4.add(jScrollPane3, BorderLayout.CENTER); { scanList2 = new JList(); jScrollPane3.setViewportView(scanList2); ListModel scanList2Model = new DefaultListModel(); scanList2.setModel(scanList2Model); scanList2.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { defaultJListClick(scanList2, evt); } }); } } { } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("jar find", null, jPanel2, null); { jarFindText = new JTextField(); jPanel2.add(jarFindText, BorderLayout.NORTH); } { jScrollPane2 = new JScrollPane(); jPanel2.add(jScrollPane2, BorderLayout.CENTER); { ListModel jarFindListModel = new DefaultListModel(); jarFindList = new JList(); jScrollPane2.setViewportView(jarFindList); jarFindList.setModel(jarFindListModel); jarFindList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { defaultJListClick(jarFindList, evt); } }); } } { jarFindExecute = new JButton(); jPanel2.add(jarFindExecute, BorderLayout.SOUTH); jarFindExecute.setText("find"); jarFindExecute.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String searchtext = jarFindText.getText(); if (StringUtils.isEmpty(searchtext) || searchtext.length() < 2) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("", "error"); return; } try { DefaultListModel model = new DefaultListModel(); jarFindList.setModel(model); searchtext = searchtext.trim(); searchtext = searchtext.replace('/', '.'); searchtext = searchtext.replace('\\', '.'); if (jarfinder == null) { jarfinder = JarFinder.newInstance(); } else { jarfinder.clear(); } jarfinder.pattern(searchtext); DefaultListModel scanModel = (DefaultListModel) scanList.getModel(); PomFile pomFile = null; for (int ii = 0; ii < scanModel.getSize(); ii++) { pomFile = (PomFile) scanModel.getElementAt(ii); if (pomFile.jarFile == null) { continue; } jarfinder.setDir(pomFile.jarFile); if (!jarfinder.execute().isEmpty()) { model.addElement(pomFile); } jarfinder.getMap().clear(); } } catch (Exception ex) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog(ex.getMessage(), "error"); ex.printStackTrace(); } } }); } } { jPanel5 = new JPanel(); BorderLayout jPanel5Layout = new BorderLayout(); jTabbedPane1.addTab("detail", null, jPanel5, null); jPanel5.setLayout(jPanel5Layout); { jScrollPane4 = new JScrollPane(); jPanel5.add(jScrollPane4, BorderLayout.CENTER); { TableModel scanTableModel = new DefaultTableModel(); scanTable = new JTable(); BorderLayout scanTableLayout = new BorderLayout(); scanTable.setLayout(scanTableLayout); jScrollPane4.setViewportView(scanTable); scanTable.setModel(scanTableModel); JTableUtil.defaultSetting(scanTable); scanTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { tableMouseClicked(scanTable, 0, evt); } }); } } } { jPanel3 = new JPanel(); jTabbedPane1.addTab("config", null, jPanel3, null); GroupLayout jPanel3Layout = new GroupLayout((JComponent) jPanel3); jPanel3.setLayout(jPanel3Layout); { copyToDir = new JButton(); copyToDir.setText("set copy to dir"); copyToDir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (file == null || !file.exists() || !file.isDirectory()) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("dir is not correct!, set default desktop", "error"); file = FileUtil.DESKTOP_DIR; } copyTo = file; System.out.println("copyTo: " + copyTo); } }); } { resetM2Dir = new JButton(); resetM2Dir.setText("set .m2 dir"); resetM2Dir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (file == null || !file.exists() || !file.isDirectory()) { showErrorMsg(); repositoryDir = DEFAULT_REPOSITORY_DIR; reloadRepositoryDir(); return; } File newRepository = new File(file, "repository"); File settings = new File(file, "settings.xml"); if (settings.exists() && settings.isFile() && newRepository.exists() && newRepository.isDirectory()) { repositoryDir = newRepository; reloadRepositoryDir(); } else { showErrorMsg(); } } void showErrorMsg() { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("dir is not correct!, set default .m2 dir", "error"); } }); } { saveCurrentDataBtn = new JButton(); saveCurrentDataBtn.setText("save current data"); saveCurrentDataBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File cfgFile = new File(PropertiesUtil.getJarCurrentPath(MavenRepositoryUI.class), MavenRepositoryUI.class.getSimpleName() + "_" + DateFormatUtil .format(System.currentTimeMillis(), "yyyyMMdd_HHmmss") + ".cfg"); try { ObjectOutputStream writer = new ObjectOutputStream( new FileOutputStream(cfgFile)); writer.writeObject(pomFileList); writer.writeObject(pomFileJarList); writer.writeObject(pomFileMap); writer.flush(); writer.close(); JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("save completed!\n" + cfgFile, "SUCCESS"); } catch (Exception ex) { JCommonUtil.handleException(ex); ex.printStackTrace(); } } }); } { loadConfigDataBtn = new JButton(); loadConfigDataBtn.setText("load config data"); loadConfigDataBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File cfgFile = JFileChooserUtil.newInstance().selectFileOnly() .addAcceptFile("cfg", ".cfg").showOpenDialog().getApproveSelectedFile(); if (cfgFile == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("file is not correct!", "ERROR"); return; } try { ObjectInputStream reader = new ObjectInputStream(new FileInputStream(cfgFile)); pomFileList = (Set<PomFile>) reader.readObject(); pomFileJarList = (Set<PomFile>) reader.readObject(); pomFileMap = (Map<DependencyKey, PomFile>) reader.readObject(); reader.close(); resetUIStatus(); JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("load completed!\n" + cfgFile, "SUCCESS"); } catch (Exception ex) { JCommonUtil.handleException(ex); ex.printStackTrace(); } } }); } jPanel3Layout.setHorizontalGroup(jPanel3Layout.createSequentialGroup().addContainerGap(24, 24) .addGroup(jPanel3Layout.createParallelGroup() .addGroup(jPanel3Layout.createSequentialGroup().addComponent(loadConfigDataBtn, GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel3Layout.createSequentialGroup().addComponent(saveCurrentDataBtn, GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel3Layout.createSequentialGroup().addComponent(copyToDir, GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel3Layout.createSequentialGroup().addComponent(resetM2Dir, GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel3Layout.createSequentialGroup().addComponent(getJButton1(), GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE))) .addContainerGap(281, Short.MAX_VALUE)); jPanel3Layout.setVerticalGroup(jPanel3Layout.createSequentialGroup().addContainerGap(25, 25) .addComponent(copyToDir, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE) .addGap(22) .addComponent(resetM2Dir, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE) .addGap(24) .addComponent(saveCurrentDataBtn, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE) .addGap(25) .addComponent(loadConfigDataBtn, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE) .addGap(28) .addComponent(getJButton1(), GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE) .addContainerGap(34, Short.MAX_VALUE)); } { jPanel6 = new JPanel(); BorderLayout jPanel6Layout = new BorderLayout(); jPanel6.setLayout(jPanel6Layout); jTabbedPane1.addTab("pom dency", null, jPanel6, null); { openPom = new JButton(); jPanel6.add(openPom, BorderLayout.NORTH); openPom.setText("open"); openPom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JFileChooserUtil.newInstance().selectFileAndDirectory() .showDialog("?pom,pom").getApproveSelectedFile(); if (file == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("file is not correct!!", "ERROR"); return; } List<File> pomList = new ArrayList<File>(); if (file.isFile() && (file.getName().endsWith(".xml") || file.getName().endsWith(".pom"))) { pomList.add(file); } else { FileUtil.searchFileMatchs(file, "pom.xml", pomList); } Set<PomFile> poms = loadPomList(pomList); resetUIStatus(); Map<DependencyKey, PomFile> map = new HashMap<DependencyKey, PomFile>(); Set<LoadPomListDependency.DependencyKey> errorSet = new HashSet<LoadPomListDependency.DependencyKey>(); for (PomFile p : poms) { openPomFetchDependency(p.pom, map, errorSet); } PomFile pfile = null; DefaultTableModel model = JTableUtil.createModel(true, "groupId", "artifactId", "jar", "pomFile"); for (DependencyKey key : map.keySet()) { pfile = map.get(key); model.addRow(new Object[] { pfile.pom.groupId, pfile.pom.artifactId, (pfile.jarFile == null ? "" : pfile.jarFile.getName()), pfile }); } for (LoadPomListDependency.DependencyKey key : errorSet) { model.addRow(new Object[] { key.groupId, key.artifactId, "ERROR" }); } pomDenpendencyTable.setModel(model); } }); } { jScrollPane5 = new JScrollPane(); jPanel6.add(jScrollPane5, BorderLayout.CENTER); { TableModel pomDenpendencyTableModel = new DefaultTableModel(); pomDenpendencyTable = new JTable(); jScrollPane5.setViewportView(pomDenpendencyTable); pomDenpendencyTable.setModel(pomDenpendencyTableModel); pomDenpendencyTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { tableMouseClicked(pomDenpendencyTable, 3, evt); } }); JTableUtil.defaultSetting(pomDenpendencyTable); } } { jPanel7 = new JPanel(); FlowLayout jPanel7Layout = new FlowLayout(); jPanel7Layout.setAlignOnBaseline(true); jPanel6.add(jPanel7, BorderLayout.SOUTH); jPanel7.setLayout(jPanel7Layout); jPanel7.setPreferredSize(new java.awt.Dimension(520, 36)); { clipboardListJar = new JButton(); jPanel7.add(clipboardListJar); clipboardListJar.setText("jar list to clipboard"); clipboardListJar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { List<File> list = fetchPomDependencyTableJarList(); StringBuilder sb = new StringBuilder(); for (File f : list) { sb.append(f + "\n"); } ClipboardUtil.getInstance().setContents(sb); JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("clipboard set ok!", "SUCCESS"); } }); } { pomOutputJarDir = new JButton(); jPanel7.add(pomOutputJarDir); pomOutputJarDir.setText("set output jar dir"); pomOutputJarDir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JFileChooserUtil.newInstance().selectDirectoryOnly() .showDialog("?Jar").getApproveSelectedFile(); if (file == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("dir is not correct!!", "ERROR"); return; } pomOutputJarDir_ = file; } }); } { exportListJar = new JButton(); jPanel7.add(exportListJar); exportListJar.setText("export list jar"); exportListJar.setPreferredSize(new java.awt.Dimension(113, 24)); exportListJar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { List<File> list = fetchPomDependencyTableJarList(); if (pomOutputJarDir_ == null || !pomOutputJarDir_.exists() || !pomOutputJarDir_.isDirectory()) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("output dir is not correct!!", "ERROR"); return; } if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION == JOptionPaneUtil .newInstance().confirmButtonYesNo().iconWaringMessage() .showConfirmDialog("are you sure copy list jar count:(" + list.size() + ") to\n" + pomOutputJarDir_, "WARN")) { StringBuilder sb = new StringBuilder(); StringBuilder fsb = new StringBuilder(); sb.append("total : " + list.size() + "\n"); int ok = 0; int noOk = 0; for (File f : list) { try { FileUtil.copyFile(f, new File(pomOutputJarDir_, f.getName())); ok++; } catch (IOException e) { e.printStackTrace(); noOk++; fsb.append(f + "\n"); } } sb.append("success : " + ok + "\n"); sb.append("failed : " + noOk + "\n"); sb.append("Failed jar :\n"); sb.append(fsb); JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog(sb, "COPY RESULT"); } } }); } } } } this.setSize(541, 365); reloadRepositoryDir(); } catch (Exception e) { e.printStackTrace(); } }
From source file:io.github.jeremgamer.editor.panels.Buttons.java
public Buttons(final JFrame frame, final ButtonPanel be, final PanelSave ps) { this.setBorder(BorderFactory.createTitledBorder("")); this.frame = frame; JButton add = null;/* www . ja v a 2s .co m*/ try { add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png")))); } catch (IOException e) { e.printStackTrace(); } add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") String name = jop.showInputDialog(null, "Nommez le bouton :", "Crer un bouton", JOptionPane.QUESTION_MESSAGE); if (name != null) { for (int i = 0; i < data.getSize(); i++) { if (data.get(i).equals(name)) { name += "1"; } } data.addElement(name); new ButtonSave(name); ActionPanel.updateLists(); OtherPanel.updateLists(); PanelsPanel.updateLists(); } } catch (IOException e) { e.printStackTrace(); } } }); JButton remove = null; try { remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { if (buttonList.getSelectedValue() != null) { File file = new File("projects/" + Editor.getProjectName() + "/buttons/" + buttonList.getSelectedValue() + "/" + buttonList.getSelectedValue() + ".rbd"); JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") int option = jop.showConfirmDialog(null, "tes-vous sr de vouloir supprimer ce bouton?", "Avertissement", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (option == JOptionPane.OK_OPTION) { File dir = new File("projects/" + Editor.getProjectName() + "/panels"); for (File f : FileUtils.listFilesAndDirs(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { if (!f.isDirectory()) { try { ps.load(f); } catch (IOException e) { e.printStackTrace(); } for (String section : ps .getSectionsContaining(buttonList.getSelectedValue() + " (Bouton)")) { ps.removeSection(section); try { ps.save(f); } catch (IOException e) { e.printStackTrace(); } } } } if (buttonList.getSelectedValue().equals(be.getFileName())) { be.setFileName(""); } be.hide(); file.delete(); File parent = new File(file.getParent()); for (File img : FileUtils.listFiles(parent, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { img.delete(); } parent.delete(); data.remove(buttonList.getSelectedIndex()); ActionPanel.updateLists(); OtherPanel.updateLists(); PanelsPanel.updateLists(); } } } catch (NullPointerException npe) { npe.printStackTrace(); } } }); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS)); buttons.add(add); buttons.add(remove); updateList(); buttonList.addMouseListener(new MouseAdapter() { @SuppressWarnings("unchecked") public void mouseClicked(MouseEvent evt) { JList<String> list = (JList<String>) evt.getSource(); if (evt.getClickCount() == 2) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { be.load(new File("projects/" + Editor.getProjectName() + "/buttons/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); be.show(); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { be.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { be.hideThenShow(); previousSelection = list.getSelectedValue(); be.load(new File("projects/" + Editor.getProjectName() + "/buttons/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { be.hide(); list.clearSelection(); } } } else if (evt.getClickCount() == 3) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { be.load(new File("projects/" + Editor.getProjectName() + "/buttons/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); be.show(); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { be.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { be.hideThenShow(); previousSelection = list.getSelectedValue(); be.load(new File("projects/" + Editor.getProjectName() + "/buttons/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { be.hide(); list.clearSelection(); } } } } }); JScrollPane listPane = new JScrollPane(buttonList); listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(buttons); this.add(listPane); }
From source file:com.funambol.email.admin.user.ResultSearchUserPanel.java
/** * Set up graphic elements for this panel. * * @throws Exception if error occures during creation of the panel *///from w w w .j a v a 2 s. com private void init() throws Exception { // create objects to display this.setLayout(new BorderLayout()); this.setBorder(BorderFactory.createEmptyBorder()); // create a model for the user table and pass it to the JTable object model = new UserTableModel(); table = new JTable(model); table.setShowGrid(true); table.setAutoscrolls(true); table.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); JScrollPane scrollpane = new JScrollPane(table); table.setPreferredScrollableViewportSize(new Dimension(800, 200)); table.setFont(GuiFactory.defaultTableFont); table.getTableHeader().setFont(GuiFactory.defaultTableHeaderFont); this.add(scrollpane, BorderLayout.CENTER); // // Select user. // table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ListSelectionModel rowSM = table.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { if (event.getValueIsAdjusting()) { return; } ListSelectionModel lsm = (ListSelectionModel) event.getSource(); if (lsm.isSelectionEmpty()) { selectedUser = null; } else { int selectedRow = lsm.getMinSelectionIndex(); selectedUser = users[selectedRow]; } } }); rowSM.clearSelection(); table.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent event) { if (event.getClickCount() < 2) { return; } // // If the selected user is already associated to an account // then insertion process can't go on. // String userName = selectedUser.getUsername(); String value[] = new String[] { userName }; WhereClause wc = new WhereClause("username", value, WhereClause.OPT_EQ, true); MailServerAccount[] tmp = null; try { tmp = WSDao.getAccounts(wc); } catch (Exception e) { } if (tmp.length > 0) { StringBuilder sb = new StringBuilder("The user "); sb.append(userName).append(" is already associated to an account"); Object[] options = { "OK" }; JOptionPane.showOptionDialog(null, sb.toString(), "Warning", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); } else { // // Go to next step. // step.goToNextStep(); } } }); }
From source file:gtu._work.etc.EnglishTester.java
private void initGUI() { try {/* w ww. j a v a2 s . c o m*/ JCommonUtil.defaultToolTipDelay(); BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); jTabbedPane1.setPreferredSize(new java.awt.Dimension(462, 259)); jTabbedPane1.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { // XXX // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx jTabbedPane1.requestFocus();// FOCUS TODO // XXX // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx } }); jTabbedPane1.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { System.out.println("2===" + evt.getKeyCode()); if (evt.getKeyCode() == 49) {// 0 jTabbedPane1.setSelectedIndex(0); } if (evt.getKeyCode() == 50) {// 1 jTabbedPane1.setSelectedIndex(1); } if (evt.getKeyCode() == 10) {// enter skipBtnAction(); } if (evt.getKeyCode() == 32) {// removeBtnAction(); } } }); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("english", null, jPanel1, null); { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(420, 141)); { englishArea = new JTextArea(); jScrollPane1.setViewportView(englishArea); englishArea.setFont(new java.awt.Font("Microsoft JhengHei", 0, 22)); } } { jPanel5 = new JPanel(); jPanel1.add(jPanel5, BorderLayout.SOUTH); jPanel5.setPreferredSize(new java.awt.Dimension(402, 65)); { skipBtn = new JButton(); jPanel5.add(skipBtn); skipBtn.setText("skip"); skipBtn.setPreferredSize(new java.awt.Dimension(187, 24)); skipBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { skipBtnAction(); } }); } { removeBtn = new JButton(); jPanel5.add(removeBtn); removeBtn.setText("remove"); removeBtn.setPreferredSize(new java.awt.Dimension(180, 24)); removeBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { removeBtnAction(); } }); } { questionCountLabel = new JLabel(); jPanel5.add(questionCountLabel); questionCountLabel.setPreferredSize(new java.awt.Dimension(47, 21)); questionCountLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); questionCountLabel.setToolTipText(""); } { propCountLabel = new JLabel(); jPanel5.add(propCountLabel); propCountLabel.setPreferredSize(new java.awt.Dimension(45, 21)); propCountLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); propCountLabel.setToolTipText(""); } { googleSearchBtn = new JButton(); jPanel5.add(googleSearchBtn); googleSearchBtn.setText("<html>GPic</html>"); googleSearchBtn.setPreferredSize(new java.awt.Dimension(58, 24)); googleSearchBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { String word = currentWordIndex.trim(); ClipboardUtil.getInstance().setContents(word); word = word.replace(" ", "%20"); URI uri = new URI( "https://www.google.com.tw/search?num=10&hl=zh-TW&site=imghp&tbm=isch&source=hp&biw=1280&bih=696&q=" + word); //URI uri = new URI("http://image.baidu.com/search/index?tn=baiduimage&ps=1&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=" + word); Desktop.getDesktop().browse(uri); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { yahooDicBtn = new JButton(); jPanel5.add(yahooDicBtn); yahooDicBtn.setText("<html>Dict</html>"); yahooDicBtn.setPreferredSize(new java.awt.Dimension(57, 24)); yahooDicBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { // URI uri = new // URI("http://tw.dictionary.yahoo.com/dictionary?p=" // + currentWord.trim()); URI uri = new URI("http://www.dreye.com/axis/ddict.jsp?ver=big5&dod=0102&w=" + currentWordIndex.trim() + "&x=0&y=0"); Desktop.getDesktop().browse(uri); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { pickBtn = new JButton(); jPanel5.add(pickBtn); pickBtn.setText("<html>+Pick</html>"); pickBtn.setPreferredSize(new java.awt.Dimension(60, 24)); pickBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { String key = currentWordIndex; String value = englishProp.getProperty(currentWordIndex); if (StringUtils.isEmpty(value)) { JCommonUtil._jOptionPane_showMessageDialog_error( "add pick failed : no such word => " + key); } else { pickProp.setProperty(key, value); JCommonUtil._jOptionPane_showMessageDialog_info( "key=" + key + "\nvalue=" + value + "\nsize=" + pickProp.size(), "??"); } } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { scanPicBtn = new JButton(); scanPicBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); jPanel5.add(scanPicBtn); scanPicBtn.setPreferredSize(new java.awt.Dimension(46, 24)); scanPicBtn.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (picDir == null) { JCommonUtil._jOptionPane_showMessageDialog_error("picDir is null"); return; } if (picSet != null && picSet.size() > 0) { try { Desktop.getDesktop().open(picSet.iterator().next()); } catch (IOException e) { JCommonUtil.handleException(e); } return; } try { String text = currentWordIndex.trim().toLowerCase(); ClipboardUtil.getInstance().setContents(text); text = text.replace(" ", "%20"); URI uri = new URI( "https://www.google.com.tw/search?num=10&hl=zh-TW&site=imghp&tbm=isch&source=hp&biw=1280&bih=696&q=" + text); //URI uri = new URI("http://image.baidu.com/search/index?tn=baiduimage&ps=1&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=" + text); Desktop.getDesktop().browse(uri); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { showChineseOption = new JCheckBox(); showChineseOption.setSelected(true); jPanel5.add(showChineseOption); } } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("chinese", null, jPanel2, null); jPanel2.setPreferredSize(new java.awt.Dimension(420, 211)); { showEnglishText = new JTextField(); jPanel2.add(showEnglishText, BorderLayout.NORTH); showEnglishText.setEditable(false); } { jPanel10 = new JPanel(); jPanel2.add(jPanel10, BorderLayout.CENTER); } { answerBtn[0] = new JButton(); jPanel10.add(answerBtn[0]); answerBtn[0].setPreferredSize(new java.awt.Dimension(190, 110)); answerBtn[0].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { answerBtnClick(answerBtn[0]); } }); } { answerBtn[1] = new JButton(); jPanel10.add(answerBtn[1]); answerBtn[1].setPreferredSize(new java.awt.Dimension(190, 110)); answerBtn[1].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { answerBtnClick(answerBtn[1]); } }); } { answerBtn[2] = new JButton(); jPanel10.add(answerBtn[2]); answerBtn[2].setPreferredSize(new java.awt.Dimension(190, 110)); answerBtn[2].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { answerBtnClick(answerBtn[2]); } }); } { answerBtn[3] = new JButton(); jPanel10.add(answerBtn[3]); answerBtn[3].setPreferredSize(new java.awt.Dimension(190, 110)); answerBtn[3].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { answerBtnClick(answerBtn[3]); } }); } { for (int ii = 0; ii < 4; ii++) { answerBtn[ii].setFont(new java.awt.Font("", 0, 14)); } } } { jPanel3 = new JPanel(); BorderLayout jPanel3Layout = new BorderLayout(); jPanel3.setLayout(jPanel3Layout); jTabbedPane1.addTab("word", null, jPanel3, null); { jScrollPane3 = new JScrollPane(); jPanel3.add(jScrollPane3, BorderLayout.CENTER); jScrollPane3.setPreferredSize(new java.awt.Dimension(420, 187)); { propTable = new JTable(); jScrollPane3.setViewportView(propTable); JTableUtil.defaultSetting(propTable); propTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { JPopupMenuUtil.newInstance(propTable) .addJMenuItem(JTableUtil.newInstance(propTable).getDefaultJMenuItems()) .applyEvent(evt).show(); } }); } } { saveBtn = new JButton(); jPanel3.add(saveBtn, BorderLayout.SOUTH); saveBtn.setText("save table"); saveBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { DefaultTableModel model = JTableUtil.newInstance(propTable).getModel(); for (int ii = 0; ii < model.getRowCount(); ii++) { String key = (String) model.getValueAt(ii, 0); String value = (String) model.getValueAt(ii, 1); if (!englishProp.containsKey(key)) { englishProp.setProperty(key, value); } } try { englishProp.store(new FileOutputStream(englishFile), "comment"); } catch (Exception e) { e.printStackTrace(); } JCommonUtil._jOptionPane_showMessageDialog_info("save file ok! \n" + englishFile); } }); } { queryText = new JTextField(); jPanel3.add(queryText, BorderLayout.NORTH); queryText.getDocument() .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() { @Override public void process(DocumentEvent event) { String text = JCommonUtil.getDocumentText(event); Pattern pattern = Pattern.compile(text); Matcher matcher = null; DefaultTableModel propTableModel = JTableUtil.createModel(false, "english", "chinese"); for (Enumeration<?> enu = englishProp.propertyNames(); enu .hasMoreElements();) { String key = (String) enu.nextElement(); String value = englishProp.getProperty(key); if (key.contains(text)) { propTableModel.addRow(new Object[] { key, value }); continue; } matcher = pattern.matcher(key); if (matcher.find()) { propTableModel.addRow(new Object[] { key, value }); continue; } } propTable.setModel(propTableModel); } })); } } { jPanel4 = new JPanel(); jTabbedPane1.addTab("config", null, jPanel4, null); { savePickBtn = new JButton(); jPanel4.add(savePickBtn); savePickBtn.setText("save pick"); savePickBtn.setPreferredSize(new java.awt.Dimension(116, 40)); savePickBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (englishFile == null) { File file = new File(// PropertiesUtil.getJarCurrentPath(EnglishTester.class), "temp.properties"); englishFile = file; } if (pickProp.isEmpty()) { JCommonUtil._jOptionPane_showMessageDialog_error("?!"); return; } String fileName = englishFile.getName().replaceAll("\\.properties", "_bak.properties"); File jarWhereFile = PropertiesUtil.getJarCurrentPath(EnglishTester.class); fileName = JCommonUtil._jOptionPane_showInputDialog("save target properties", fileName); if (StringUtils.isEmpty(fileName)) { JCommonUtil._jOptionPane_showMessageDialog_error("can't save!"); return; } if (fileName.equalsIgnoreCase(englishFile.getName())) { JCommonUtil._jOptionPane_showMessageDialog_error( "??englishFile???"); return; } if (!fileName.endsWith(".properties")) { fileName += ".properties"; } File newFile = new File(jarWhereFile, fileName); Properties oldProp = new Properties(); if (newFile.exists()) { try { oldProp.load(new FileInputStream(newFile)); } catch (Exception e) { e.printStackTrace(); } } oldProp.putAll(pickProp); try { oldProp.store(new FileOutputStream(newFile), "comment"); } catch (Exception e) { e.printStackTrace(); } JCommonUtil._jOptionPane_showMessageDialog_info("save file ok! \n" + newFile); } }); } { saveConfigBtn2 = new JButton(); jPanel4.add(saveConfigBtn2); saveConfigBtn2.setText("save config"); saveConfigBtn2.setPreferredSize(new java.awt.Dimension(108, 40)); saveConfigBtn2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveConfigBtnAction(); } }); } { startAllBtn = new JButton(); jPanel4.add(startAllBtn); startAllBtn.setText("start all"); startAllBtn.setPreferredSize(new java.awt.Dimension(101, 40)); startAllBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Object[] files = fileList.getSelectedValues(); if (files == null || files.length == 0) { JCommonUtil ._jOptionPane_showMessageDialog_error("?properties"); return; } Properties allProp = new Properties(); Properties prop = new Properties(); for (Object ff : files) { try { prop.load(new FileInputStream((File) ff)); } catch (Exception e) { JCommonUtil.handleException(e); } allProp.putAll(prop); } englishProp = allProp; System.out.println("englishProp = " + englishProp.size()); startNow(); } }); } { startNow = new JButton(); jPanel4.add(startNow); startNow.setText("start now"); startNow.setPreferredSize(new java.awt.Dimension(101, 40)); startNow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { startNow(); } }); } { picOnly = new JCheckBox(); jPanel4.add(picOnly); picOnly.setText("picOnly"); } { sortChkBox = new JCheckBox(); jPanel4.add(sortChkBox); sortChkBox.setText("sort"); } { showPicChkBox = new JCheckBox(); showPicChkBox.setSelected(true); jPanel4.add(showPicChkBox); showPicChkBox.setText("showPic"); } { JCommonUtil.defaultToolTipDelay(); fontSizeSliber = new JSlider(JSlider.HORIZONTAL); jPanel4.add(fontSizeSliber); fontSizeSliber.setPreferredSize(new java.awt.Dimension(419, 35)); fontSizeSliber.setValue(22); fontSizeSliber.setMinimum(22); fontSizeSliber.setMaximum(300); fontSizeSliber.setMajorTickSpacing(30); fontSizeSliber.setMinorTickSpacing(5); fontSizeSliber.setCursor(new Cursor(Cursor.HAND_CURSOR)); fontSizeSliber.setPaintTicks(false); fontSizeSliber.setPaintLabels(true); { picFolderDirText = new JTextField(); JCommonUtil.jTextFieldSetFilePathMouseEvent(picFolderDirText, true); jPanel4.add(picFolderDirText); picFolderDirText.setColumns(20); } fontSizeSliber.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int size = fontSizeSliber.getValue(); fontSizeSliber.setToolTipText("" + size); englishArea.setFont(new java.awt.Font("Microsoft JhengHei", 0, size)); } }); } } { jPanel6 = new JPanel(); jTabbedPane1.addTab("files", null, jPanel6, null); BorderLayout jPanel6Layout = new BorderLayout(); jPanel6.setLayout(jPanel6Layout); { jScrollPane4 = new JScrollPane(); jPanel6.add(jScrollPane4, BorderLayout.CENTER); jScrollPane4.setPreferredSize(new java.awt.Dimension(420, 211)); { fileList = new JList(); reloadFileList(); jScrollPane4.setViewportView(fileList); fileList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { final File file = JListUtil.getLeadSelectionObject(fileList); if (JMouseEventUtil.buttonRightClick(1, evt)) { JPopupMenuUtil.newInstance(EnglishTester.this.fileList).applyEvent(evt)// .addJMenuItem("reload", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reloadFileList(); } })// .addJMenuItem("delete : " + file.getName(), new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean result = JCommonUtil ._JOptionPane_showConfirmDialog_yesNoOption( "delete : " + file.getName() + " ?", "confirm"); if (result) { file.delete(); reloadFileList(); } }// }).show(); return; } if (evt.getClickCount() == 1) { return; } if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "?,?\n" + file.getName(), "")) { loadEnglishFile(file); } } }); fileList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(fileList).defaultJListKeyPressed(evt); } }); } } } { jPanel9 = new JPanel(); jTabbedPane1.addTab("pic", null, jPanel9, null); { picCheckText = new JTextField(); jPanel9.add(picCheckText); picCheckText.setPreferredSize(new java.awt.Dimension(177, 39)); } { picCheckBtn = new JButton(); jPanel9.add(picCheckBtn); picCheckBtn.setText("check"); picCheckBtn.setPreferredSize(new java.awt.Dimension(98, 43)); { jPanel11 = new JPanel(); jTabbedPane1.addTab("", null, jPanel11, null); jPanel11.setLayout(new BorderLayout(0, 0)); { inputTestArea2 = new JTextArea(); inputTestArea2.setFont(new Font("", Font.PLAIN, 12)); inputTestArea2.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { inputTestTrainer.keyin(e); } }); jPanel11.add(inputTestArea2, BorderLayout.SOUTH); } { inputTestArea1 = new JTextArea(); JTextAreaUtil.setWrapTextArea(inputTestArea1); inputTestArea1.setFont(new Font("", Font.PLAIN, 22)); jPanel11.add(inputTestArea1, BorderLayout.CENTER); } { panel = new JPanel(); jPanel11.add(panel, BorderLayout.NORTH); { inputTestLabel = new JLabel(""); panel.add(inputTestLabel); } { inputTestChk = new JCheckBox(""); inputTestChk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { inputTestTrainer.initQuestion(); } }); panel.add(inputTestChk); } } } picCheckBtn.addActionListener(new ActionListener() { void scanPic(String searchWord, File file, Set<File> findFile) { if (file.isDirectory()) { File[] list = null; if ((list = file.listFiles()) != null) { for (File f : list) { scanPic(searchWord, f, findFile); } } } else { String text = searchWord; String name = file.getName().toLowerCase(); if (isMatch(name, text)) { findFile.add(file); } } } public void actionPerformed(ActionEvent evt) { picDir = new File(picFolderDirText.getText()); if (picDir == null) { JCommonUtil._jOptionPane_showMessageDialog_error("picDir is null"); return; } if (!picDir.exists() || !picDir.isDirectory()) { JCommonUtil._jOptionPane_showMessageDialog_error("picDir "); return; } picCheckBtn.setText("search.."); String searchWord = picCheckText.getText().toLowerCase().trim(); Set<File> picSet2 = new HashSet<File>(); scanPic(searchWord, picDir, picSet2); if (picSet2 != null && picSet2.size() > 0) { picCheckBtn.setText("" + picSet2.size()); try { Desktop.getDesktop().open(picSet2.iterator().next()); } catch (IOException e) { JCommonUtil.handleException(e); } } else { picCheckBtn.setText("0"); } } }); } } } JCommonUtil.setJFrameIcon(this, "resource/images/ico/english_tester.ico"); pack(); this.setSize(423, 314); configHelper.init(); } catch (Exception e) { // add your error handling code here e.printStackTrace(); } }
From source file:io.heming.accountbook.ui.MainFrame.java
public MainFrame() throws Exception { categoryFacade = new CategoryFacade(); recordFacade = new RecordFacade(); builder = new Pages.Builder(); builder.order("id", false); pages = builder.make();/*from ww w . jav a 2 s .c o m*/ date_chooser_visible = false; disable = false; // Create widgets model = new TableModel(); table = new JTable(model) { /** * tip. * * @param evt * @return */ @Override public String getToolTipText(MouseEvent evt) { String tip = null; java.awt.Point point = evt.getPoint(); int row = rowAtPoint(point); int col = columnAtPoint(point); Rectangle bounds = getCellRect(row, col, false); Component comp = prepareRenderer(getCellRenderer(row, col), row, col); try { if (comp.getPreferredSize().width > bounds.width) { tip = getValueAt(row, col).toString(); } } catch (RuntimeException e) { //catch null pointer exception if mouse is over an empty line } return tip; } }; if (pages.hasNext()) { model.setRecords(pages.next()); } // ? table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); TableColumnModel columnModel = table.getColumnModel(); columnModel.getColumn(0).setPreferredWidth(80); columnModel.getColumn(1).setPreferredWidth(160); columnModel.getColumn(2).setPreferredWidth(80); columnModel.getColumn(3).setPreferredWidth(100); columnModel.getColumn(4).setPreferredWidth(100); columnModel.getColumn(5).setPreferredWidth(360); // Layout JScrollPane pane = new JScrollPane(table); add(pane, BorderLayout.CENTER); table.getTableHeader().setReorderingAllowed(false); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // table header table.getTableHeader().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int col = table.columnAtPoint(e.getPoint()); String name = table.getColumnName(col); // TODO } }); // ? addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { quit(); } }); categories = categoryFacade.listBySale(); initMenuBar(); initToolBar(); initStatusBar(); initTablePopupMenu(); searchRecords(); setIconImage(new ImageIcon(getClass().getResource("64.png")).getImage()); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setTitle(""); setSize(860, 620); }
From source file:de.tor.tribes.ui.views.DSWorkbenchRankFrame.java
private void buildMenu() { JXTaskPane statsTaskPane = new JXTaskPane(); statsTaskPane.setTitle("Statistiken"); JXButton openDSRealButton = new JXButton( new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/dsreal.png"))); openDSRealButton.setToolTipText("DS Real Seite im Browser ffnen"); openDSRealButton.addMouseListener(new MouseAdapter() { @Override//from w w w .j a va 2 s .c o m public void mouseReleased(MouseEvent e) { RankTableTab activeTab = getActiveTab(); if (activeTab != null) { activeTab.openDSReal(); } } }); statsTaskPane.getContentPane().add(openDSRealButton); JXButton dsRealStatsButton = new JXButton( new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/chart.png"))); dsRealStatsButton.setToolTipText("DS Real Verlaufsgrafik anzeigen"); dsRealStatsButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { RankTableTab activeTab = getActiveTab(); if (activeTab != null) { activeTab.showDSRealChart(); } } }); statsTaskPane.getContentPane().add(dsRealStatsButton); centerPanel.setupTaskPane(statsTaskPane); }
From source file:io.gameover.utilities.pixeleditor.Pixelizer.java
public JProgressBar getToleranceBar() { if (toleranceBar == null) { toleranceBar = new JProgressBar(); toleranceBar.setPreferredSize(new Dimension(200, 25)); toleranceBar.setValue(10);/*from w ww . j a v a 2 s. com*/ toleranceBar.setMaximum(100); toleranceBar.setStringPainted(true); toleranceBar.addMouseListener(new MouseAdapter() { public boolean mouseEntered = false; @Override public void mouseReleased(MouseEvent e) { if (mouseEntered) { JProgressBar pb = (JProgressBar) e.getComponent(); pb.setValue((int) ((((double) e.getX()) / pb.getSize().getWidth()) * 100d)); pb.updateUI(); } } @Override public void mouseEntered(MouseEvent e) { this.mouseEntered = true; } @Override public void mouseExited(MouseEvent e) { this.mouseEntered = false; } }); } return toleranceBar; }
From source file:edu.ku.brc.specify.tasks.subpane.wb.FormPane.java
/** * Creates all the UI form the Form. // w w w . j ava 2 s. co m */ protected void buildUI() { headers.addAll(workbench.getWorkbenchTemplate().getWorkbenchTemplateMappingItems()); Collections.sort(headers); MouseAdapter clickable = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { selectControl(e.getSource()); } @Override public void mouseClicked(MouseEvent e) { selectedInputPanel = getInputPanel(e.getSource()); controlPropsBtn.setEnabled(true); if (controlPropsDlg != null) { controlPropsDlg.setControl(selectedInputPanel); } if (e.getClickCount() == 2 && (controlPropsDlg == null || !controlPropsDlg.isVisible())) { UsageTracker.incrUsageCount("WB.FormPropsTool"); showControlProps(); } } }; Point topLeftPnt = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE); final int LAYOUT_SPACING = 4; short maxY = 0; Vector<InputPanel> delayedLayout = new Vector<InputPanel>(); int maxWidthOffset = 0; for (WorkbenchTemplateMappingItem wbtmi : headers) { // Create the InputPanel and make it draggable InputPanel panel = new InputPanel(wbtmi, wbtmi.getCaption(), createUIComp(wbtmi), this, clickable); Dimension size = panel.getPreferredSize(); panel.setSize(size); panel.setPreferredSize(size); // Finds the largest label maxWidthOffset = Math.max(panel.getTextFieldOffset(), maxWidthOffset); int x = wbtmi.getXCoord(); int y = wbtmi.getYCoord(); if (y < topLeftPnt.y || (y == topLeftPnt.y && x < topLeftPnt.x)) { firstComp = panel.getComp(); topLeftPnt.setLocation(x, y); } // Add it to the Form (drag canvas) uiComps.add(panel); add(panel); // NOTE: that the constructor sets the x,y storage from WorkbenchTemplateMappingItem object // so the ones with XCoord and YCoord set do not need to be positioned if (wbtmi.getXCoord() == null || wbtmi.getYCoord() == null || wbtmi.getXCoord() == -1 || wbtmi.getYCoord() == -1) { delayedLayout.add(panel); // remember this for later once we know the Max Y } else { maxY = (short) Math.max(wbtmi.getYCoord() + size.height, maxY); } } // Now align the control by their text fields and skips the ones that have actual positions defined. // NOTE: We set the X,Y into the Mapping so that each item knows where it is, then if the user // drags and drop anything or save the template everyone knows where they are suppose to be // int inx = 0; int maxX = 0; int y = maxY + LAYOUT_SPACING; for (InputPanel panel : uiComps) { WorkbenchTemplateMappingItem wbtmi = headers.get(inx); if (delayedLayout.contains(panel)) { int x = maxWidthOffset - panel.getTextFieldOffset(); panel.setLocation(x, y); wbtmi.setXCoord((short) x); wbtmi.setYCoord((short) y); Dimension size = panel.getPreferredSize(); y += size.height + LAYOUT_SPACING; } Rectangle r = panel.getBounds(); maxX = Math.max(maxX, r.x + r.width); inx++; } initialSize = new Dimension(maxX, y); controlPropsBtn = createIconBtn("ControlEdit", IconManager.IconSize.NonStd, "WB_EDIT_CONTROL", false, new ActionListener() { public void actionPerformed(ActionEvent ae) { UsageTracker.getUsageCount("WBFormPropsTool"); showControlProps(); } }); addArrowTraversalKeys(); }
From source file:net.sourceforge.entrainer.gui.socket.EntrainerSocketConnector.java
private void init() { initConnector();/* ww w . ja v a 2 s .c o m*/ initListeners(); wireSliders(); initGui(); addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.isControlDown() && e.getClickCount() == 1) { openBrowser(getLocalDocAddress()); } } }); }
From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java
/** * System Tray Icon setup/*from w w w. ja v a 2 s .c o m*/ * @param frame owner JFrame */ private void setupTrayIcon(final JFrame frame) { // Idle Icon idleIcon = Toolkit.getDefaultToolkit() .getImage(ClassLoader.getSystemResource("META-INF/resources/cluster_inactive.png")); // Active Icon activeIcon = Toolkit.getDefaultToolkit() .getImage(ClassLoader.getSystemResource("META-INF/resources/cluster_active.png")); frame.setIconImage(idleIcon); // If system tray is supported by OS if (SystemTray.isSupported()) { // Set Icon trayIcon = new TrayIcon(idleIcon, "Nebula Grid Cluster", createTrayPopup()); trayIcon.setImageAutoSize(true); trayIcon.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (!frame.isVisible()) { frame.setVisible(true); } frame.setExtendedState(JFrame.NORMAL); frame.requestFocus(); frame.toFront(); } } }); try { SystemTray.getSystemTray().add(trayIcon); } catch (AWTException ae) { log.debug("[UI] Unable to Initialize Tray Icon"); return; } frame.addWindowListener(new WindowAdapter() { @Override public void windowIconified(WindowEvent e) { // Hide (can be shown using tray icon) frame.setVisible(false); } }); } }