Package javax.swing

Examples of javax.swing.TransferHandler$DragHandler


            //official beginning of a drag.
            if (dx > 5 || dy > 5) {
                //This is a drag, not a click.
                JComponent c = (JComponent)e.getSource();
                //Tell the transfer handler to initiate the drag.
                TransferHandler handler = c.getTransferHandler();
                handler.exportAsDrag(c, firstMouseEvent, action);
                firstMouseEvent = null;
            }
        }
    }
View Full Code Here


            myMenu.setEnabled(false);
           
        } else {
            // 傷病名Tree、テーブル、ハンドラからメニューを構築する
            JComponent comp = diagnosis.getDiagnosisTable();
            TransferHandler handler = comp.getTransferHandler();
            StampTreeMenuBuilder builder = new StampTreeMenuBuilder();
            myMenu = builder.build(stampTree, comp, handler);
        }
        return myMenu;
    }
View Full Code Here

            //
            JComponent comp = getCurrentComponent();
            if (comp == null) {
                comp = kartePane.getTextPane();
            }
            TransferHandler handler = comp.getTransferHandler();
            StampTreeMenuBuilder builder = new StampTreeMenuBuilder();
            myMenu = builder.build(stampTree, comp, handler);
        }
       
        return myMenu;
View Full Code Here

            myMenu.setEnabled(false);
           
        } else {
            // StampTree、JTextPane、Handler からメニューを構築する
            JComponent comp = kartePane.getTextPane();
            TransferHandler handler = comp.getTransferHandler();
            StampTreeMenuBuilder builder = new StampTreeMenuBuilder();
            myMenu = builder.build(stampTree, comp, handler);
        }
        return myMenu;
    }
View Full Code Here

                myMenu.setEnabled(false);
                popup.add(myMenu);
                return;
            } else {
                JComponent comp = diagnosis.getDiagnosisTable();
                TransferHandler handler = comp.getTransferHandler();
                StampTreePopupBuilder builder = new StampTreePopupBuilder();
                builder.build(stampTree, popup, comp, handler);
            }
        }
    }
View Full Code Here

            } else {
                JComponent comp = getCurrentComponent();
                if (comp == null) {
                    comp = kartePane.getTextPane();
                }
                TransferHandler handler = comp.getTransferHandler();
                StampTreePopupBuilder builder = new StampTreePopupBuilder();
                builder.build(stampTree, popup, comp, handler);
            }
        }
    }
