Example usage for java.awt Point Point

List of usage examples for java.awt Point Point

Introduction

In this page you can find the example usage for java.awt Point Point.

Prototype

public Point(int x, int y) 

Source Link

Document

Constructs and initializes a point at the specified (x,y) location in the coordinate space.

Usage

From source file:edu.ku.brc.specify.tasks.subpane.wb.FormPane.java

/**
 * Creates all the UI form the Form. //from w  ww.  ja  v  a  2  s. com
 */
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.openbyte.gui.WelcomeFrame.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Gary Lee
    scrollPane1 = new JScrollPane();
    list1 = new JList();
    button1 = new JButton();
    label2 = new JLabel();
    button2 = new JButton();
    button3 = new JButton();
    button4 = new JButton();
    button5 = new JButton();
    scrollPane2 = new JScrollPane();
    xImagePanel1 = new JXImagePanel();
    button6 = new JButton();
    button7 = new JButton();
    button8 = new JButton();

    //======== this ========
    setTitle("Welcome to OpenByte");
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setResizable(false);/*from  www .  ja  va  2 s.c  o m*/
    Container contentPane = getContentPane();
    contentPane.setLayout(null);

    //======== scrollPane1 ========
    {
        scrollPane1.setBorder(new TitledBorder(LineBorder.createGrayLineBorder(), "Recent Projects"));

        //---- list1 ----
        list1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        list1.setBackground(new Color(240, 240, 240));
        list1.addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                list1ValueChanged(e);
            }
        });
        scrollPane1.setViewportView(list1);
    }
    contentPane.add(scrollPane1);
    scrollPane1.setBounds(15, 10, 165, 340);

    //---- button1 ----
    button1.setText("Open Project");
    button1.setEnabled(false);
    button1.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button1ActionPerformed(e);
        }
    });
    contentPane.add(button1);
    button1.setBounds(105, 355, 110, button1.getPreferredSize().height);

    //---- label2 ----
    label2.setText("Media");
    contentPane.add(label2);
    label2.setBounds(new Rectangle(new Point(605, 210), label2.getPreferredSize()));

    //---- button2 ----
    button2.setText("Minecraft Forums");
    button2.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button2ActionPerformed(e);
        }
    });
    contentPane.add(button2);
    button2.setBounds(500, 230, 151, button2.getPreferredSize().height);

    //---- button3 ----
    button3.setText("GitHub");
    button3.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button3ActionPerformed(e);
        }
    });
    contentPane.add(button3);
    button3.setBounds(500, 260, 150, button3.getPreferredSize().height);

    //---- button4 ----
    button4.setText("+");
    button4.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button4ActionPerformed(e);
        }
    });
    contentPane.add(button4);
    button4.setBounds(15, 355, 45, button4.getPreferredSize().height);

    //---- button5 ----
    button5.setText("-");
    button5.setEnabled(false);
    button5.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button5ActionPerformed(e);
        }
    });
    contentPane.add(button5);
    button5.setBounds(60, 355, 40, button5.getPreferredSize().height);

    //======== scrollPane2 ========
    {
        scrollPane2.setBorder(null);
        scrollPane2.setViewportView(xImagePanel1);
    }
    contentPane.add(scrollPane2);
    scrollPane2.setBounds(210, 25, 445, 160);

    //---- button6 ----
    button6.setText("Preferences");
    button6.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button6ActionPerformed(e);
        }
    });
    contentPane.add(button6);
    button6.setBounds(500, 290, 150, 30);

    //---- button7 ----
    button7.setText("About");
    button7.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button7ActionPerformed(e);
        }
    });
    contentPane.add(button7);
    button7.setBounds(500, 320, 150, 30);

    //---- button8 ----
    button8.setText("Plugins");
    button8.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button8ActionPerformed(e);
        }
    });
    contentPane.add(button8);
    button8.setBounds(500, 350, 150, 30);

    { // compute preferred size
        Dimension preferredSize = new Dimension();
        for (int i = 0; i < contentPane.getComponentCount(); i++) {
            Rectangle bounds = contentPane.getComponent(i).getBounds();
            preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
            preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
        }
        Insets insets = contentPane.getInsets();
        preferredSize.width += insets.right;
        preferredSize.height += insets.bottom;
        contentPane.setMinimumSize(preferredSize);
        contentPane.setPreferredSize(preferredSize);
    }
    setSize(675, 425);
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:at.tuwien.ifs.somtoolbox.visualization.thematicmap.SOMRegion.java

