List of usage examples for javax.swing JFrame setLocation
@Override public void setLocation(int x, int y)
The method changes the geometry-related data.
From source file:StdErrOutWindows.java
public StdErrOutWindows() { JScrollPane pain = new JScrollPane(outArea); JFrame outFrame = new JFrame("out"); outFrame.getContentPane().add(pain); outFrame.setVisible(true);//from w w w. j a va 2 s .c o m pain = new JScrollPane(errArea); JFrame errFrame = new JFrame("err"); errFrame.getContentPane().add(pain); errFrame.setLocation(errFrame.getLocation().x + 20, errFrame.getLocation().y + 20); errFrame.setVisible(true); System.setOut(new PrintStream(new JTextAreaOutputStream(outArea))); System.setErr(new PrintStream(new JTextAreaOutputStream(errArea))); }
From source file:Main.java
public Main() { DefaultMutableTreeNode root = new DefaultMutableTreeNode("ROOT"); DefaultTreeModel model = new DefaultTreeModel(root); JTree tree = new JTree(model); buildTreeFromString(model, "A/D/E/Node 4"); buildTreeFromString(model, "A/C/F/Node 5"); buildTreeFromString(model, "A/B/G/Node 6"); buildTreeFromString(model, "A/C/H/Node 5"); buildTreeFromString(model, "A/B/G/Node 5"); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(tree);/* ww w .java 2 s . c o m*/ f.setSize(300, 300); f.setLocation(200, 200); f.setVisible(true); }
From source file:Main.java
void start() { ToolTipManager ttm = ToolTipManager.sharedInstance(); ttm.setInitialDelay(0);/*from www.j av a 2 s. c o m*/ ttm.setDismissDelay(10000); Main newContentPane = new Main(); newContentPane.setOpaque(true); JFrame frame = new JFrame("Main"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(newContentPane); frame.pack(); frame.setLocation(150, 150); frame.setVisible(true); }
From source file:Main.java
public Fonts() { doc = jta.getStyledDocument();//from w w w. ja v a 2 s . co m JScrollPane jsp = new JScrollPane(jta); jsp.setPreferredSize(new Dimension(400, 400)); JFrame frm = new JFrame(); frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frm.setLayout(new BorderLayout()); frm.add(jsp, BorderLayout.CENTER); frm.setLocation(100, 100); frm.pack(); frm.setVisible(true); jta.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); fnt = ge.getAvailableFontFamilyNames(); mas = jta.getInputAttributes(); new Thread(this).start(); }
From source file:jyplot.XYErrorBar.ErrorBarDemo.java
public ErrorBarDemo() { XYDataset dataset = createDataset(); JPanel chartPanel = createChartPanel(dataset); JFrame frame = new JFrame("Error Bar Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(chartPanel); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); frame.pack();/*from ww w. j av a 2 s . c o m*/ frame.setLocation((screenSize.width - frame.getWidth()) / 2, (screenSize.height - frame.getHeight()) / 2); frame.show(); }
From source file:turtlekit.viewer.PopulationCharter.java
@Override public void setupFrame(JFrame frame) { final ChartPanel chartPanel = ChartsUtil.createChartPanel(dataset, "Population", null, null); chartPanel.setPreferredSize(new java.awt.Dimension(550, 250)); frame.setContentPane(chartPanel);//from www . ja v a 2 s. co m frame.setLocation(50, 0); }
From source file:AppPackage.HumidityGraph.java
/** * */// w ww .j a v a2s . com public HumidityGraph() { try { JFrame window = new JFrame(); window.setSize(1000, 615); window.setBackground(Color.blue); Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); int x = (int) ((dimension.getWidth() - window.getWidth()) / 2); int y = (int) ((dimension.getHeight() - window.getHeight()) / 2); window.setLocation(x, y); XYSeries series = new XYSeries("Humidity "); XYSeriesCollection dataset = new XYSeriesCollection(series); JFreeChart chart = ChartFactory.createXYLineChart("Humidity against Time", "Time(seconds)", "Humidity(percentage)", dataset); window.add(new ChartPanel(chart), BorderLayout.CENTER); window.setVisible(true); } catch (Exception e) { System.out.print("Chart exception:" + e); } initComponents(); }
From source file:com.googlecode.gmail4j.util.LoginDialog.java
/** * Centers the frame on screen// w w w.j a v a 2 s. c o m * * @param frame Target frame */ private void center(final JFrame frame) { final Rectangle screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getDefaultConfiguration().getBounds(); frame.setLocation(screen.width / 2 - dialog.getSize().width / 2, screen.height / 2 - dialog.getSize().height / 2); }
From source file:AppPackage.Temperature.java
public Temperature() { try {//from www.j a va 2s .co m JFrame window = new JFrame(); window.setSize(1000, 615); window.setBackground(Color.blue.darker()); double value = 55; Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); int x = (int) ((dimension.getWidth() - window.getWidth()) / 2); int y = (int) ((dimension.getHeight() - window.getHeight()) / 2); window.setLocation(x, y); DefaultValueDataset dataset = new DefaultValueDataset(value); ThermometerPlot thermometerplot = new ThermometerPlot(dataset); thermometerplot.setSubrangePaint(0, Color.green.darker()); thermometerplot.setSubrangePaint(1, Color.orange); thermometerplot.setSubrangePaint(2, Color.red); JFreeChart jfreechart = new JFreeChart("Temperature readings", JFreeChart.DEFAULT_TITLE_FONT, thermometerplot, true); thermometerplot.setInsets(new RectangleInsets(5D, 5D, 5D, 5D)); thermometerplot.setPadding(new RectangleInsets(10D, 10D, 10D, 10D)); thermometerplot.setThermometerStroke(new BasicStroke(2.0F)); thermometerplot.setThermometerPaint(Color.BLUE); thermometerplot.setGap(3); window.add(new ChartPanel(jfreechart), BorderLayout.CENTER); window.setVisible(true); } catch (Exception e) { System.out.print("Chart exception:" + e); } initComponents(); }
From source file:AppPackage.humidity.java
public humidity() { try {// w w w .j av a 2 s . c om JFrame window = new JFrame(); window.setSize(1000, 615); window.setBackground(Color.blue.darker()); double value = 45; Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); int x = (int) ((dimension.getWidth() - window.getWidth()) / 2); int y = (int) ((dimension.getHeight() - window.getHeight()) / 2); window.setLocation(x, y); DefaultValueDataset dataset = new DefaultValueDataset(value); ThermometerPlot thermometerplot = new ThermometerPlot(dataset); thermometerplot.setSubrangePaint(0, Color.green.darker()); thermometerplot.setSubrangePaint(1, Color.orange); thermometerplot.setSubrangePaint(2, Color.red); JFreeChart jfreechart = new JFreeChart("Humidity readings", JFreeChart.DEFAULT_TITLE_FONT, thermometerplot, true); thermometerplot.setInsets(new RectangleInsets(5D, 5D, 5D, 5D)); thermometerplot.setPadding(new RectangleInsets(10D, 10D, 10D, 10D)); thermometerplot.setThermometerStroke(new BasicStroke(2.0F)); thermometerplot.setThermometerPaint(Color.BLUE); thermometerplot.setUnits(0); thermometerplot.setGap(3); window.add(new ChartPanel(jfreechart), BorderLayout.CENTER); window.setVisible(true); } catch (Exception e) { System.out.print("Chart exception:" + e); } initComponents(); }