Example usage for java.awt.datatransfer DataFlavor getSubType

List of usage examples for java.awt.datatransfer DataFlavor getSubType

Introduction

In this page you can find the example usage for java.awt.datatransfer DataFlavor getSubType.

Prototype

public String getSubType() 

Source Link

Document

Returns the sub MIME type of this DataFlavor .

Usage

From source file:Main.java

public static void main(String[] args) {

    DataFlavor df = DataFlavor.stringFlavor;

    System.out.println(df.getSubType());
}

From source file:MainClass.java

public static void main(String[] args) {

    DataFlavor df = DataFlavor.stringFlavor;

    System.out.println("Mime type: " + df.getMimeType());
    System.out.println("Primary type: " + df.getPrimaryType());
    System.out.println("Subtype: " + df.getSubType());
    System.out.println("Name: " + df.getHumanPresentableName());
    String s = df.getRepresentationClass().toString();
    System.out.println("Representation class: " + s + "\n");

    df = DataFlavor.javaFileListFlavor;

    System.out.println("Mime type: " + df.getMimeType());
    System.out.println("Primary type: " + df.getPrimaryType());
    System.out.println("Subtype: " + df.getSubType());
    System.out.println("Name: " + df.getHumanPresentableName());
    s = df.getRepresentationClass().toString();
    System.out.println("Representation class: " + s);
}

From source file:MainClass.java

public static void main(String[] args) {

    DataFlavor df1 = new DataFlavor("text/plain; charset=ASCII", "Plain ASCII text");

    DataFlavor df2 = new DataFlavor(java.awt.Button.class, "AWT Button");

    System.out.println("Mime type: " + df2.getMimeType());
    System.out.println("Primary type: " + df2.getPrimaryType());
    System.out.println("Subtype: " + df2.getSubType());
    System.out.println("Name: " + df2.getHumanPresentableName());
    String s = df2.getRepresentationClass().toString();
    System.out.println("Representation class: " + s + "\n");

    System.out.println("df1 equals df2: " + df1.isMimeTypeEqual(df2));
}

From source file:MainClass.java

public static void main(String[] args) {

    DataFlavor df = new DataFlavor("text/plain; charset=ASCII", "Plain ASCII text");

    System.out.println("Mime type: " + df.getMimeType());
    System.out.println("Primary type: " + df.getPrimaryType());
    System.out.println("Subtype: " + df.getSubType());
    System.out.println("Parameter: " + df.getParameter("charset"));
    System.out.println("Name: " + df.getHumanPresentableName());
    String s = df.getRepresentationClass().toString();
    System.out.println("Representation class: " + s + "\n");

}

From source file:SerialTransferTest.java

public boolean isDataFlavorSupported(DataFlavor flavor) {
    return DataFlavor.stringFlavor.equals(flavor) || "application".equals(flavor.getPrimaryType())
            && "x-java-serialized-object".equals(flavor.getSubType())
            && flavor.getRepresentationClass().isAssignableFrom(obj.getClass());
}

From source file:com.raddle.tools.ClipboardTransferMain.java

private void setRemoteClipboard(boolean alert) {
    if (!isProcessing) {
        isProcessing = true;/* w  w w.  j  a  v a  2s  .c  om*/
        try {
            Clipboard sysc = Toolkit.getDefaultToolkit().getSystemClipboard();
            Transferable clipT = sysc.getContents(null);
            if (alert && !ClipboardUtils.isClipboardNotEmpty(clipT)) {
                updateMessage("?");
                return;
            }
            updateMessage("???");
            trayIcon.setImage(sendImage);
            final BooleanHolder success = new BooleanHolder();
            doInSocket(new SocketCallback() {

                @Override
                public Object connected(Socket socket) throws Exception {
                    ClipCommand cmd = new ClipCommand();
                    cmd.setCmdCode(ClipCommand.CMD_SET_CLIP);
                    cmd.setResult(ClipboardUtils.getClipResult());
                    // ??
                    ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
                    out.writeObject(cmd);
                    // 
                    ObjectInputStream in = new ObjectInputStream(socket.getInputStream());
                    ClipResult result = (ClipResult) in.readObject();
                    if (result.isSuccess()) {
                        StringBuilder sb = new StringBuilder();
                        for (DataFlavor dataFlavor : cmd.getResult().getClipdata().keySet()) {
                            sb.append("\n");
                            sb.append(dataFlavor.getPrimaryType()).append("/").append(dataFlavor.getSubType());
                        }
                        iconQueue.add("send");
                        success.value = true;
                        updateMessage("????? " + sb);
                    } else {
                        updateMessage("???:" + result.getMessage());
                    }
                    in.close();
                    out.close();
                    return null;
                }
            });
            if (!success.value) {
                trayIcon.setImage(grayImage);
            }
        } catch (Exception e) {
            trayIcon.setImage(grayImage);
            updateMessage("???" + e.getMessage());
        } finally {
            isProcessing = false;
        }
    }
}

From source file:com.raddle.tools.ClipboardTransferMain.java

