Example usage for javax.swing JPanel setLocation

List of usage examples for javax.swing JPanel setLocation

Introduction

In this page you can find the example usage for javax.swing JPanel setLocation.

Prototype

public void setLocation(int x, int y) 

Source Link

Document

Moves this component to a new location.

Usage

From source file:probe.com.model.util.vaadintoimageutil.HeatmapSwingComponent.java

private JPanel initCell(String color, int x, int y) {
    JPanel cell = new JPanel();
    cell.setSize(50, 50);//from  w w w.  jav  a 2  s .c  o m
    cell.setBackground(Color.decode(color));
    cell.setOpaque(true);
    cell.setLocation(x, y);
    cell.setBorder(new LineBorder(Color.WHITE));
    return cell;

}

From source file:neironweb.Frame.java

public Frame() {
    super("neural network");
    //JPanel pane = new JPanel();

    setLayout(null);//from   w  ww .  j a  v a 2 s. c  o m

    JPanel mailPanel = new JPanel();
    mailPanel.setLayout(null);
    mailPanel.setLocation(50, 30);
    mailPanel.setSize(300, 170);
    mailPanel.setBorder(BorderFactory.createLineBorder(Color.black));

    JLabel mailLabel = new JLabel("e-mail:");
    mailLabel.setLocation(10, 10);
    mailLabel.setSize(50, 30);
    mailPanel.add(mailLabel);

    JLabel dirMailLabel = new JLabel("direct:");
    dirMailLabel.setLocation(10, 50);
    dirMailLabel.setSize(50, 30);
    mailPanel.add(dirMailLabel);

    JTextField mailField = new JTextField("mail@mail.ru");
    mailField.setSize(150, 30);
    mailField.setLocation(80, 10);
    mailPanel.add(mailField);

    JTextField textField = new JTextField("INBOX");
    textField.setLocation(80, 50);
    textField.setSize(150, 30);
    mailPanel.add(textField);

    JButton mailButton = new JButton("Analyze");
    mailButton.setLocation(80, 90);
    mailButton.setSize(150, 30);
    mailPanel.add(mailButton);

    //        JButton eduButton = new JButton("Start education");
    //        eduButton.setLocation(0, 50);
    //        eduButton.setSize(150, 30);
    //        buttonPanel.add(eduButton);

    XYSeries xyser = new XYSeries("");
    XYDataset xy = new XYSeriesCollection(xyser);
    JFreeChart jf = ChartFactory.createXYLineChart("Education", "X", "Y", xy);

    for (int i = 0; i < 100; i++)
        xyser.add(i, Math.cos(i));

    ChartPanel chartPanel = new ChartPanel(jf);
    chartPanel.setSize(700, 300);
    chartPanel.setLocation(50, 230);
    chartPanel.setBorder(BorderFactory.createLineBorder(Color.black));

    //        JPanel myChartPanel = new JPanel();        
    //        myChartPanel.setLayout(null);
    //        myChartPanel.setLocation(50, 230);
    //        myChartPanel.setSize(700, 300);
    //        myChartPanel
    //      myChartPanel.add(chartPanel);        

    setSize(800, 600);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container con = this.getContentPane(); // inherit main frame
    //con.add(pane); 
    con.add(mailPanel);
    //con.add(myChartPanel);
    con.add(chartPanel);
    setVisible(true);

}

From source file:jcine.CineForm.java

