List of usage examples for javax.swing JFrame setLocationRelativeTo
public void setLocationRelativeTo(Component c)
From source file:org.onehippo.cms7.launcher.LoggingPanel.java
JFrame createAndShow() { JFrame frame = new JFrame("Server log"); frame.setLocationRelativeTo(null); frame.setSize(600, 200);/*from www . j av a 2 s .c o m*/ frame.add(this); frame.pack(); frame.setResizable(false); startPolling(); return frame; }
From source file:org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement.java
@Override protected void archive(SQLRow row, boolean cutLinks) throws SQLException { // Si on supprime une ecriture on doit supprimer toutes les ecritures du mouvement associ System.err.println("Archivage des critures"); // archiveMouvement(row.getInt("ID_MOUVEMENT")); JFrame frame = new PanelFrame(new SuppressionEcrituresPanel(row.getInt("ID_MOUVEMENT")), "Suppression d'ecritures"); frame.pack();//from w ww. ja v a2s. com frame.setResizable(false); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:org.syphr.mythtv.apps.previewer.Main.java
private static void centerAndSize(JFrame frame, float size) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); frame.setSize((int) (screenSize.getWidth() * size), (int) (screenSize.getHeight() * size)); frame.setLocationRelativeTo(null); }
From source file:org.transitime.gui.ExceptionPanel.java
/** * Initialize the contents of the frame. *//*from ww w.j a v a 2 s.c om*/ private void initialize() { JPanel middlePanel = new JPanel(); middlePanel.setBorder(new TitledBorder(new EtchedBorder(), "Error Starting TransitimeQuickStart")); // create the middle panel components JTextArea display = new JTextArea(35, 90); display.setEditable(false); // set textArea non-editable JScrollPane scroll = new JScrollPane(display); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); //Add Textarea in to middle panel middlePanel.add(scroll); JFrame frame = new JFrame(); frame.add(middlePanel); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); String stackTrace = ExceptionUtils.getStackTrace(ex); display.setText(message + "\n" + ex.toString() + "\n" + stackTrace); }
From source file:paquete.HollywoodUI.java
private void Mostrar_grafoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Mostrar_grafoActionPerformed SimpleGraphView sgv = new SimpleGraphView(); sgv.setGrafo(HollyUniverseGraph);/*w w w. ja va 2s . c o m*/ Layout<Actor, Arista> layout = new CircleLayout(sgv.grafo); layout.setSize(new Dimension(800, 600)); BasicVisualizationServer<Actor, Arista> bvs = new BasicVisualizationServer<>(layout); bvs.setPreferredSize(new Dimension(850, 650)); //agregando etiquetas al grafo Transformer<Actor, Paint> vertexPaint = new Transformer<Actor, Paint>() { public Paint transform(Actor i) { return Color.GREEN; } }; float dash[] = { 10.0f }; final Stroke edgeStroke = new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, dash, 0.0f); Transformer<Arista, Stroke> edgeStrokeTransformer = new Transformer<Arista, Stroke>() { public Stroke transform(Arista s) { return edgeStroke; } }; bvs.getRenderContext().setVertexFillPaintTransformer(vertexPaint); // bvs.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer); bvs.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); bvs.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); bvs.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); JFrame frame = new JFrame("Vista del grafo con libreria JUNG2"); frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); frame.getContentPane().add(bvs); frame.pack(); frame.setLocationRelativeTo(this); frame.setVisible(true); }
From source file:pcgen.gui2.dialog.OptionsPathDialog.java
public static String promptSettingsPath() { JFrame tempFrame = new JFrame("Select Settings Path"); tempFrame.setLocationRelativeTo(null); OptionsPathDialog dialog = new OptionsPathDialog(tempFrame); tempFrame.setVisible(true);/*from w w w. j a va 2s. c o m*/ dialog.setVisible(true); tempFrame.setVisible(false); tempFrame.dispose(); return dialog.selectedDir; }
From source file:qic.launcher.Main.java
private void startGUI(TakeDown installer) { TextAreaWithBackground textArea = new TextAreaWithBackground(); JButton launchButton = new JButton(" Launch "); launchButton.setEnabled(false);//from w w w . j a va2 s . c o m JProgressBar progressBar = new JProgressBar(); launchButton.addActionListener(e -> { runAIC(); System.exit(0); }); JPanel southPanel = new JPanel(); southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.X_AXIS)); southPanel.add(progressBar); southPanel.add(launchButton); JFrame frame = new JFrame("QIC Search Updater"); frame.setIconImage(new ImageIcon(getClass().getResource("/q.png")).getImage()); frame.setLayout(new BorderLayout(5, 5)); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.getContentPane().add(southPanel, BorderLayout.SOUTH); frame.setSize(495, 445); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); textArea.setText("Loading path notes..."); String imgUrl = "http://poeqic.github.io/launcher/images/background.png"; try { Image image = ImageIO.read(new URL(imgUrl)); if (image != null) textArea.setBackgroundImage(image); } catch (IOException ex) { logger.error("Error while loading background image from: " + imgUrl, ex); } Worker<String> pathNotesWorker = new Worker<String>(() -> URLConnectionReader.getText(CHANGELOG_URL), s -> textArea.setText(s), e -> showErrorAndQuit(e)); pathNotesWorker.execute(); Worker<Boolean> updaterWorker = new Worker<Boolean>(() -> { progressBar.setIndeterminate(true); return installer.installOrUpdate(); }, b -> { progressBar.setIndeterminate(false); launchButton.setEnabled(true); }, e -> showErrorAndQuit(e)); updaterWorker.execute(); }
From source file:s3ml.DFA.DFA.java
public JFrame print(boolean visible) { DirectedSparseGraph<State, Transition> graph = new DirectedSparseGraph<>(); for (State s : states) { graph.addVertex(s);/*from w w w. j a v a 2 s. c o m*/ } for (Transition t : transitions) { graph.addEdge(t, t.a, t.b, EdgeType.DIRECTED); } KKLayout<State, Transition> kkLayout = new KKLayout(graph); kkLayout.setSize(new Dimension(600, 600)); final VisualizationViewer<State, Transition> vv = new VisualizationViewer<>(kkLayout); vv.getRenderContext().setVertexLabelTransformer(new Transformer<State, String>() { @Override public String transform(State i) { return i.name; } }); vv.getRenderContext().setEdgeLabelTransformer(new Transformer<Transition, String>() { @Override public String transform(Transition i) { return "" + i.symbol; } }); final Stroke stroke = new Stroke() { private Stroke stroke1, stroke2; { this.stroke1 = new BasicStroke(5f); this.stroke2 = new BasicStroke(1f); } @Override public Shape createStrokedShape(Shape shape) { return stroke2.createStrokedShape(stroke1.createStrokedShape(shape)); } }; vv.getRenderContext().setVertexStrokeTransformer(new Transformer<State, Stroke>() { @Override public Stroke transform(State i) { if (i.startState) { return new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[] { 2.0f }, 0.0f); } else if (i.finalState) { return stroke; } else { return vv.getRenderContext().getGraphicsContext().getStroke(); } } }); vv.getRenderContext().setVertexFillPaintTransformer(new Transformer<State, Paint>() { @Override public Paint transform(State i) { if (i.finalState) { return Color.RED; } else if (i.startState) { return Color.CYAN; } else { return Color.LIGHT_GRAY; } } }); DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); gm.setMode(ModalGraphMouse.Mode.TRANSFORMING); vv.setGraphMouse(gm); final JFrame frame = new JFrame("V:" + graph.getVertexCount() + " E:" + graph.getEdgeCount()); JMenuBar jMenuBar = new JMenuBar(); jMenuBar.add(gm.getModeMenu()); frame.setJMenuBar(jMenuBar); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.getContentPane().add(vv); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(visible); return frame; }
From source file:TrabajoFinalJava.DescargaFichero.java
@Override public void run() { //************************INICIO****INTERFAZ************************************************************************** JFrame principal = new JFrame("GESTOR DESCARGAS"); //Colores/*from w ww. j a v a 2s. com*/ Color nuevoColor = new Color(167, 220, 231); principal.getContentPane().setBackground(nuevoColor); JLabel tituloPrincipal = new JLabel("GESTOR DESCARGAS"); JLabel tituloVentana = new JLabel("DESCARGA FICHERO FTP"); //Recojo la fuente que se esta utilizando actualmente. Font auxFont = tituloPrincipal.getFont(); //Aplico la fuente actual, y al final le doy el tamao del texto... tituloPrincipal.setFont(new Font(auxFont.getFontName(), auxFont.getStyle(), 30)); tituloVentana.setFont(new Font(auxFont.getFontName(), auxFont.getStyle(), 30)); //tituloVentana.setAlignmentY(0); JLabel nombreArchivo = new JLabel("INTRODUCE EL NOMBRE DEL FICHERO A DESCARGAR."); JTextField nombreArchivoIn = new JTextField(); JButton descarga = new JButton("DESCARGA FICHERO."); JButton atras = new JButton("ATRAS"); JButton salir = new JButton("Salir"); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); //Asignamos la constante EXIT_ON_CLOSE, cierra la ventana al pulsar la X. principal.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Asignamos al JFrame el Layout que usaremos, GridBagLayout principal.setLayout(gridbag); //aadir botones al layout gbc.gridx = 1; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; // La fila 0 debe estirarse, le ponemos un 1.0 gbc.fill = GridBagConstraints.HORIZONTAL; principal.add(tituloPrincipal, gbc); gbc.gridx = 1; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; // La fila 0 debe estirarse, le ponemos un 1.0 gbc.fill = GridBagConstraints.NONE; principal.add(tituloVentana, gbc); gbc.gridx = 1; gbc.gridy = 2; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.0; gbc.fill = GridBagConstraints.HORIZONTAL; principal.add(nombreArchivo, gbc); gbc.gridx = 1; gbc.gridy = 3; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.0; gbc.fill = GridBagConstraints.HORIZONTAL; principal.add(nombreArchivoIn, gbc); gbc.gridx = 1; gbc.gridy = 4; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.0; gbc.fill = GridBagConstraints.NONE; principal.add(descarga, gbc); gbc.gridx = 0; gbc.gridy = 5; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; gbc.fill = GridBagConstraints.NONE; principal.add(atras, gbc); gbc.gridx = 1; gbc.gridy = 5; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; // La fila 0 debe estirarse, le ponemos un 1.0 gbc.fill = GridBagConstraints.HORIZONTAL; principal.add(salir, gbc); //Hace visible el panel principal.setVisible(true); principal.setSize(650, 350); principal.setLocationRelativeTo(null); principal.setResizable(false); //principal.pack(); descarga.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (descargasUsuarioLog <= 9) { try { cFtp.connect(ftpSsrver); boolean login = cFtp.login(ftpUser, ftpPass); System.out.print("conexion establecida"); cFtp.enterLocalPassiveMode(); nombreFichero = nombreArchivoIn.getText(); nombrePc = nombreArchivoIn.getText(); CrearListaFicheros listarFicheros = new CrearListaFicheros(); listarFicheros.start(); for (int i = 0; i < CrearListaFicheros.arrayArchivos.size(); i++) { System.out.println(CrearListaFicheros.arrayArchivos.get(i)); } if (CrearListaFicheros.arrayArchivos.contains(nombreFichero)) { FTPFile file = cFtp.mlistFile(nombreFichero); long size = file.getSize(); System.out.println("Tamao del fichero= " + size); if (size > 1000000) { System.out.println("El fichero es muy grande......"); } else { FileOutputStream fos = new FileOutputStream(nombreFichero); cFtp.retrieveFile(nombreFichero, fos); System.out.println(""); System.out.println("Archivo recibido"); nombreArchivoIn.setBackground(Color.green); descargasUsuarioLog = descargasUsuarioLog + 1; System.out.println(descargasUsuarioLog); //modificamos las descargas totales del usuario en la BBDD Connection conn; try { try { Class.forName("com.mysql.jdbc.Driver"); } catch (Exception y) { y.printStackTrace(); } conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/midb", "root", ""); System.out.println("Conn OK!"); stmt = conn.createStatement(); stmt.executeUpdate("UPDATE usuarios SET bajadas = '" + descargasUsuarioLog + "' WHERE usuario = '" + usuarioLog + "';"); System.out.print("Descargas modificadas correctamente."); conn.close(); } catch (Exception i) { System.out.println(e); } } } else { System.out.println("El fichero no existe..."); nombreArchivoIn.setText("El fichero no existe"); } } catch (IOException r) { r.printStackTrace(); } } else { System.out.println( "No te quedan descargas... por favor comuniquese con el administrador del servidor. Gracias."); nombreArchivoIn.setText( "No te quedan descargas... por favor comuniquese con el administrador del servidor. Gracias."); } } }); atras.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FormularioAccesoFtp accesoFtp = new FormularioAccesoFtp(); accesoFtp.inicioFtp(); principal.setVisible(false); } }); salir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(1000); } }); }
From source file:TrabajoFinalJava.FormularioVerFicheros.java
public void run() { //************************INICIO****INTERFAZ************************************************************************** JFrame principal = new JFrame("GESTOR DESCARGAS"); //Colores// w w w . j a va2 s .c om Color nuevoColor = new Color(167, 220, 231); principal.getContentPane().setBackground(nuevoColor); JLabel tituloPrincipal = new JLabel("GESTOR DESCARGAS"); JLabel tituloVentana = new JLabel("VER FICHEROS"); JTextArea cajaFicheros = new JTextArea(12, 20); JButton mostrar = new JButton("MOSTRAR FICHEROS"); JButton atras = new JButton("ATRAS"); JButton salir = new JButton("SALIR"); cajaFicheros.setEditable(false); //Recojo la fuente que se esta utilizando actualmente. Font auxFont = tituloPrincipal.getFont(); //Aplico la fuente actual, y al final le doy el tamao del texto... tituloPrincipal.setFont(new Font(auxFont.getFontName(), auxFont.getStyle(), 30)); tituloVentana.setFont(new Font(auxFont.getFontName(), auxFont.getStyle(), 30)); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); //Asignamos la constante EXIT_ON_CLOSE, cierra la ventana al pulsar la X. principal.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Asignamos al JFrame el Layout que usaremos, GridBagLayout principal.setLayout(gridbag); //aadir botones al layout gbc.gridx = 1; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; gbc.fill = GridBagConstraints.HORIZONTAL; principal.add(tituloPrincipal, gbc); gbc.gridx = 1; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; gbc.fill = GridBagConstraints.NONE; principal.add(tituloVentana, gbc); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; gbc.fill = GridBagConstraints.HORIZONTAL; principal.add(new JScrollPane(cajaFicheros), gbc); gbc.gridx = 1; gbc.gridy = 3; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; gbc.fill = GridBagConstraints.NONE; principal.add(mostrar, gbc); gbc.gridx = 0; gbc.gridy = 4; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; gbc.fill = GridBagConstraints.NONE; principal.add(atras, gbc); gbc.gridx = 1; gbc.gridy = 4; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weighty = 0.1; gbc.fill = GridBagConstraints.NONE; principal.add(salir, gbc); //cajaFicheros.setEditable(false); //Hace visible el panel principal.setVisible(true); principal.setSize(650, 350); principal.setLocationRelativeTo(null); principal.setResizable(false); //principal.pack(); mostrar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String ftpSsrver = "127.0.0.1"; String ftpUser = "solera"; String ftpPass = "solera"; FTPClient cFtp = new FTPClient(); try { cFtp.connect(ftpSsrver); boolean login = cFtp.login(ftpUser, ftpPass); System.out.print("conexion ftp para ver ficheros establecida"); cFtp.enterLocalPassiveMode(); String[] archivos = cFtp.listNames(); FTPFile[] detalles = cFtp.listFiles(); archivos = cFtp.listNames(); for (int i = 0; i < archivos.length; i++) { /* cajaFicheros.selectAll(); cajaFicheros.replaceSelection(""); */ arrayArchivos.add(archivos[i].toString()); System.out.println(arrayArchivos.get(i)); cajaFicheros.append(System.getProperty("line.separator")); cajaFicheros.append(arrayArchivos.get(i)); } cFtp.logout(); cFtp.disconnect(); System.out.println("Conexion Finalizada, buenas tardes."); } catch (IOException ioe) { System.out.println("error" + ioe.toString()); } } }); try { salir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); } catch (Exception e) { } try { atras.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FormularioAccesoFtp accesoFtp = new FormularioAccesoFtp(); accesoFtp.inicioFtp(); principal.setVisible(false); } }); } catch (Exception e) { } }