Search in sources :

Example 51 with MouseListener

use of java.awt.event.MouseListener in project java-swing-tips by aterai.

the class LabelTransferable method createAndShowGui.

private static void createAndShowGui() {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
        ex.printStackTrace();
        Toolkit.getDefaultToolkit().beep();
    }
    JFrame f1 = new JFrame("@title@");
    JFrame f2 = new JFrame();
    f1.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    f2.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    DragPanel p1 = new DragPanel();
    DragPanel p2 = new DragPanel();
    p1.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    p2.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    p1.add(new JLabel(UIManager.getIcon("OptionPane.warningIcon")));
    p1.add(new JLabel(UIManager.getIcon("OptionPane.questionIcon")));
    p1.add(new JLabel(UIManager.getIcon("OptionPane.informationIcon")));
    p1.add(new JLabel(UIManager.getIcon("OptionPane.errorIcon")));
    p1.add(new JLabel("Text"));
    MouseListener handler = new Handler();
    p1.addMouseListener(handler);
    p2.addMouseListener(handler);
    LabelTransferHandler th = new LabelTransferHandler();
    p1.setTransferHandler(th);
    p2.setTransferHandler(th);
    JPanel p = new JPanel(new GridLayout(2, 1));
    p.add(new JScrollPane(new JTextArea()));
    p.add(p2);
    f1.getContentPane().add(p1);
    f2.getContentPane().add(p);
    f1.setSize(320, 240);
    f2.setSize(320, 240);
    f1.setLocationRelativeTo(null);
    Point pt = f1.getLocation();
    pt.translate(340, 0);
    f2.setLocation(pt);
    f1.setVisible(true);
    f2.setVisible(true);
}
Also used : MouseListener(java.awt.event.MouseListener)

Example 52 with MouseListener

use of java.awt.event.MouseListener in project jPOS by jpos.

the class ISOMeter method createLogList.

public JComponent createLogList() {
    final JList logList = new JList(parent.getLog());
    JPanel A = new JPanel();
    A.setLayout(new BorderLayout());
    MouseListener mouseListener = new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            ISOMsg m = (ISOMsg) logList.getSelectedValue();
            if (m != null) {
                JFrame f = new JFrame(parent.getSymbolicName() + ":" + m.toString());
                ISOMsgPanel p = new ISOMsgPanel(m);
                f.getContentPane().add(p);
                f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                f.pack();
                f.show();
            }
        }
    };
    logList.addMouseListener(mouseListener);
    logList.setPrototypeCellValue("9999 99999999 999999");
    JScrollPane scrollPane = new JScrollPane(logList);
    A.add(scrollPane, BorderLayout.CENTER);
    return A;
}
Also used : MouseListener(java.awt.event.MouseListener) MouseEvent(java.awt.event.MouseEvent) ISOMsg(org.jpos.iso.ISOMsg) MouseAdapter(java.awt.event.MouseAdapter)

Example 53 with MouseListener

use of java.awt.event.MouseListener in project ginkgo-jdbc by georgeworld.

the class JdbcMain method main.

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    JFrame mainFrame = new JFrame();
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setTitle("Ginkgo-JDBC");
    mainFrame.setSize(599, 300);
    mainFrame.setLayout(new java.awt.BorderLayout());
    JLabel topLabel = new JLabel("银杏树精简 JDBC 框架 " + getVersion());
    topLabel.setFont(new java.awt.Font("宋体", 1, 18));
    topLabel.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED, new java.awt.Color(0, 102, 102), new java.awt.Color(0, 204, 204)));
    JLabel bottomLabel = new JLabel("(C)www.georgeinfo.com");
    bottomLabel.addMouseListener(new MouseListener() {

        public void mouseClicked(MouseEvent e) {
            openUrl("http://www.georgeinfo.com");
        }

        public void mousePressed(MouseEvent e) {
        // openUrl("http://www.georgeinfo.com");
        }

        public void mouseReleased(MouseEvent e) {
        // throw new UnsupportedOperationException("Not supported yet.");
        }

        public void mouseEntered(MouseEvent e) {
        // throw new UnsupportedOperationException("Not supported yet.");
        }

        public void mouseExited(MouseEvent e) {
        // throw new UnsupportedOperationException("Not supported yet.");
        }
    });
    bottomLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    bottomLabel.setForeground(Color.BLUE);
    // JTextArea changeLogArea = new JTextArea();
    // changeLogArea.setText(IrapidCommentsTool.getCommentsString(IrapidMain.class));
    // changeLogArea.setFont(new java.awt.Font("宋体", 0, 18));
    // JScrollPane mainScrollPane = new JScrollPane();
    // mainScrollPane.setViewportView(changeLogArea);
    mainFrame.add(topLabel, java.awt.BorderLayout.NORTH);
    mainFrame.add(new JdbcChangeLogPanel(JdbcMain.class), java.awt.BorderLayout.CENTER);
    mainFrame.add(bottomLabel, java.awt.BorderLayout.SOUTH);
    mainFrame.setAlwaysOnTop(true);
    setWindowCenter(mainFrame);
    mainFrame.setVisible(true);
}
Also used : MouseListener(java.awt.event.MouseListener) MouseEvent(java.awt.event.MouseEvent) JFrame(javax.swing.JFrame) Color(java.awt.Color) JLabel(javax.swing.JLabel) Cursor(java.awt.Cursor)