private void buildHall(Asiento[] asientos) {
    //Encontraremos las dimensiones de sala
    Integer maxX = 0;//from   w  ww . j  a v a2s .com
    Integer maxY = 0;
    for (int i = 0; i < asientos.length; i++) {
        if (asientos[i].getPosX() > maxX) {
            maxX = asientos[i].getPosX();
        }
        if (asientos[i].getPosY() > maxY) {
            maxY = asientos[i].getPosY();
        }
    }
    //los tamaos de sillas
    Integer sizeX = pHall.getWidth() / maxX;
    Integer sizeY = pHall.getHeight() / maxY;

    Boolean[][] matrix = new Boolean[maxX][maxY];

    //sillas
    for (int i = 0; i < asientos.length; i++) {
        JButton btn = new JButton("btn_" + Integer.toString(i));
        btn.setText(asientos[i].getName());
        btn.setLocation(sizeX * (asientos[i].getPosX() - 1), sizeY * (asientos[i].getPosY() - 1));
        btn.setSize(sizeX - SPACER, sizeY - SPACER);
        btn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chairPressed(evt);
            }
        });
        matrix[asientos[i].getPosX() - 1][asientos[i].getPosY() - 1] = true;
        pHall.add(btn);
    }
    //pasillos
    for (int x = 0; x < maxX; x++) {
        for (int y = 0; y < maxY; y++) {
            if (matrix[x][y] == null) {
                JPanel panel = new JPanel();
                panel.setBackground(Color.cyan);
                panel.setLocation(x * sizeX - SPACER, y * sizeY - SPACER);
                panel.setSize(sizeX + 2 * SPACER, sizeY + 2 * SPACER);
                pHall.add(panel);
            }
        }
    }
    pHall.repaint();
}

From source file:ac.openmicrolabs.view.gui.OMLLoggerView.java

private JPanel createContentPane(final TimeSeriesCollection t, final String graphTitle,
        final double graphTimeRange, final String[] signals) {

    btmPanel.remove(reportButton);//from ww  w .  j  a va 2s . c  o  m

    chanLabel = new JLabel[signals.length];

    int activeSignalCount = 0;
    for (int i = 0; i < signals.length; i++) {
        chanLabel[i] = new JLabel(h.format("label", (char) ((i / PIN_COUNT) + ASCII_OFFSET) + "-0x"
                + String.format("%02x", (i % PIN_COUNT) + SLAVE_BITS).toUpperCase()));
        chanLabel[i].setHorizontalAlignment(JLabel.CENTER);
        if (signals[i] != null) {
            activeSignalCount++;
        } else {
            chanLabel[i].setEnabled(false);
        }
    }

    typeLabel = new JLabel[activeSignalCount];
    valLabel = new JLabel[activeSignalCount];
    minLabel = new JLabel[activeSignalCount];
    maxLabel = new JLabel[activeSignalCount];
    avgLabel = new JLabel[activeSignalCount];

    int index = 0;
    for (int i = 0; i < signals.length; i++) {
        if (signals[i] != null) {
            typeLabel[index] = new JLabel(h.format("body", signals[i]));
            typeLabel[index].setHorizontalAlignment(JLabel.CENTER);
            index++;
        }
    }

    for (int i = 0; i < activeSignalCount; i++) {
        valLabel[i] = new JLabel();
        valLabel[i].setHorizontalAlignment(JLabel.CENTER);
        minLabel[i] = new JLabel();
        minLabel[i].setHorizontalAlignment(JLabel.CENTER);
        maxLabel[i] = new JLabel();
        maxLabel[i].setHorizontalAlignment(JLabel.CENTER);
        avgLabel[i] = new JLabel();
        avgLabel[i].setHorizontalAlignment(JLabel.CENTER);
    }

    // Set up main panel.
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(null);
    mainPanel.setBackground(Color.white);

    // Create graph.
    snsChart = ChartFactory.createTimeSeriesChart(graphTitle, GRAPH_X_LABEL, GRAPH_Y_LABEL, t, true, true,
            false);
    final XYPlot plot = snsChart.getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(graphTimeRange);
    axis = plot.getRangeAxis();
    axis.setRange(graphMinY, graphMaxY);

    ChartPanel snsChartPanel = new ChartPanel(snsChart);
    snsChartPanel.setPreferredSize(new Dimension(FRAME_WIDTH - PAD20, GRAPH_HEIGHT - PAD10));

    // Set up graph panel.
    final JPanel graphPanel = new JPanel();
    graphPanel.setSize(FRAME_WIDTH - PAD20, GRAPH_HEIGHT);
    graphPanel.setLocation(0, 0);
    graphPanel.setBackground(Color.white);
    graphPanel.add(snsChartPanel);

    // Set up results panel.
    final JPanel resultsPanel = createResultsPane();

    // Set up scroll pane.
    final JScrollPane scrollPane = new JScrollPane(resultsPanel);
    scrollPane.setSize(FRAME_WIDTH - PAD20, FRAME_HEIGHT - BTM_HEIGHT - GRAPH_HEIGHT + PAD8);
    scrollPane.setLocation(PAD5, GRAPH_HEIGHT);
    scrollPane.setBackground(Color.white);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

    // Set results panel size.
    resultsPanel.setPreferredSize(new Dimension(PAD40 + (signals.length * RESULTS_COL_WIDTH),
            FRAME_HEIGHT - BTM_HEIGHT - GRAPH_HEIGHT - PAD120));
    resultsPanel.revalidate();

    // Set up bottom panel.
    btmPanel.setLayout(null);
    btmPanel.setSize(FRAME_WIDTH, BTM_HEIGHT);
    btmPanel.setLocation(0, this.getHeight() - BTM_HEIGHT);
    btmPanel.setBackground(Color.white);

    // Instantiate bottom panel objects.
    footerLabel.setSize(LABEL_WIDTH, LABEL_HEIGHT);
    footerLabel.setLocation(LABEL_X, LABEL_Y);
    footerLabel.setText("");

    doneButton.setIcon(new ImageIcon("img/22x22/stop.png"));
    doneButton.setSize(DONE_WIDTH, DONE_HEIGHT);
    doneButton.setLocation(FRAME_WIDTH - PAD20 - doneButton.getWidth(), PAD15);

    progressBar = new JProgressBar();
    progressBar.setSize(FRAME_WIDTH - PAD40 - doneButton.getWidth() - footerLabel.getWidth(), PAD20);
    progressBar.setValue(0);
    progressBar.setLocation(footerLabel.getWidth() + PAD10, PAD22);

    // Populate bottom panel.
    btmPanel.add(footerLabel);
    btmPanel.add(progressBar);
    btmPanel.add(doneButton);

    // Populate main panel.
    mainPanel.add(graphPanel);
    mainPanel.add(scrollPane);
    mainPanel.add(btmPanel);

    return mainPanel;
}