public void sortSegments() {
    if (segments.isEmpty()) {
        return;/*from w ww.  j av  a 2s . c om*/
    }
    Segment s = segments.get(0);
    ArrayList<Segment> res = new ArrayList<Segment>();
    res.add(s);
    segments.remove(s);
    int n = 0;
    boolean done = true;
    while (!segments.isEmpty()) {
        if (n > 100) {
            done = false;
            break;
        }
        n++;
        for (int i = 0; i < segments.size(); i++) {
            Segment ss = segments.get(i);
            if (s.end2.equals(ss.end1) && !s.end1.equals(ss.end2)) {
                res.add(ss);
                segments.remove(ss);
                s = ss;
                break;
            } else if (s.end2.equals(ss.end2) && !s.end1.equals(ss.end1)) {
                res.add(ss);
                segments.remove(ss);
                ss.flip();
                s = ss;
                break;
            }
        }
    }

    if (!done) {
        if (!res.isEmpty()) {
            s = res.get(0);
        } else {
            s = segments.get(segments.size() - 1);
        }

        n = 0;
        while (!segments.isEmpty()) {
            if (n > 100) {
                break;
            }
            n++;
            for (int i = 0; i < segments.size(); i++) {
                Segment ss = segments.get(i);
                if (s.end1.equals(ss.end2) && !s.end2.equals(ss.end1)) {
                    res.add(0, ss);
                    segments.remove(ss);
                    s = ss;
                    break;
                } else if (s.end1.equals(ss.end1) && !s.end2.equals(ss.end2)) {
                    res.add(0, ss);
                    segments.remove(ss);
                    ss.flip();
                    s = ss;
                    break;
                }
            }
        }
    }
    segments = res;

    int len = segments.size();
    int[] xx = new int[len];
    int[] yy = new int[len];
    Point[] points = new Point[len];
    for (int i = 0; i < len; i++) {
        Segment seg = segments.get(i);
        xx[i] = (int) seg.end1.coord(0);
        yy[i] = (int) seg.end1.coord(1);
        points[i] = new Point(xx[i], yy[i]);
    }

    super.xpoints = xx;
    super.ypoints = yy;
    super.npoints = len;
    super.getBounds();
}

From source file:web.diva.server.model.SomClustering.SomClustImgGenerator.java

public String generateScale(Dataset dataset, boolean clustColumn) {
    int W = 0;/*from w  ww . j a v  a2 s .  c o  m*/
    if (clustColumn) {
        W = (Math.min((upperTree.getWidth() + 21), 250));
    } else {
        W = (Math.min((dataset.getColumnIds().length * 12 + 21), 250));
    }
    BufferedImage nfo = new BufferedImage(W, 50, BufferedImage.TYPE_INT_ARGB);
    Graphics g = nfo.getGraphics();
    g.setFont(getTableFont(9));
    drawScale(g, new Point(0, 0), W, 30);
    return this.generateEncodedImg(nfo);

}

From source file:org.nekorp.workflow.desktop.view.AutoDamageView.java

private void contentMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_contentMouseReleased
    if (evt.isPopupTrigger()) {
        for (DamageDetailGraphicsView x : damageDetail) {
            Point punto = new Point(evt.getX(), evt.getY());
            if (x.shapeContains(punto) && editable) {
                this.currentEdited = x;
                this.jPopupMenu1.show(evt.getComponent(), evt.getX(), evt.getY());
                break;
            }//  ww w .  j a  va 2 s . c o m
        }
    } else {
        if (currentView.shapeContains(evt.getX() - boundsX, evt.getY() - boundsY) && editable) {
            damageCaptura.setX(evt.getX() - boundsX);
            damageCaptura.setY(evt.getY() - boundsY);
            dialogFactory.createDialog(mainFrame, true).setVisible(true);
        }
    }
}

From source file:it.unibas.spicygui.controllo.provider.intermediatezone.WidgetCreator.java