private void initGUI() {
    try {/*from www .  j ava2s .c  o m*/
        {
            this.setTitle("\u8fdc\u7a0b\u526a\u5207\u677f");
            getContentPane().setLayout(null);
            {
                remoteClipGetBtn = new JButton();
                getContentPane().add(remoteClipGetBtn);
                remoteClipGetBtn.setText("\u83b7\u5f97\u8fdc\u7a0b\u526a\u5207\u677f");
                remoteClipGetBtn.setBounds(12, 22, 151, 29);
                remoteClipGetBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        doInSocket(new SocketCallback() {

                            @Override
                            public Object connected(Socket socket) throws Exception {
                                if (!isProcessing) {
                                    isProcessing = true;
                                    try {
                                        ClipCommand cmd = new ClipCommand();
                                        cmd.setCmdCode(ClipCommand.CMD_GET_CLIP);
                                        updateMessage("??");
                                        // ??
                                        ObjectOutputStream out = new ObjectOutputStream(
                                                socket.getOutputStream());
                                        out.writeObject(cmd);
                                        // 
                                        ObjectInputStream in = new ObjectInputStream(socket.getInputStream());
                                        ClipResult result = (ClipResult) in.readObject();
                                        if (result.isSuccess()) {
                                            setLocalClipboard(result);
                                            StringBuilder sb = new StringBuilder();
                                            for (DataFlavor dataFlavor : result.getClipdata().keySet()) {
                                                sb.append("\n");
                                                sb.append(dataFlavor.getPrimaryType()).append("/")
                                                        .append(dataFlavor.getSubType());
                                            }
                                            updateMessage("??? " + sb);
                                        } else {
                                            updateMessage("?:" + result.getMessage());
                                        }
                                        in.close();
                                        out.close();
                                    } catch (Exception e) {
                                        updateMessage("?:" + e.getMessage());
                                    } finally {
                                        isProcessing = false;
                                    }
                                }
                                return null;
                            }
                        });
                    }
                });
            }
            {
                remoteClipSetBtn = new JButton();
                getContentPane().add(remoteClipSetBtn);
                remoteClipSetBtn.setText("\u8bbe\u7f6e\u8fdc\u7a0b\u526a\u5207\u677f");
                remoteClipSetBtn.setBounds(181, 22, 159, 29);
                remoteClipSetBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        setRemoteClipboard(true);
                    }
                });
            }
            {
                serverLeb = new JLabel();
                getContentPane().add(serverLeb);
                serverLeb.setText("\u8fdc\u7a0b\u670d\u52a1\u5668\u5730\u5740(IP:PORT)");
                serverLeb.setBounds(12, 63, 162, 17);
            }
            {
                serverAddrTxt = new JTextField();
                getContentPane().add(serverAddrTxt);
                serverAddrTxt.setBounds(169, 58, 186, 27);
            }
            {
                jLabel1 = new JLabel();
                getContentPane().add(jLabel1);
                jLabel1.setText("\u6d88\u606f\uff1a");
                jLabel1.setBounds(12, 97, 48, 24);
            }
            {
                jLabel2 = new JLabel();
                getContentPane().add(jLabel2);
                jLabel2.setText("\u672c\u5730\u526a\u5207\u677f\u670d\u52a1");
                jLabel2.setBounds(12, 297, 91, 20);
            }
            {
                clipServerStartBtn = new JButton();
                getContentPane().add(clipServerStartBtn);
                clipServerStartBtn.setText("\u542f\u52a8");
                clipServerStartBtn.setBounds(12, 329, 79, 29);
                clipServerStartBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        startServer();
                    }
                });
            }
            {
                clipServerStopBtn = new JButton();
                getContentPane().add(clipServerStopBtn);
                clipServerStopBtn.setText("\u505c\u6b62");
                clipServerStopBtn.setBounds(103, 329, 81, 29);
                clipServerStopBtn.setEnabled(false);
                clipServerStopBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        shutdown();
                    }
                });
            }
            {
                jLabel3 = new JLabel();
                getContentPane().add(jLabel3);
                jLabel3.setText("\u7aef\u53e3\uff1a");
                jLabel3.setBounds(196, 335, 44, 17);
            }
            {
                portTxt = new JTextField();
                getContentPane().add(portTxt);
                portTxt.setText("11221");
                portTxt.setBounds(252, 330, 88, 27);
            }
            {
                modifyClipChk = new JCheckBox();
                getContentPane().add(modifyClipChk);
                modifyClipChk.setText("\u5141\u8bb8\u8fdc\u7a0b\u4fee\u6539\u526a\u5207\u677f");
                modifyClipChk.setBounds(12, 377, 172, 22);
            }
            {
                clearBtn = new JButton();
                getContentPane().add(clearBtn);
                clearBtn.setText("\u6e05\u7a7a\u672c\u5730\u7cfb\u7edf\u526a\u5207\u677f");
                clearBtn.setBounds(196, 374, 159, 29);
                clearBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        Clipboard sysc = Toolkit.getDefaultToolkit().getSystemClipboard();
                        Transferable tText = new StringSelection(null);
                        sysc.setContents(tText, null);
                    }
                });
            }
            {
                autoChk = new JCheckBox();
                autoChk.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        m.setEnabled(autoChk.isSelected());
                    }
                });
                getContentPane().add(autoChk);
                autoChk.setText("\u81ea\u52a8\u8bbe\u7f6e\u8fdc\u7a0b\u526a\u5207\u677f");
                autoChk.setBounds(12, 405, 172, 22);
            }
        }

        JScrollPane scrollPane = new JScrollPane();
        scrollPane.setBounds(55, 97, 542, 199);
        getContentPane().add(scrollPane);
        {
            messageArea = new JTextArea();
            scrollPane.setViewportView(messageArea);
        }
        this.setSize(611, 465);
        {
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.wings.STransferHandler.java

private DataFlavor getPropertyDataFlavor(Class<?> argument, DataFlavor[] flavors) {
    for (DataFlavor flavor : flavors) {
        if ("application".equals(flavor.getPrimaryType())
                && "x-java-jvm-local-objectref".equals(flavor.getSubType())) {
            if (argument.isAssignableFrom(flavor.getRepresentationClass())) {
                return flavor;
            }/*from  w w  w .j  a va 2s . co  m*/
        }
    }

    return null;
}