From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.heatmap.HeatMapImgGenerator.java

private JPanel initCell(String color, int x, int y) {
    JPanel cell = new JPanel();
    cell.setSize(50, 50);/*from   w  ww.  j a  v a 2  s  . co  m*/
    Color c;
    if (color.contains("#")) {
        c = Color.decode(color);
    } else if (color.toLowerCase().contains("rgb")) {
        String rgb = color.toLowerCase().replace("rgb", "").replace("(", "").replace(")", "").replace(" ", "");
        String[] stringRGBArr = rgb.split(",");
        c = new Color(Integer.valueOf(stringRGBArr[0]), Integer.valueOf(stringRGBArr[1]),
                Integer.valueOf(stringRGBArr[2]));
    } else {
        c = Color.RED;
    }

    cell.setBackground(c);
    cell.setOpaque(true);
    cell.setLocation(x, y);
    cell.setBorder(new LineBorder(Color.WHITE));
    return cell;

}

From source file:com.moss.greenshell.wizard.ProcessPanel.java

private void transitionAnimated(final JPanel oldView, final JPanel newView, final Runnable followupAction,
        SlidingPanel.Mode direction) {//from  ww w  .  j a  v  a2 s  .com

    final Dimension dimension = view.getActionArea().getSize();
    final SlidingPanel slidingPanel = new SlidingPanel();

    int gapBetweenViews = 100;

    synchronized (view.getActionArea()) {
        view.getActionArea().removeAll();
        view.getActionArea().add(slidingPanel);
    }

    slidingPanel.setSize(dimension);
    slidingPanel.setLocation(0, 0);
    slidingPanel.setLayout(null);
    slidingPanel.add(oldView);
    slidingPanel.add(newView);

    oldView.setSize(dimension);
    oldView.setLocation(0, 0);

    if (direction.equals(SlidingPanel.Mode.HORIZONTAL_LEFT)) {
        newView.setSize(dimension);
        newView.setLocation(dimension.width + gapBetweenViews, 0);
    } else if (direction.equals(SlidingPanel.Mode.HORIZONTAL_RIGHT)) {
        newView.setSize(dimension);
        newView.setLocation(0 - dimension.width - gapBetweenViews, 0);
    } else if (direction.equals(SlidingPanel.Mode.VERTICAL_UP)) {
        newView.setSize(dimension);
        newView.setLocation(0, dimension.width + gapBetweenViews);
    } else if (direction.equals(SlidingPanel.Mode.VERTICAL_DOWN)) {
        newView.setSize(dimension);
        newView.setLocation(0, 0 - dimension.width - gapBetweenViews);
    }

    view.getActionArea().invalidate();
    view.validate();
    view.repaint();

    slidingPanel.setMode(direction);
    slidingPanel.setTranslateMax(dimension.width + gapBetweenViews);

    slidingPanel.slide(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            transitionStatic(oldView, newView, followupAction);
        }
    });
}

