List of usage examples for javax.swing JPanel setSize
public void setSize(int width, int height)
From source file:probe.com.model.util.vaadintoimageutil.Convertor.java
private JPanel convertVerticalLayout(VerticalLayout vaadinVerticalLayout) { JPanel verticalComponent = new JPanel(); verticalComponent.setSize((int) vaadinVerticalLayout.getWidth(), (int) vaadinVerticalLayout.getHeight()); verticalComponent.setBackground(backgroundMap.get(vaadinVerticalLayout.getStyleName())); return verticalComponent; }
From source file:neironweb.Frame.java
public Frame() { super("neural network"); //JPanel pane = new JPanel(); setLayout(null);//from w ww . ja v a 2 s . c om 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 a 2s . co m*/ 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:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.heatmap.HeatMapImgGenerator.java
public String generateHeatmap(String[] rows, String[] columns, String[][] data) { JPanel heatmapPanelLayout = new JPanel(); heatmapPanelLayout.setLayout(null);/* w w w. ja va 2s . c om*/ heatmapPanelLayout.setVisible(true); int width = (columns.length + 1) * 50; int height = (rows.length + 1) * 50; heatmapPanelLayout.setSize(width, height); JPanel cornerCell = initCell("#ffffff", 0, 0); int x = 50; int y = 0; heatmapPanelLayout.add(cornerCell); for (String headerCell : columns) { JPanel cell = initCell(headerCell, x, y); x += 50; heatmapPanelLayout.add(cell); } y = 50; for (String headerCell : rows) { JPanel cell = initCell(headerCell, 0, y); y += 50; heatmapPanelLayout.add(cell); } x = 50; y = 50; for (String[] row : data) { for (String color : row) { JPanel cell = initCell(color, x, y); heatmapPanelLayout.add(cell); x += 50; } x = 50; y += 50; } BufferedImage image = new BufferedImage(width + 10, height + 10, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = image.createGraphics(); graphics.setPaint(Color.WHITE); graphics.setBackground(Color.WHITE); heatmapPanelLayout.paint(graphics); byte[] imageData = null; try { ImageEncoder in = ImageEncoderFactory.newInstance(ImageFormat.PNG, new Float(0.084666f)); imageData = in.encode(image); } catch (Exception e) { System.out.println(e.getLocalizedMessage()); } String base64 = Base64.encodeBytes(imageData); base64 = "data:image/png;base64," + base64; return base64; }
From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectAdd.java
/** * This method initializes this/* ww w . ja va2 s . c o m*/ * * @return void */ private void initialize() { GridBagConstraints gridBagConstraints10 = new GridBagConstraints(); gridBagConstraints10.gridx = 1; gridBagConstraints10.anchor = GridBagConstraints.NORTH; gridBagConstraints10.insets = new Insets(10, 0, 0, 0); gridBagConstraints10.fill = GridBagConstraints.NONE; gridBagConstraints10.gridy = 0; GridBagConstraints gridBagConstraints9 = new GridBagConstraints(); gridBagConstraints9.gridx = 0; gridBagConstraints9.insets = new Insets(10, 10, 10, 0); gridBagConstraints9.fill = GridBagConstraints.BOTH; gridBagConstraints9.weightx = 0.1; gridBagConstraints9.weighty = 0.1; gridBagConstraints9.gridheight = 1; gridBagConstraints9.gridy = 0; JPanel p = new JPanel(); p.setSize(600, 300); p.setLayout(new GridBagLayout()); p.add(getJPanelPjtList(), gridBagConstraints9); p.add(getJPanelButton(), gridBagConstraints10); getContentPane().add(p); }
From source file:probe.com.model.util.vaadintoimageutil.HeatmapSwingComponent.java
public String generateHeatmap(String[] rows, String[] columns, String[][] data) { JPanel heatmapPanelLayout = new JPanel(); heatmapPanelLayout.setLayout(null);/*from ww w. j a va 2s .co m*/ heatmapPanelLayout.setVisible(true); heatmapPanelLayout.setBorder(new LineBorder(Color.BLACK)); int width = (columns.length + 1) * 50; int height = (rows.length + 1) * 50; heatmapPanelLayout.setSize(width, height); JPanel cornerCell = initCell("#ffffff", 0, 0); int x = 50; int y = 0; heatmapPanelLayout.add(cornerCell); for (String headerCell : columns) { JPanel cell = initCell(headerCell, x, y); x += 50; heatmapPanelLayout.add(cell); } y = 50; for (String headerCell : rows) { JPanel cell = initCell(headerCell, 0, y); y += 50; heatmapPanelLayout.add(cell); } x = 50; y = 50; for (String[] row : data) { for (String color : row) { JPanel cell = initCell(color, x, y); heatmapPanelLayout.add(cell); x += 50; } x = 50; y += 50; } BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = image.createGraphics(); graphics.setPaint(Color.WHITE); heatmapPanelLayout.paint(graphics); // super.paint(graphics); byte[] imageData = null; try { ImageEncoder in = ImageEncoderFactory.newInstance(ImageFormat.PNG, new Float(0.084666f)); imageData = in.encode(image); } catch (Exception e) { System.out.println(e.getLocalizedMessage()); } String base64 = Base64.encodeBytes(imageData); base64 = "data:image/png;base64," + base64; return base64; // // JFrame frame = new JFrame(); // frame.setSize(1000, 1000); // frame.add(heatmapPanelLayout); // frame.setVisible(true); // return ""; }
From source file:udpserver.UDPui.java
/** * Creates new form UDPui/*from w w w . j a va 2s.com*/ */ public UDPui() { // <editor-fold defaultstate="collapsed" desc="Graph"> series = new XYSeries("ECG Reading"); series.setMaximumItemCount(50); XYSeriesCollection dataset = new XYSeriesCollection(series); JFreeChart chart = ChartFactory.createXYLineChart("ECG Reading", "Time (seconds)", "Voltage (volt)", dataset); final XYPlot plot = chart.getXYPlot(); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); JPanel jPanel1 = new JPanel(); jPanel1.setLayout(new java.awt.BorderLayout()); jPanel1.setVisible(true); jPanel1.setSize(600, 500); jPanel1.add(new ChartPanel(chart), BorderLayout.CENTER); jPanel1.validate(); add(jPanel1); // </editor-fold> initComponents(); receiveUDP(); // tempReceiveUDP(); // new UDPServer(valuePane); }
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 w w w .j a v a 2s .co 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:de.main.sessioncreator.ReportingHelper.java
public void addReport(JPanel jp) { jp.removeAll();/*from w w w. j a va 2s. co m*/ PieDataset dataset = createDataset(); // based on the dataset we create the chart JFreeChart chart = createChart(dataset, "Sessions by Tester"); // we put the chart into a panel ChartPanel chartPanel = new ChartPanel(chart); chartPanel.updateUI(); chartPanel.setSize(490, 350); jp.revalidate(); jp.setOpaque(true); jp.add(chartPanel); jp.revalidate(); jp.setVisible(true); jp.setSize(700, 500); jp.revalidate(); jp.repaint(); }
From source file:ecg.ecgshow.ECGShowUI.java
private void createGuardData() { GuardDataPanel = new JPanel(); GuardDataPanel.setBackground(new Color(0, 150, 255)); // GuardDataPanel.setBounds(); // BoxLayout layout=new BoxLayout(GuardDataPanel,BoxLayout.Y_AXIS); // GuardDataPanel.setLayout(layout); GroupLayout layout = new GroupLayout(GuardDataPanel); GuardDataPanel.setLayout(layout);//from w w w. ja v a2s .com JPanel temperatureData = new JPanel(); temperatureData.setLayout(new FlowLayout()); // temperatureData.setLayout(null); // temperatureData.setBounds(0,0,(int) (WIDTH * 0.14), (int) (HEIGHT * 0.15)); temperatureData.setSize((int) (WIDTH * 0.16), (int) (HEIGHT * 0.11)); temperatureData.setBackground(new Color(0, 150, 255)); temperatureLabel = new JLabel("--.- "); temperatureLabel.setFont(loadFont("LED.tff", (float) (HEIGHT * 0.070))); temperatureLabel.setBackground(new Color(0, 150, 255)); temperatureLabel.setForeground(Color.RED); // temperatureLabel.setBounds(0,0,200,100); temperatureLabel.setOpaque(true); JLabel temperatureLabelName = new JLabel(" "); temperatureLabelName.setFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.020))); temperatureLabelName.setBackground(new Color(0, 150, 255)); temperatureLabelName.setForeground(Color.BLACK); temperatureLabelName.setBounds(0, 0, 100, 100); temperatureLabelName.setOpaque(true); //?? temperatureData.add(temperatureLabelName); temperatureData.add(temperatureLabel); // JPanel emptyPanel=new JPanel(); // emptyPanel.setSize((int)(WIDTH*0.14),(int)(HEIGHT*0.2)); // emptyPanel.setBackground(new Color(0,150,255)); // GuardDataPanel.add(emptyPanel); JPanel lightValueData = new JPanel(); lightValueData.setLayout(new BorderLayout()); lightValueData.setBackground(new Color(0, 150, 255)); // lightValueData.setBounds(0,(int)(HEIGHT*0.28),(int)(WIDTH*0.14),(int)(HEIGHT*0.30)); lightValueData.setSize((int) (WIDTH * 0.14), (int) (HEIGHT * 0.22)); lightValueDataSet = new DefaultValueDataset(); DialPlot lightValueDialPlot = new DialPlot(); lightValueDialPlot.setDataset(lightValueDataSet); StandardDialFrame dialFrame = new StandardDialFrame(); dialFrame.setVisible(false); lightValueDialPlot.setDialFrame(dialFrame); GradientPaint gradientpaint = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(170, 170, 170)); DialBackground dialBackground = new DialBackground(gradientpaint); dialBackground.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL)); lightValueDialPlot.setBackground(dialBackground); // ?? DialTextAnnotation dialtextannotation = new DialTextAnnotation(""); dialtextannotation.setFont(new Font("Dialog", 0, (int) (0.016 * HEIGHT))); dialtextannotation.setRadius(0.1D); lightValueDialPlot.addLayer(dialtextannotation); DialValueIndicator dialValueIndicator = new DialValueIndicator(0); dialValueIndicator.setFont(new Font("Dialog", Font.PLAIN, (int) (0.011 * HEIGHT))); dialValueIndicator.setOutlinePaint(Color.darkGray); dialValueIndicator.setRadius(0.4D); dialValueIndicator.setAngle(-90.0); lightValueDialPlot.addLayer(dialValueIndicator); StandardDialScale dialScale = new StandardDialScale(); dialScale.setLowerBound(0D); // dialScale.setUpperBound(1024); // dialScale.setMajorTickIncrement(100); dialScale.setStartAngle(-120D); // 120,? dialScale.setExtent(-300D); // 300,? dialScale.setTickRadius(0.85D); // , dialScale.setTickLabelOffset(0.1D); // ,0 bloodDialRange = new StandardDialRange(500D, 750D, Color.red); bloodDialRange.setInnerRadius(0.52000000000000002D); bloodDialRange.setOuterRadius(0.55000000000000004D); lightValueDialPlot.addLayer(bloodDialRange); // bubbleDialRange = new StandardDialRange(0D, 500D, Color.black); bubbleDialRange.setInnerRadius(0.52000000000000002D); bubbleDialRange.setOuterRadius(0.55000000000000004D); lightValueDialPlot.addLayer(bubbleDialRange); // normalDialRange = new StandardDialRange(750D, 1024D, Color.green); normalDialRange.setInnerRadius(0.52000000000000002D); normalDialRange.setOuterRadius(0.55000000000000004D); lightValueDialPlot.addLayer(normalDialRange); dialScale.setTickLabelFont(new Font("Dialog", 0, (int) (0.011 * HEIGHT))); // lightValueDialPlot.addScale(0, dialScale); DialPointer.Pointer pointer = new DialPointer.Pointer(); lightValueDialPlot.addPointer(pointer); lightValueDialPlot.mapDatasetToScale(0, 0); DialCap dialCap = new DialCap(); dialCap.setRadius(0.07D); JFreeChart lightValueDialChart = new JFreeChart(lightValueDialPlot); lightValueDialChart.setBackgroundPaint(new Color(0, 150, 255)); lightValueDialChart.setTitle("??"); lightValueDialChart.getTitle().setFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.020))); ChartPanel lightValueDialChartPanel = new ChartPanel(lightValueDialChart, (int) (WIDTH * 0.15), (int) (HEIGHT * 0.27), 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false, false); lightValueData.add(lightValueDialChartPanel, BorderLayout.CENTER); layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(temperatureData, GroupLayout.Alignment.LEADING) .addComponent(lightValueData, GroupLayout.Alignment.LEADING)))); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap((int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05)) .addComponent(temperatureData) .addGap((int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05)) .addComponent(lightValueData) .addGap((int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05)))); // JPanel alarmMessage=new JPanel(); // alarmMessage.setBackground(new Color(0,150,255)); // alarmMessLabel=new JLabel(""); // alarmMessLabel.setFont(new Font("SansSerif", 0, (int)(HEIGHT *0.020))); // alarmMessLabel.setBackground(new Color(0,150,255)); // alarmMessage.add(alarmMessLabel); // GuardDataPanel.add(alarmMessage); }