List of usage examples for javax.swing JFrame setLocationRelativeTo
public void setLocationRelativeTo(Component c)
From source file:task5.Histogram.java
private void display() { JFrame f = new JFrame("Histogram"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(createChartPanel());/*from w ww .ja v a 2 s .c om*/ f.add(createControlPanel(), BorderLayout.SOUTH); f.add(new JLabel(new ImageIcon(img)), BorderLayout.WEST); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); }
From source file:pdi.HistogramaRGB.java
private void mostraTela() { JFrame f = new JFrame("PDI - Histograma"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(criaHistograma(), BorderLayout.EAST); f.add(new JLabel(new ImageIcon(imagem)), BorderLayout.WEST); f.add(criaPainel(), BorderLayout.SOUTH); f.pack();// ww w. j a v a 2 s . com f.setLocationRelativeTo(f); f.setVisible(true); }
From source file:com.diversityarrays.kdxplore.curate.fieldview.OverviewDialog.java
@SuppressWarnings("unchecked") public OverviewDialog(Window window, String title, @SuppressWarnings("rawtypes") ComboBoxModel comboBoxModel, CurationData curationData, Transformer<TraitInstance, String> tiNameProvider, OverviewInfoProvider overviewInfoProvider, FieldViewSelectionModel fvsm, FieldLayoutTableModel fltm, CurationTableModel ctm) { super(window, title, ModalityType.MODELESS); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setAlwaysOnTop(true);//from ww w .ja v a 2s . co m this.fieldViewSelectionModel = fvsm; @SuppressWarnings({ "rawtypes" }) JComboBox activeTiCombo = new JComboBox(comboBoxModel); TraitInstanceCellRenderer tiCellRenderer = new TraitInstanceCellRenderer( curationData.getTraitColorProvider(), tiNameProvider); activeTiCombo.setRenderer(tiCellRenderer); JLabel infoLabel = new JLabel(" "); infoLabel.setBorder(new BevelBorder(BevelBorder.LOWERED)); final JFrame[] helpDialog = new JFrame[1]; Action helpAction = new AbstractAction("?") { @Override public void actionPerformed(ActionEvent e) { if (helpDialog[0] != null) { GuiUtil.restoreFrame(helpDialog[0]); } else { JFrame f = new JFrame("Overview Help"); helpDialog[0] = f; f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setAlwaysOnTop(true); f.setLocationRelativeTo(overview); String html = Overview.getOverviewHelpHtml(); JLabel label = new JLabel(html); label.setBorder(new EmptyBorder(0, 10, 0, 10)); f.setContentPane(label); f.pack(); f.setVisible(true); } } }; // Window window = GuiUtil.getOwnerWindow(FieldLayoutViewPanel.this); if (window != null) { if (window instanceof JFrame) { System.out.println("Found window: " + ((JFrame) window).getTitle()); } window.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { window.removeWindowListener(this); if (helpDialog[0] != null) { helpDialog[0].dispose(); } } }); } KDClientUtils.initAction(ImageId.HELP_24, helpAction, "Help for Overview"); Box top = Box.createHorizontalBox(); top.add(activeTiCombo); top.add(new JButton(helpAction)); overview = new Overview(overviewInfoProvider, fltm, curationData, ctm, infoLabel); overview.setActiveTraitInstance(fvsm.getActiveTraitInstance(true)); Container cp = getContentPane(); cp.add(top, BorderLayout.NORTH); // cp.add(traitLabel, BorderLayout.NORTH); cp.add(infoLabel, BorderLayout.SOUTH); cp.add(overview, BorderLayout.CENTER); pack(); // setResizable(false); // setLocationRelativeTo(showOverviewButton); // DEFAULT POSITION is "out of the way" setVisible(true); this.fieldViewSelectionModel.addListSelectionListener(listSelectionListener); addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { toFront(); } @Override public void windowClosed(WindowEvent e) { fieldViewSelectionModel.removeListSelectionListener(listSelectionListener); removeWindowListener(this); } }); }
From source file:gui.accessories.BattleSimFx.java
@Override public void start() { SwingUtilities.invokeLater(new Runnable() { @Override// ww w . j a v a 2 s . c om public void run() { JFrame frame = new JFrame("Swing JTable"); frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); JApplet applet = new BattleSimFx(); applet.init(); frame.setContentPane(applet.getContentPane()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); // applet.start(); } }); }
From source file:task5.deneme.java
private void display() { JFrame f = new JFrame("Histogram"); f.add(createChartPanel());//w w w. j a v a 2s . c o m f.add(createControlPanel(), BorderLayout.SOUTH); f.add(new JLabel(new ImageIcon(img)), BorderLayout.WEST); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); }
From source file:ar.com.mantinanmatias.calculadoraderivadas.Interface.java
public void GraficarFuncion(String funcion, Node nodo_funcion, double desde, double hasta, double intervalo) throws ParseException { XYSeries seriesPuntos = new XYSeries("Puntos"); double[] valores_x = increment(desde, intervalo, hasta); double[] valores_y = ObtenerValoresFuncion(valores_x, seriesPuntos, funcion, nodo_funcion); XYSeriesCollection dataset = new XYSeriesCollection(seriesPuntos); JFreeChart graficoXY = ChartFactory.createXYLineChart(funcion, "x", "y", dataset, PlotOrientation.VERTICAL, true, true, false);//from ww w . j a va2 s . com ChartPanel panelGrafico = new ChartPanel(graficoXY); //Plot2DPanel panelGrafico= new Plot2DPanel(); // panelGrafico.addLinePlot(funcion, valores_x, valores_y); JFrame ventanaGrafico = new JFrame("Grfico"); ventanaGrafico.setSize(500, 500); ventanaGrafico.setContentPane(panelGrafico); ventanaGrafico.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); ventanaGrafico.setLocationRelativeTo(null); ventanaGrafico.setVisible(true); }
From source file:classpackage.ChartGalaxy.java
public ChartGalaxy() { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); XYDataset dataset = createDataset(); JFreeChart chart = createChart(dataset); ChartPanel chartPanel = new ChartPanel(chart) { @Override//from w ww . j a v a 2 s.c o m public Dimension getPreferredSize() { return new Dimension(1000, 500); } }; f.add(chartPanel); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); }
From source file:Trabalho.HistogramaHSB.java
private void mostraTela() throws IOException { JFrame f = new JFrame("PDI - Histograma"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(criaHistograma(), BorderLayout.EAST); f.add(new JLabel(new ImageIcon(imagem)), BorderLayout.WEST); f.add(criaPainel(), BorderLayout.SOUTH); f.pack();/* ww w . j a va 2 s .co m*/ f.setLocationRelativeTo(f); f.setVisible(true); }
From source file:misc.TextBatchPrintingDemo.java
/** * Create and display the main application frame. *//*from w w w . j av a 2 s. c o m*/ void createAndShowGUI() { messageArea = new JLabel(defaultMessage); selectedPages = new JList(new DefaultListModel()); selectedPages.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); selectedPages.addListSelectionListener(this); setPage(homePage); JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(pageItem), new JScrollPane(selectedPages)); JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); /** Menu item and keyboard shortcuts for the "add page" command. */ fileMenu.add(createMenuItem(new AbstractAction("Add Page") { public void actionPerformed(ActionEvent e) { DefaultListModel pages = (DefaultListModel) selectedPages.getModel(); pages.addElement(pageItem); selectedPages.setSelectedIndex(pages.getSize() - 1); } }, KeyEvent.VK_A, KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.ALT_MASK))); /** Menu item and keyboard shortcuts for the "print selected" command.*/ fileMenu.add(createMenuItem(new AbstractAction("Print Selected") { public void actionPerformed(ActionEvent e) { printSelectedPages(); } }, KeyEvent.VK_P, KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.ALT_MASK))); /** Menu item and keyboard shortcuts for the "clear selected" command.*/ fileMenu.add(createMenuItem(new AbstractAction("Clear Selected") { public void actionPerformed(ActionEvent e) { DefaultListModel pages = (DefaultListModel) selectedPages.getModel(); pages.removeAllElements(); } }, KeyEvent.VK_C, KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.ALT_MASK))); fileMenu.addSeparator(); /** Menu item and keyboard shortcuts for the "home page" command. */ fileMenu.add(createMenuItem(new AbstractAction("Home Page") { public void actionPerformed(ActionEvent e) { setPage(homePage); } }, KeyEvent.VK_H, KeyStroke.getKeyStroke(KeyEvent.VK_H, ActionEvent.ALT_MASK))); /** Menu item and keyboard shortcuts for the "quit" command. */ fileMenu.add(createMenuItem(new AbstractAction("Quit") { public void actionPerformed(ActionEvent e) { for (Window w : Window.getWindows()) { w.dispose(); } } }, KeyEvent.VK_A, KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.ALT_MASK))); JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); JPanel contentPane = new JPanel(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); contentPane.add(pane); contentPane.add(messageArea); JFrame frame = new JFrame("Text Batch Printing Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setJMenuBar(menuBar); frame.setContentPane(contentPane); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); if (printService == null) { // Actual printing is not possible, issue a warning message. JOptionPane.showMessageDialog(frame, "No default print service", "Print Service Alert", JOptionPane.WARNING_MESSAGE); } }
From source file:org.keyboardplaying.xtt.ui.UIController.java
private Window makeWindow(String titleKey, String iconKey, Container content) { /* The basics. */ JFrame window = new I14edJFrame(i18n, titleKey); window.setIconImages(images.getImages(iconKey)); /* Make sure thread is ended when window is closed. */ window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); /* Add content and adapt size to fit the content. */ window.setContentPane(content);/*from w w w. j av a2s. c om*/ window.pack(); // Center on screen window.setLocationRelativeTo(null); return window; }