From source file:com.floreantpos.jasperreport.swing.JRViewerPanel.java

protected void createHyperlinks(List elements, int offsetX, int offsetY) {
    if (elements != null && elements.size() > 0) {
        for (Iterator it = elements.iterator(); it.hasNext();) {
            JRPrintElement element = (JRPrintElement) it.next();

            JRImageMapRenderer imageMap = null;
            if (element instanceof JRPrintImage) {
                JRRenderable renderer = ((JRPrintImage) element).getRenderer();
                if (renderer instanceof JRImageMapRenderer) {
                    imageMap = (JRImageMapRenderer) renderer;
                    if (!imageMap.hasImageAreaHyperlinks()) {
                        imageMap = null;
                    }//from w w  w  . j  ava  2s .c  om
                }
            }
            boolean hasImageMap = imageMap != null;

            JRPrintHyperlink hyperlink = null;
            if (element instanceof JRPrintHyperlink) {
                hyperlink = (JRPrintHyperlink) element;
            }
            boolean hasHyperlink = !hasImageMap && hyperlink != null
                    && hyperlink.getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE;
            boolean hasTooltip = hyperlink != null && hyperlink.getHyperlinkTooltip() != null;

            if (hasHyperlink || hasImageMap || hasTooltip) {
                JPanel link;
                if (hasImageMap) {
                    Rectangle renderingArea = new Rectangle(0, 0, element.getWidth(), element.getHeight());
                    link = new ImageMapPanel(renderingArea, imageMap);
                } else //hasImageMap
                {
                    link = new JPanel();
                    if (hasHyperlink) {
                        link.addMouseListener(mouseListener);
                    }
                }

                if (hasHyperlink) {
                    link.setCursor(new Cursor(Cursor.HAND_CURSOR));
                }

                link.setLocation((int) ((element.getX() + offsetX) * realZoom),
                        (int) ((element.getY() + offsetY) * realZoom));
                link.setSize((int) (element.getWidth() * realZoom), (int) (element.getHeight() * realZoom));
                link.setOpaque(false);

                String toolTip = getHyperlinkTooltip(hyperlink);
                if (toolTip == null && hasImageMap) {
                    toolTip = "";//not null to register the panel as having a tool tip
                }
                link.setToolTipText(toolTip);

                pnlLinks.add(link);
                linksMap.put(link, element);
            }

            if (element instanceof JRPrintFrame) {
                JRPrintFrame frame = (JRPrintFrame) element;
                int frameOffsetX = offsetX + frame.getX() + frame.getLineBox().getLeftPadding().intValue();
                int frameOffsetY = offsetY + frame.getY() + frame.getLineBox().getTopPadding().intValue();
                createHyperlinks(frame.getElements(), frameOffsetX, frameOffsetY);
            }
        }
    }
}

From source file:net.sf.jasperreports.swing.JRViewerPanel.java