Example 54 with MouseListener

use of java.awt.event.MouseListener in project drools by kiegroup.

the class AdventureFrame method createInventoryPanel.

private Component createInventoryPanel() {
    inventoryTable = new JTable();
    inventoryTable.setBorder(null);
    inventoryTable.setModel(new NonEditableTableMode(new Object[][] {}, new String[] { "Inventory" }));
    inventoryTable.addMouseListener(new MouseListener() {

        public void mouseReleased(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseClicked(MouseEvent e) {
            if (cmd == null) {
                return;
            }
            int row = inventoryTable.rowAtPoint(e.getPoint());
            int col = inventoryTable.columnAtPoint(e.getPoint());
            Thing t = (Thing) inventoryTable.getModel().getValueAt(row, col);
            cmdTextField.setText(cmdTextField.getText() + t.getName() + " ");
            cmd.add(t);
        }
    });
    JScrollPane inventoryPanel = new JScrollPane(inventoryTable);
    return inventoryPanel;
}
Also used : MouseListener(java.awt.event.MouseListener) MouseEvent(java.awt.event.MouseEvent)

Example 55 with MouseListener

use of java.awt.event.MouseListener in project Java by bottleleung.

the class AwtMainComponet method main.

public static void main(String[] args) throws Exception {
    Toolkit tool = Toolkit.getDefaultToolkit();
    Dimension d = tool.getScreenSize();
    JFrame frame = new JFrame();
    GamingInfo.getGamingInfo().setGaming(true);
    GamingInfo.getGamingInfo().setScreenWidth(900);
    GamingInfo.getGamingInfo().setScreenHeight(600);
    frame.setSize(GamingInfo.getGamingInfo().getScreenWidth(), GamingInfo.getGamingInfo().getScreenHeight());
    // ȥ�����ڵ�װ��
    frame.setUndecorated(true);
    // frame.getRootPane().setWindowDecorationStyle(JRootPane.NONE);//����ָ���Ĵ���װ�η��
    // frame.setResizable(false);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocationRelativeTo(null);
    MainSurface pane = new MainSurface();
    GamingInfo.getGamingInfo().setSurface(pane);
    frame.setContentPane(pane);
    // frame.setAlwaysOnTop(true);
    frame.setVisible(true);
    frame.addMouseListener(new MouseListener() {

        @Override
        public void mouseReleased(MouseEvent e) {
        // TODO Auto-generated method stub
        }

        @Override
        public void mousePressed(MouseEvent e) {
            if (GameInitManager.getGameInitManager().isIniting()) {
                return;
            }
            // �ȿ����ֹ������Ƿ�����Ӧ
            if (!LayoutManager.getLayoutManager().onClick(e.getX(), e.getY())) {
                // �����ӵ�
                CannonManager.getCannonManager().shot(e.getX(), e.getY());
            }
        }

        @Override
        public void mouseExited(MouseEvent e) {
        // TODO Auto-generated method stub
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        // TODO Auto-generated method stub
        }

        @Override
        public void mouseClicked(MouseEvent e) {
        // TODO Auto-generated method stub
        }
    });
    // frame.pack();
    pane.action();
    /**
     * ����һ���߳����첽��ʼ����Ϸ����
     */
    new Thread(new Runnable() {

        public void run() {
            // ʹ����Ϸ��ʼ����������ʼ����Ϸ
            GameInitManager.getGameInitManager().init();
        }
    }).start();
}
Also used : MouseListener(java.awt.event.MouseListener) MouseEvent(java.awt.event.MouseEvent) JFrame(javax.swing.JFrame) MainSurface(com.mypro.mainsurface.MainSurface) Toolkit(java.awt.Toolkit) Dimension(java.awt.Dimension)

Aggregations

MouseListener (java.awt.event.MouseListener)104 MouseEvent (java.awt.event.MouseEvent)67 Dimension (java.awt.Dimension)21 JLabel (javax.swing.JLabel)20 MouseAdapter (java.awt.event.MouseAdapter)19 JPanel (javax.swing.JPanel)16 Component (java.awt.Component)14 JComponent (javax.swing.JComponent)14 ActionEvent (java.awt.event.ActionEvent)13 ActionListener (java.awt.event.ActionListener)11 MouseMotionListener (java.awt.event.MouseMotionListener)11 JButton (javax.swing.JButton)11 JScrollPane (javax.swing.JScrollPane)11 Insets (java.awt.Insets)8 BorderLayout (java.awt.BorderLayout)7 Color (java.awt.Color)7 Point (java.awt.Point)7 File (java.io.File)7 ImageIcon (javax.swing.ImageIcon)6 JCheckBox (javax.swing.JCheckBox)6