View Full Code Here

            List<StampTree> trees = stampBox.getAllTrees();
           
            StampTreeMenuBuilder builder = new StampTreeMenuBuilder();
            JComponent cmp = kartePane.getTextPane();
            TransferHandler handler = cmp.getTransferHandler();
           
            // StampBox内の全Treeをイテレートする
            for (StampTree stampTree : trees) {
               
                // 傷病名とテキストは別に作成するのでスキップする
View Full Code Here

        table.setDefaultRenderer(String.class, new StringRenderer());

        // drag-and-drop initialization
        table.setDragEnabled(true);

        table.setTransferHandler(new TransferHandler() {

            @Override
            protected Transferable createTransferable(JComponent c) {
                int rowIndex = table.getSelectedRow();
View Full Code Here

                      .setPreferredSize(new java.awt.Dimension(
                          110, 25));
                  jMetricsIDTextField.setEditable(false);
                  jMetricsIDTextField.setBackground(COLOR_DEACTIVATED);
                  jMetricsIDTextField.setForeground(Color.DARK_GRAY);
                  jMetricsIDTextField.setTransferHandler(new TransferHandler() {
                    private static final long serialVersionUID = 8700297967169121889L;

                    public boolean canImport(
                        TransferHandler.TransferSupport support) {
                        return false;
                    }
                  });
                  jMetricsIDTextField.getDocument().addDocumentListener(new MetricsBuilderListener());
                }
                {
                  jMetricsNameTextField = new WatermarkedJTextField(Messages.getString("MetricsBuilder.Watermarks.Name"));
                  jPanelMBNorth.add(jMetricsNameTextField);
                  jMetricsNameTextField
                      .setPreferredSize(new java.awt.Dimension(
                          236, 25));
                  jMetricsNameTextField.setTransferHandler(new TransferHandler(){
                    private static final long serialVersionUID = 973043666511565759L;

                    public boolean canImport(
                        TransferHandler.TransferSupport support) {
                        return false;
                    }
                  });
                  jMetricsNameTextField.getDocument().addDocumentListener(new MetricsBuilderListener());
                }
                }
                }
              {
                jPanelMBNorthCenter = new JPanel();
                BorderLayout jPanelMBNorthCenterLayout = new BorderLayout();
                jPanelMBNorthCenterLayout.setVgap(3);
                jPanelMBNorthCenterLayout.setHgap(5);
                jPanelMBNorthCenter.setLayout(jPanelMBNorthCenterLayout);
                jPanelId.add(jPanelMBNorthCenter,
                    BorderLayout.SOUTH);
                jPanelMBNorthCenter.setPreferredSize(new java.awt.Dimension(395, 123));
                jPanelMBNorthCenter.setSize(395, 120);
                {
                  jMetricsDescriptionTextField = new WatermarkedJTextField(Messages.getString("MetricsBuilder.Watermarks.Description"));
                  jPanelMBNorthCenter.add(jMetricsDescriptionTextField, BorderLayout.NORTH);
                  jMetricsDescriptionTextField.setPreferredSize(new java.awt.Dimension(395, 68));
                  jMetricsDescriptionTextField.setSize(395, 68);
                  jMetricsDescriptionTextField.setTransferHandler(new TransferHandler() {
                    private static final long serialVersionUID = 8700297967169121889L;

                    public boolean canImport(
                        TransferHandler.TransferSupport support) {
                        return false;
                    }
                  });
                  jMetricsDescriptionTextField.getDocument().addDocumentListener(new MetricsBuilderListener());
                }
                {
                  jMetricsFormulaTextField = new WatermarkedJTextField(Messages.getString("MetricsBuilder.Watermarks.Formula"));
                  jPanelMBNorthCenter.add(jMetricsFormulaTextField, BorderLayout.CENTER);
                  jMetricsFormulaTextField.setPreferredSize(new java.awt.Dimension(395, 25));
                  jMetricsFormulaTextField
                      .setDropMode(DropMode.USE_SELECTION);
                  jMetricsFormulaTextField
                      .setTransferHandler(new TransferHandler() {
                        private static final long serialVersionUID = -5435327025028911097L;

                        public boolean canImport(
                            TransferHandler.TransferSupport support) {
                          if (!support
                              .isDataFlavorSupported(DataFlavor.stringFlavor) ||
                              !jMetricsFormulaTextField.isEditable())
                            return false;
                          else if(!support.getDropLocation().equals(jMetricsDescriptionTextField))
                            return true;
                          else
                            return false;
                        }

                        public boolean importData(
                            TransferHandler.TransferSupport support) {
                          if (!canImport(support))
                            return false;

                          Transferable transferable = support
                              .getTransferable();
                          String data;
                          try {
                            data = (String) transferable
                                .getTransferData(DataFlavor.stringFlavor);
                          } catch (Exception e) {
                            return false;
                          }
                         
                          if(ConfigurationManager.getConfiguration().isShowNamesInBuilder())
                            data = MetricsUIRequestHandler.algorithmNameToID(data);

                          JTextField.DropLocation dl = (JTextField.DropLocation) support
                              .getDropLocation();
                          int index = dl.getIndex();

                          String oldText = jMetricsFormulaTextField.getText();
                         
                          if(!oldText.equals(Messages.getString("MetricsBuilder.Watermarks.Formula"))) {
                            String firstPart = oldText.substring(0, index);
                            // If the last character is a blank remove it
                            if(firstPart.length() > 0 && firstPart.substring(firstPart.length() - 1, firstPart.length()).equals(" "))
                              firstPart = firstPart.substring(0, firstPart.length() - 1);
                           
                            String secondPart = oldText.substring(index, oldText.length());
                            // If the first character is a blank remove it
                            if(secondPart.length() > 0 && secondPart.substring(0, 1).equals(" "))
                              secondPart = secondPart.substring(1);
                       
                            jMetricsFormulaTextField
                                .setText(firstPart
                                    + " "
                                    + data
                                    + " "
                                    + secondPart);
                           
                            // If formula now starts with a blank remove that blank
                            if(jMetricsFormulaTextField.getText().length() > 0 &&
                                jMetricsFormulaTextField.getText().substring(0, 1).equals(" "))
                              jMetricsFormulaTextField.setText(jMetricsFormulaTextField.getText().substring(1));
                            return true;
                          } else {
                            jMetricsFormulaTextField.setText(data);
                            return true;
                          }
                        }
                      });
                  jMetricsFormulaTextField.getDocument().addDocumentListener(new MetricsBuilderListener());
                }
                {
                  jPanel8 = new JPanel();
                  GridBagLayout jPanel8Layout = new GridBagLayout();
                  jPanelMBNorthCenter.add(jPanel8, BorderLayout.SOUTH);
                  jPanel8.setPreferredSize(new java.awt.Dimension(395, 25));
                  jPanel8Layout.rowWeights = new double[] {0.1};
                  jPanel8Layout.rowHeights = new int[] {1};
                  jPanel8Layout.columnWeights = new double[] {1.0, 0.01};
                  jPanel8Layout.columnWidths = new int[] {7, 1};
                  jPanel8.setLayout(jPanel8Layout);
                  {
                    jOpenFileChooserButton = new JButton();
                    jPanel8.add(jOpenFileChooserButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
                    jOpenFileChooserButton.setText("...");
                  }
                  {
                    jMetricsFilePathTextField = new JTextField();
                    jPanel8.add(jMetricsFilePathTextField, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
//                    jMetricsFilePathTextField.setText("C:\\");
                    jMetricsFilePathTextField.setPreferredSize(new java.awt.Dimension(391, 25));
                    jMetricsFilePathTextField.setSize(338, 25);
                    jMetricsFilePathTextField.setEnabled(false);
                    jMetricsFilePathTextField.setTransferHandler(new TransferHandler() {
                      private static final long serialVersionUID = 6507240735372523805L;

                      public boolean canImport(
                          TransferHandler.TransferSupport support) {
                          return false;
View Full Code Here

    protected void startDragging(MouseEvent event) {
      isDragging = true;
      if (graph.isDragEnabled()) {
        int action = (event.isControlDown() && graph.isCloneable()) ? TransferHandler.COPY
            : TransferHandler.MOVE;
        TransferHandler th = graph.getTransferHandler();
        setInsertionLocation(event.getPoint());
        try {
          th.exportAsDrag(graph, event, action);
        } catch (Exception ex) {
          // Ignore
        }
      }
    }
View Full Code Here

TOP

Related Classes of javax.swing.TransferHandler$DragHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.