protected void createHyperlinks(List<JRPrintElement> elements, int offsetX, int offsetY) {
    if (elements != null && elements.size() > 0) {
        for (Iterator<JRPrintElement> it = elements.iterator(); it.hasNext();) {
            JRPrintElement element = it.next();

            AreaHyperlinksRenderable imageMap = null;
            if (element instanceof JRPrintImage) {
                Renderable renderer = ((JRPrintImage) element).getRenderer();
                if (renderer instanceof AreaHyperlinksRenderable) {
                    imageMap = (AreaHyperlinksRenderable) renderer;
                    if (!imageMap.hasImageAreaHyperlinks()) {
                        imageMap = null;
                    }//from   w w  w .ja  v a  2  s  . co m
                }
            }
            boolean hasImageMap = imageMap != null;

            JRPrintHyperlink hyperlink = null;
            if (element instanceof JRPrintHyperlink) {
                hyperlink = (JRPrintHyperlink) element;
            }
            boolean hasHyperlink = !hasImageMap && hyperlink != null
                    && hyperlink.getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE;
            boolean hasTooltip = hyperlink != null && hyperlink.getHyperlinkTooltip() != null;

            if (hasHyperlink || hasImageMap || hasTooltip) {
                JPanel link;
                if (hasImageMap) {
                    Rectangle renderingArea = new Rectangle(0, 0, element.getWidth(), element.getHeight());
                    link = new ImageMapPanel(renderingArea, imageMap);
                } else //hasImageMap
                {
                    link = new JPanel();
                    if (hasHyperlink) {
                        link.addMouseListener(mouseListener);
                    }
                }

                if (hasHyperlink) {
                    link.setCursor(new Cursor(Cursor.HAND_CURSOR));
                }

                link.setLocation((int) ((element.getX() + offsetX) * realZoom),
                        (int) ((element.getY() + offsetY) * realZoom));
                link.setSize((int) (element.getWidth() * realZoom), (int) (element.getHeight() * realZoom));
                link.setOpaque(false);

                String toolTip = getHyperlinkTooltip(hyperlink);
                if (toolTip == null && hasImageMap) {
                    toolTip = "";//not null to register the panel as having a tool tip
                }
                link.setToolTipText(toolTip);

                pnlLinks.add(link);
                linksMap.put(link, hyperlink);
            }

            if (element instanceof JRPrintFrame) {
                JRPrintFrame frame = (JRPrintFrame) element;
                int frameOffsetX = offsetX + frame.getX() + frame.getLineBox().getLeftPadding();
                int frameOffsetY = offsetY + frame.getY() + frame.getLineBox().getTopPadding();
                createHyperlinks(frame.getElements(), frameOffsetX, frameOffsetY);
            }
        }
    }
}

From source file:com.openbravo.pos.util.JRViewer411.java

protected void createHyperlinks(List<JRPrintElement> elements, int offsetX, int offsetY) {
    if (elements != null && elements.size() > 0) {
        for (Iterator<JRPrintElement> it = elements.iterator(); it.hasNext();) {
            JRPrintElement element = it.next();

            JRImageMapRenderer imageMap = null;
            if (element instanceof JRPrintImage) {
                JRRenderable renderer = ((JRPrintImage) element).getRenderer();
                if (renderer instanceof JRImageMapRenderer) {
                    imageMap = (JRImageMapRenderer) renderer;
                    if (!imageMap.hasImageAreaHyperlinks()) {
                        imageMap = null;
                    }//from www  . ja  v a  2  s .com
                }
            }
            boolean hasImageMap = imageMap != null;

            JRPrintHyperlink hyperlink = null;
            if (element instanceof JRPrintHyperlink) {
                hyperlink = (JRPrintHyperlink) element;
            }
            boolean hasHyperlink = !hasImageMap && hyperlink != null
                    && hyperlink.getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE;
            boolean hasTooltip = hyperlink != null && hyperlink.getHyperlinkTooltip() != null;

            if (hasHyperlink || hasImageMap || hasTooltip) {
                JPanel link;
                if (hasImageMap) {
                    Rectangle renderingArea = new Rectangle(0, 0, element.getWidth(), element.getHeight());
                    link = new ImageMapPanel(renderingArea, imageMap);
                } else //hasImageMap
                {
                    link = new JPanel();
                    if (hasHyperlink) {
                        link.addMouseListener(mouseListener);
                    }
                }

                if (hasHyperlink) {
                    link.setCursor(new Cursor(Cursor.HAND_CURSOR));
                }

                link.setLocation((int) ((element.getX() + offsetX) * realZoom),
                        (int) ((element.getY() + offsetY) * realZoom));
                link.setSize((int) (element.getWidth() * realZoom), (int) (element.getHeight() * realZoom));
                link.setOpaque(false);

                String toolTip = getHyperlinkTooltip(hyperlink);
                if (toolTip == null && hasImageMap) {
                    toolTip = "";//not null to register the panel as having a tool tip
                }
                link.setToolTipText(toolTip);

                pnlLinks.add(link);
                linksMap.put(link, hyperlink);
            }

            if (element instanceof JRPrintFrame) {
                JRPrintFrame frame = (JRPrintFrame) element;
                int frameOffsetX = offsetX + frame.getX() + frame.getLineBox().getLeftPadding().intValue();
                int frameOffsetY = offsetY + frame.getY() + frame.getLineBox().getTopPadding().intValue();
                createHyperlinks(frame.getElements(), frameOffsetX, frameOffsetY);
            }
        }
    }
}