public Widget createConstantInterWidget(Scene scene, LayerWidget mainLayer, LayerWidget connectionLayer,
        JPanel pannelloPrincipale, Point point, GraphSceneGlassPane glassPane) {
    CaratteristicheWidgetInterConst caratteristicheWidget = new CaratteristicheWidgetInterConst();
    caratteristicheWidget.setTreeType(Costanti.INTERMEDIE);
    caratteristicheWidget.setFormValidation(new FormValidation(true));
    //giannisk//from  w ww  . j av a2s.c o m
    caratteristicheWidget.setTgdView(false);
    ConstantWidget rootWidget = new ConstantWidget(scene, point, caratteristicheWidget);
    rootWidget.getActions()
            .addAction(ActionFactory.createEditAction(new MyEditProviderConst(caratteristicheWidget)));
    rootWidget.getActions().addAction(ActionFactory.createConnectAction(connectionLayer,
            new ActionConstantConnection(mainLayer, connectionLayer, caratteristicheWidget)));
    rootWidget.getActions()
            .addAction(ActionFactory.createPopupMenuAction(new MyPopupProviderDeleteConst(glassPane)));
    CaratteristicheBarra caratteristicheBarra = new CaratteristicheBarra(rootWidget, Costanti.INTERMEDIE_BARRA);
    IconNodeWidget barra = new IconNodeWidget(scene);
    barra.setImage(ImageUtilities.loadImage(Costanti.ICONA_MOVE));
    Point pointBarra = new Point(rootWidget.getPreferredLocation().x - Costanti.OFF_SET_X_WIDGET_BARRA,
            rootWidget.getPreferredLocation().y - Costanti.OFF_SET_Y_WIDGET_BARRA);
    barra.setPreferredLocation(pointBarra);
    IntermediateMoveProvider moveProvider = new IntermediateMoveProvider(pannelloPrincipale);
    barra.getActions().addAction(ActionFactory.createMoveAction(moveProvider, moveProvider));
    caratteristicheWidget.setWidgetBarra(barra);

    mainLayer.addChild(rootWidget, caratteristicheWidget);
    mainLayer.addChild(barra, caratteristicheBarra);

    glassPane.addConstant(rootWidget);
    glassPane.addConstant(barra);

    return rootWidget;
}

From source file:de.fhg.igd.mapviewer.view.ExtendedMapKit.java

/**
 * @see IPersistable#saveState(IMemento)
 *//*  w  ww  .j  a  v a  2 s  .  c o m*/
@Override
public void saveState(IMemento memento) {
    GeoPosition min = getMainMap().convertPointToGeoPosition(new Point(
            (int) Math.round(getMainMap().getWidth() * 0.1), (int) Math.round(getMainMap().getHeight() * 0.1)));
    GeoPosition max = getMainMap().convertPointToGeoPosition(new Point(
            (int) Math.round(getMainMap().getWidth() * 0.9), (int) Math.round(getMainMap().getHeight() * 0.9)));

    // GeoPosition min = getMainMap().convertPointToGeoPosition(new Point(0,
    // 0));
    // GeoPosition max = getMainMap().convertPointToGeoPosition(new
    // Point(getMainMap().getWidth(), getMainMap().getHeight()));

    int epsg = min.getEpsgCode();

    try {
        if (epsg != max.getEpsgCode())
            max = GeotoolsConverter.getInstance().convert(max, epsg);

        memento.putFloat(MEMENTO_KEY_MIN_X, (float) min.getX());
        memento.putFloat(MEMENTO_KEY_MIN_Y, (float) min.getY());
        memento.putFloat(MEMENTO_KEY_MAX_X, (float) max.getX());
        memento.putFloat(MEMENTO_KEY_MAX_Y, (float) max.getY());

        memento.putInteger(MEMENTO_KEY_EPSG, epsg);
    } catch (IllegalGeoPositionException e) {
        log.error("Error saving map state: Could not convert GeoPosition", e); //$NON-NLS-1$
    }
}

From source file:AWTUtilities.java

/**
 * Attempts to determine the usable screen bounds of the default screen
 * device. If the require java.awt API is not available under the JVM we're
 * running in, this will simply return the screen bounds obtained via
 * <code>Toolkit.getScreenSize()</code>.
 *///from www . j a  v  a 2 s . c o m

