List of usage examples for javax.swing JFrame setLocationRelativeTo
public void setLocationRelativeTo(Component c)
From source file:org.leo.benchmark.Benchmark.java
/** * Display Memory results//from w ww. j a v a2 s. c om */ public void displayMemoryResults() { ChartPanel chart = createChart("Memory usage of collections", "Memory usage (bytes) of collections populated by " + populateSize + " element(s)", memoryResults, new StandardCategoryItemLabelGenerator()); JFrame frame = new JFrame("Collection Implementations Benchmark"); frame.getContentPane().add(chart, BorderLayout.CENTER); frame.setSize(900, 500); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:com.ywh.train.logic.TrainClient.java
/** * url??// w w w.java2 s .com * @param url * @return * @throws IOException */ String getCode(String url) throws IOException { JFrame frame = new JFrame("??"); JLabel label = new JLabel(new ImageIcon(getCodeByte(url)), JLabel.CENTER); frame.add(label); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(300, 200); frame.setLocationRelativeTo(null); frame.setVisible(true); InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); String rd = br.readLine(); frame.dispose(); return rd; }
From source file:umontreal.iro.lecuyer.charts.BoxChart.java
/** * Displays chart on the screen using Swing. * This method creates an application containing a chart panel displaying * the chart. The created frame is positioned on-screen, and displayed before * it is returned. The circle represents the mean, the dark line inside the box * is the median, the box limits are the first and third quartiles, * the lower whisker (the lower line outside the box) is the first decile, * and the upper whisker is the ninth decile. The outliers, if any, are * represented by empty circles, or arrows if outside the range bounds. * /*from w ww. jav a 2 s . co m*/ * @param width frame width. * * @param height frame height. * * @return frame containing the chart.; * */ public JFrame view(int width, int height) { JFrame myFrame; if (chart.getTitle() != null) myFrame = new JFrame("BoxChart from SSJ : " + chart.getTitle().getText()); else myFrame = new JFrame("BoxChart from SSJ"); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(width, height)); myFrame.setContentPane(chartPanel); myFrame.pack(); myFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); myFrame.setLocationRelativeTo(null); myFrame.setVisible(true); return myFrame; }
From source file:adapters.BoxChartAdapter.java
/** * Modified Method: set visible to be false * * Displays chart on the screen using Swing. * This method creates an application containing a chart panel displaying * the chart. The created frame is positioned on-screen, and displayed before * it is returned. The circle represents the mean, the dark line inside the box * is the median, the box limits are the first and third quartiles, * the lower whisker (the lower line outside the box) is the first decile, * and the upper whisker is the ninth decile. The outliers, if any, are * represented by empty circles, or arrows if outside the range bounds. * * @param width frame width./* ww w . j av a2s .com*/ * * @param height frame height. * * @return frame containing the chart.; * */ public JFrame view(int width, int height) { JFrame myFrame; if (chart.getTitle() != null) myFrame = new JFrame("BoxChart: " + chart.getTitle().getText()); else myFrame = new JFrame("BoxChart"); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(width, height)); myFrame.setContentPane(chartPanel); myFrame.pack(); myFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); myFrame.setLocationRelativeTo(null); // myFrame.setVisible (true); return myFrame; }
From source file:userInterface.DistrictAdminRole.MonitorNeighborhoodAreasJPanel.java
public void browserMethod() { Neighborhood area = (Neighborhood) areasComboBox.getSelectedItem(); Browser browser = new Browser(); BrowserView view = new BrowserView(browser); JFrame frame = new JFrame("JxBrowser Google Maps"); frame.add(view, BorderLayout.CENTER); frame.setSize(700, 500);/*ww w . j a v a 2 s .c o m*/ frame.setLocationRelativeTo(null); frame.setVisible(true); browser.loadURL("https://www.google.com/maps/place/" + area); }
From source file:ita.parthenope.twitternlp.semantic.CloudOfWords.java
/** * Costruzione della cloud e visualizzazione. * @throws IOException/*from ww w.j a v a 2 s .c om*/ */ public void buildCloud() throws IOException { final JFrame frame = new JFrame("Kumo: WordCloud Generator"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //This function attach AWT Component to JPanel Component component = assembler(); frame.add(component); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:umontreal.iro.lecuyer.charts.EmpiricalChart.java
/** * Displays chart on the screen using Swing. * This method creates an application containing a chart panel displaying * the chart. The created frame is positioned on-screen, and displayed before * it is returned. The <TT>width</TT> and the <TT>height</TT> * of the chart are measured in pixels. * /*from w ww . j a v a 2s. c om*/ * @param width frame width in pixels. * * @param height frame height in pixels. * * @return frame containing the chart. * */ public JFrame view(int width, int height) { JFrame myFrame; if (chart.getTitle() != null) myFrame = new JFrame("EmpiricalChart from SSJ : " + chart.getTitle().getText()); else myFrame = new JFrame("EmpiricalChart from SSJ"); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(width, height)); myFrame.setContentPane(chartPanel); myFrame.pack(); myFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); myFrame.setLocationRelativeTo(null); myFrame.setVisible(true); return myFrame; }
From source file:courseapplication.CourseApplication1.java
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed double[] xValues = data.getxValues(); double[] yValues = data.getyValues(); double step = 0.0001; double[] xValuesForGraph = prepareArray(xValues, step); double[] polinom = new double[xValuesForGraph.length]; double[] lagr = new double[xValuesForGraph.length]; XYSeries seriesFunction = new XYSeries("Function values"); XYSeries seriesLagranje = new XYSeries("Lagranje values"); XYSeries seriesPolinom = new XYSeries("Polinom values"); double[] yValuesForGraph = new double[xValuesForGraph.length]; for (int i = 0; i < yValuesForGraph.length; i++) { yValuesForGraph[i] = data.function(function, (xValuesForGraph[i])); }// w ww. j a v a2 s .c o m for (int i = 0; i < yValuesForGraph.length; i++) { polinom[i] = interpolation.polinomInterpolation(polinomResult, xValuesForGraph[i]); lagr[i] = interpolation.lagranjeInterpolation(xValues, yValues, xValuesForGraph[i]); } for (int i = 0; i < xValuesForGraph.length; i++) { seriesFunction.add(xValuesForGraph[i], yValuesForGraph[i]); seriesLagranje.add(xValuesForGraph[i], lagr[i]); seriesPolinom.add(xValuesForGraph[i], polinom[i]); } XYSeriesCollection data = new XYSeriesCollection(); data.addSeries(seriesFunction); data.addSeries(seriesLagranje); data.addSeries(seriesPolinom); // XYDataset data = new XYSeriesCollection(seriesFunction); JFreeChart chart = ChartFactory.createXYLineChart("Function values and approximation functions", "X", "F(x)", data, PlotOrientation.VERTICAL, true, true, true); JFrame frameForGraphic = new JFrame("Graphic"); XYPlot plot = chart.getXYPlot(); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.GREEN); renderer.setSeriesPaint(1, Color.BLUE); renderer.setSeriesPaint(2, Color.PINK); frameForGraphic.getContentPane().add(new ChartPanel(chart)); frameForGraphic.show(); frameForGraphic.setPreferredSize(new Dimension(800, 600)); frameForGraphic.setLocationRelativeTo(null); frameForGraphic.pack(); }
From source file:umontreal.iro.lecuyer.charts.HistogramChart.java
/** * Displays chart on the screen using Swing. * This method creates an application containing a chart panel displaying * the chart. The created frame is positioned on-screen, and displayed before * it is returned. The <TT>width</TT> and the <TT>height</TT> * of the chart are measured in pixels. * /* w w w . j a v a 2s . co m*/ * @param width frame width in pixels. * * @param height frame height in pixels. * * @return frame containing the chart. * */ public JFrame view(int width, int height) { JFrame myFrame; if (chart.getTitle() != null) myFrame = new JFrame("HistogramChart from SSJ: " + chart.getTitle().getText()); else myFrame = new JFrame("HistogramChart from SSJ"); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(width, height)); myFrame.setContentPane(chartPanel); myFrame.pack(); myFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); myFrame.setLocationRelativeTo(null); myFrame.setVisible(true); return myFrame; }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopTabSheet.java
protected void detachTab(final int tabIndex) { final JComponent tabContent = (JComponent) impl.getComponentAt(tabIndex); TabImpl tabAtIndex = null;//from w ww . j ava 2 s . co m for (TabImpl tab : tabs) { if (DesktopComponentsHelper.getComposition(tab.getComponent()) == tabContent) { tabAtIndex = tab; if (tab.isLazy() && !tab.isLazyInitialized()) { initLazyTab(tabContent); } break; } } if (tabAtIndex == null) { throw new IllegalStateException("Unable to find tab to detach"); } final TabImpl tabToDetach = tabAtIndex; final ButtonTabComponent tabComponent = tabToDetach.getButtonTabComponent(); final JFrame frame = new DetachedFrame(tabComponent.getCaption(), impl); frame.setLocationRelativeTo(DesktopComponentsHelper.getTopLevelFrame(this)); impl.remove(tabContent); updateTabsEnabledState(); frame.setSize(impl.getSize()); frame.add(tabContent); final HierarchyListener listener = new HierarchyListener() { @Override public void hierarchyChanged(HierarchyEvent e) { if ((e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) == HierarchyEvent.DISPLAYABILITY_CHANGED && !impl.isDisplayable()) { attachTab(frame, tabToDetach); impl.removeHierarchyListener(this); } } }; frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { attachTab(frame, tabToDetach); impl.removeHierarchyListener(listener); } }); impl.addHierarchyListener(listener); frame.setVisible(true); }