From source file:neg.JRViewer.java

protected void createHyperlinks(List elements, int offsetX, int offsetY) {
    if (elements != null && elements.size() > 0) {
        for (Iterator it = elements.iterator(); it.hasNext();) {
            JRPrintElement element = (JRPrintElement) it.next();

            JRImageMapRenderer imageMap = null;
            if (element instanceof JRPrintImage) {
                JRRenderable renderer = ((JRPrintImage) element).getRenderer();
                if (renderer instanceof JRImageMapRenderer) {
                    imageMap = (JRImageMapRenderer) renderer;
                    if (!imageMap.hasImageAreaHyperlinks()) {
                        imageMap = null;
                    }/*from  w w  w.ja  v a 2 s.c  o  m*/
                }
            }
            boolean hasImageMap = imageMap != null;

            JRPrintHyperlink hyperlink = null;
            if (element instanceof JRPrintHyperlink) {
                hyperlink = (JRPrintHyperlink) element;
            }
            boolean hasHyperlink = !hasImageMap && hyperlink != null
                    && hyperlink.getHyperlinkType() != JRHyperlink.HYPERLINK_TYPE_NONE;
            boolean hasTooltip = hyperlink != null && hyperlink.getHyperlinkTooltip() != null;

            if (hasHyperlink || hasImageMap || hasTooltip) {
                JPanel link;
                if (hasImageMap) {
                    Rectangle renderingArea = new Rectangle(0, 0, element.getWidth(), element.getHeight());
                    link = new ImageMapPanel(renderingArea, imageMap);
                } else //hasImageMap
                {
                    link = new JPanel();
                    if (hasHyperlink) {
                        link.addMouseListener(mouseListener);
                    }
                }

                if (hasHyperlink) {
                    link.setCursor(new Cursor(Cursor.HAND_CURSOR));
                }

                link.setLocation((int) ((element.getX() + offsetX) * realZoom),
                        (int) ((element.getY() + offsetY) * realZoom));
                link.setSize((int) (element.getWidth() * realZoom), (int) (element.getHeight() * realZoom));
                link.setOpaque(false);

                String toolTip = getHyperlinkTooltip(hyperlink);
                if (toolTip == null && hasImageMap) {
                    toolTip = "";//not null to register the panel as having a tool tip
                }
                link.setToolTipText(toolTip);

                pnlLinks.add(link);
                linksMap.put(link, element);
            }

            if (element instanceof JRPrintFrame) {
                JRPrintFrame frame = (JRPrintFrame) element;
                int frameOffsetX = offsetX + frame.getX() + frame.getLineBox().getLeftPadding().intValue();
                int frameOffsetY = offsetY + frame.getY() + frame.getLineBox().getTopPadding().intValue();
                createHyperlinks(frame.getElements(), frameOffsetX, frameOffsetY);
            }
        }
    }
}