public static Rectangle getUsableScreenBounds() {
    if (PlatformUtils.isJavaBetterThan("1.4")) {
        try {
            Class graphicsEnvironmentClass = Class.forName("java.awt.GraphicsEnvironment");
            Class graphicsDeviceClass = Class.forName("java.awt.GraphicsDevice");
            Class graphicsConfigurationClass = Class.forName("java.awt.GraphicsConfiguration");

            Class[] emptyClassArr = new Class[0];
            Method getLocalGraphicsEnvironmentMethod = graphicsEnvironmentClass
                    .getMethod("getLocalGraphicsEnvironment", emptyClassArr);
            Method getDefaultScreenDeviceMethod = graphicsEnvironmentClass.getMethod("getDefaultScreenDevice",
                    emptyClassArr);
            Method getDefaultConfigurationMethod = graphicsDeviceClass.getMethod("getDefaultConfiguration",
                    emptyClassArr);
            Method getBoundsMethod = graphicsConfigurationClass.getMethod("getBounds", emptyClassArr);
            Method getScreenInsetsMethod = Toolkit.class.getMethod("getScreenInsets",
                    new Class[] { graphicsConfigurationClass });

            Object[] emptyObjArr = new Object[0];
            Object graphicsEnvironment = getLocalGraphicsEnvironmentMethod.invoke(null, emptyObjArr);
            Object defaultScreenDevice = getDefaultScreenDeviceMethod.invoke(graphicsEnvironment, emptyObjArr);
            Object defaultConfiguration = getDefaultConfigurationMethod.invoke(defaultScreenDevice,
                    emptyObjArr);
            Rectangle bounds = (Rectangle) getBoundsMethod.invoke(defaultConfiguration, emptyObjArr);
            Insets insets = (Insets) getScreenInsetsMethod.invoke(Toolkit.getDefaultToolkit(),
                    new Object[] { defaultConfiguration });

            bounds.x += insets.left;
            bounds.y += insets.top;
            bounds.width -= insets.left + insets.right;
            bounds.height -= insets.top + insets.bottom;

            return bounds;
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }

    return new Rectangle(new Point(0, 0), Toolkit.getDefaultToolkit().getScreenSize());
}

From source file:com.intuit.tank.tools.debugger.AgentDebuggerFrame.java

/**
 * @throws HeadlessException//from  w w w  .j  a  v  a 2  s  .  co  m
 */
public AgentDebuggerFrame(final boolean isStandalone, String serviceUrl) throws HeadlessException {
    super("Intuit Tank Agent Debugger");
    workingDir = PanelBuilder.createWorkingDir(this, serviceUrl);
    setSize(new Dimension(1024, 800));
    setBounds(new Rectangle(getSize()));
    setPreferredSize(getSize());
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setLayout(new BorderLayout());
    this.standalone = isStandalone;
    addWindowListener(new WindowAdapter() {
        public void windowClosed(WindowEvent e) {
            quit();
        }
    });
    errorIcon = ActionProducer.getIcon("bullet_error.png", IconSize.SMALL);
    modifiedIcon = ActionProducer.getIcon("bullet_code_change.png", IconSize.SMALL);
    skippedIcon = ActionProducer.getIcon("skip.png", IconSize.SMALL);

    this.glassPane = new InfiniteProgressPanel();
    setGlassPane(glassPane);
    debuggerActions = new ActionProducer(this, serviceUrl);
    requestResponsePanel = new RequestResponsePanel(this);
    requestResponsePanel.init();
    testPlanChooser = new JComboBox();
    testPlanChooser.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent event) {
            if (event.getItem() != null) {
                HDTestPlan selected = (HDTestPlan) event.getItem();
                if (!selected.equals(currentTestPlan)) {
                    setCurrentTestPlan(selected);
                }
            }

        }
    });

    tankClientChooser = new JComboBox<TankClientChoice>();
    debuggerActions.setChoiceComboBoxOptions(tankClientChooser);

    actionComponents = new ActionComponents(standalone, testPlanChooser, tankClientChooser, debuggerActions);
    addScriptChangedListener(actionComponents);
    setJMenuBar(actionComponents.getMenuBar());

    Component topPanel = PanelBuilder.createTopPanel(actionComponents);
    Component bottomPanel = PanelBuilder.createBottomPanel(this);
    Component contentPanel = PanelBuilder.createContentPanel(this);

    final JPopupMenu popup = actionComponents.getPopupMenu();
    scriptEditorTA.setPopupMenu(null);

    scriptEditorTA.addMouseListener(new MouseAdapter() {
        int lastHash;

        @Override
        public void mousePressed(MouseEvent e) {
            maybeShow(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            maybeShow(e);
        }

        private void maybeShow(MouseEvent e) {
            if (lastHash == getHash(e)) {
                return;
            }
            if (e.isPopupTrigger()) {
                // select the line
                try {
                    int offset = scriptEditorTA.viewToModel(e.getPoint());
                    Rectangle modelToView = scriptEditorTA.modelToView(offset);
                    Point point = new Point(modelToView.x + 1, e.getPoint().y);
                    if (modelToView.contains(point)) {
                        if (!multiSelect) {
                            int line = scriptEditorTA.getLineOfOffset(offset);
                            scriptEditorTA.setCurrentLine(line);
                        }
                        popup.show(e.getComponent(), e.getX(), e.getY());
                    }
                } catch (BadLocationException e1) {
                    e1.printStackTrace();
                }
            } else if (e.isShiftDown()) {
                int line = scriptEditorTA.getCaretLineNumber();
                int start = Math.min(line, lastLine);
                int end = Math.max(line, lastLine);
                multiSelect = end - start > 1;
                if (multiSelect) {
                    multiSelectStart = start;
                    multiSelectEnd = end;
                    try {
                        scriptEditorTA.setEnabled(true);
                        scriptEditorTA.select(scriptEditorTA.getLineStartOffset(start),
                                scriptEditorTA.getLineEndOffset(end));
                        scriptEditorTA.setEnabled(false);
                    } catch (BadLocationException e1) {
                        e1.printStackTrace();
                        multiSelect = false;
                    }
                }
            } else {
                multiSelect = false;
                lastLine = scriptEditorTA.getCaretLineNumber();
            }
            lastHash = getHash(e);
        }

        private int getHash(MouseEvent e) {
            return new HashCodeBuilder().append(e.getButton()).append(e.getSource().hashCode())
                    .append(e.getPoint()).toHashCode();
        }

    });

    JSplitPane mainSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    mainSplit.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    mainSplit.setTopComponent(contentPanel);
    mainSplit.setBottomComponent(bottomPanel);
    mainSplit.setDividerLocation(600);
    mainSplit.setResizeWeight(0.8D);
    mainSplit.setDividerSize(5);

    add(topPanel, BorderLayout.NORTH);
    add(mainSplit, BorderLayout.CENTER);

    WindowUtil.centerOnScreen(this);
    pack();

    KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();

    manager.addKeyEventDispatcher(new KeyEventDispatcher() {

        @Override
        public boolean dispatchKeyEvent(KeyEvent e) {
            if (e.getID() == KeyEvent.KEY_PRESSED) {
                handleKeyEvent(e);
            }
            return false;
        }
    });
}

From source file:fr.landel.utils.commons.CollectionUtils2Test.java

/**
 * Test method for//from  w ww .  j a va  2  s .  c  o m
 * {@link CollectionUtils2#transformIntoArray(I[], Transformer)} .
 * {@link CollectionUtils2#transformIntoArray(I[], Function)} .
 */
@Test
public void testTransformIntoArrayIArrayTransformerOfIO() {
    try {
        Point[] points = new Point[3];
        points[0] = new Point(1, 2);
        points[1] = new Point(2, 0);

        String[] pointsArray = CollectionUtils2.transformIntoArray(points, TRANSFORMER);

        assertNotNull(pointsArray);
        assertTrue(pointsArray.length > 0);
        assertThat(pointsArray, Matchers.arrayContaining("1, 2", "2, 0", null));

        pointsArray = CollectionUtils2.transformIntoArray(points, FUNCTION);

        assertNotNull(pointsArray);
        assertTrue(pointsArray.length > 0);
        assertThat(pointsArray, Matchers.arrayContaining("1, 2", "2, 0", null));
    } catch (IllegalArgumentException e) {
        fail("The test isn't correct");
    }
}