Example usage for javax.swing JOptionPane getFrameForComponent

List of usage examples for javax.swing JOptionPane getFrameForComponent

Introduction

In this page you can find the example usage for javax.swing JOptionPane getFrameForComponent.

Prototype

public static Frame getFrameForComponent(Component parentComponent) throws HeadlessException 

Source Link

Document

Returns the specified component's Frame.

Usage

From source file:edu.ucla.stat.SOCR.motionchart.MotionMouseListener.java

protected Point getDialogLocation(JDialog dialog, Component c) {
    Frame frame = JOptionPane.getFrameForComponent(c);
    int x = frame.getX() + (frame.getWidth() - dialog.getWidth()) / 2;
    int y = frame.getY() + (frame.getHeight() - dialog.getHeight()) / 2;
    return new Point(x, y);
}

From source file:com.projity.pm.graphic.xbs.XbsInteractor.java

public void showDependencyPropertiesDialog(final GraphicDependency dependency) {
    if (dependencyPropertiesDialog == null) {
        Frame parent = JOptionPane.getFrameForComponent(getGraph());
        dependencyPropertiesDialog = new XbsDependencyDialog(parent, dependency);
    }/*from w ww.  j  a va 2  s.c  o m*/
    boolean didAction = XbsDependencyDialog.doDialog(dependencyPropertiesDialog, dependency, new Closure() {
        public void execute(Object arg0) {
            Node child = dependency.getSuccessor().getNode();
            int position = 0;
            TreeNode[] path = ((NodeBridge) child).getPath();
            if (path.length > 1) {
                NodeBridge previous = (NodeBridge) path[1];
                position = previous.getRoot().getIndex(previous) + 1;
            }
            List nodes = new LinkedList();
            nodes.add(child);
            getGraph().getModel().getCache().getModel().move(null, nodes, position, NodeModel.NORMAL);
        }
    });
}

From source file:com.projity.pm.graphic.graph.GraphInteractor.java

public void showDependencyPropertiesDialog(GraphicDependency dependency) {
    GraphicManager.getInstance().lockProject(); // pre-lock project for timeout issue
    if (dependencyPropertiesDialog == null) {
        Frame parent = JOptionPane.getFrameForComponent(getGraph());
        dependencyPropertiesDialog = new DependencyDialog(parent, dependency.getDependency());
    }//from   w  w w  .jav  a2  s .  c  o  m
    dependencyPropertiesDialog.setShowEnabled(!GraphicManager.getInstance().isProjectLockedByOther());

    boolean didAction = DependencyDialog.doDialog(dependencyPropertiesDialog, dependency.getDependency());
}

From source file:com.biosis.biosislite.vistas.dialogos.DlgEmpleadoCRUD.java

public DlgEmpleadoCRUD(JInternalFrame parent, Empleado empleado, int accion) {
    super(JOptionPane.getFrameForComponent(parent), true);
    this.empleado = empleado;
    this.accion = accion;
    padre = parent;//from  ww w .ja  v  a  2  s  .  c o  m
    initComponents();
    iniciar();
    ec = new EmpleadoControlador();
    agregar = true;
    ec.setSeleccionado(empleado);
    if (this.accion == Controlador.MODIFICAR) {
        this.mostrarDatos(empleado);
    }
    if (this.accion == Controlador.NUEVO) {
        tab = false;
        this.tblPane.setEnabledAt(2, false);
    }

    this.setLocationRelativeTo(parent);
    listarArea();
    listarContratos();
    listarCargos();

    FormularioUtil.activarComponente(panelDatosC, false);
    FormularioUtil.activarComponente(panelDatosA, false);
    FormularioUtil.activarComponente(panelDatosP, false);

}

From source file:livecanvas.mesheditor.MeshEditor.java

private void open(File file) {
    if (file == null) {
        FileDialog fd = new FileDialog(JOptionPane.getFrameForComponent(MeshEditor.this), "Load");
        fd.setVisible(true);/*from  w  w  w  . j av a  2s .co m*/
        String file_str = fd.getFile();
        if (file_str == null) {
            return;
        }
        file = new File(fd.getDirectory() + "/" + file_str);
    }
    try {
        StringWriter out = new StringWriter();
        InputStreamReader in = new InputStreamReader(new FileInputStream(file));
        Utils.copy(in, out);
        in.close();
        out.close();
        clear();
        JSONObject doc = new JSONObject(out.toString());
        Layer rootLayer = Layer.fromJSON(doc.getJSONObject("rootLayer"));
        layersView.setRootLayer(rootLayer);
        rootLayer.setCanvas(canvas);
        for (Layer layer : rootLayer.getSubLayersRecursively()) {
            layer.setCanvas(canvas);
        }
        JSONObject canvasJSON = doc.optJSONObject("canvas");
        if (canvasJSON != null) {
            canvas.fromJSON(canvasJSON);
        }
        canvas.setCurrLayer(rootLayer);
    } catch (Exception e1) {
        e1.printStackTrace();
        String msg = "An error occurred while trying to load.";
        JOptionPane.showMessageDialog(JOptionPane.getFrameForComponent(MeshEditor.this), msg, "Error",
                JOptionPane.ERROR_MESSAGE);
    }
    repaint();
}

From source file:com.projity.pm.graphic.frames.GraphicManager.java

/**
 * @param projectUrl TODO//from ww w .  j a  va  2s.  c  o  m
 * @param server TODO
 * @throws java.awt.HeadlessException
 */
public GraphicManager(/*String[] projectUrl,*/ String server, Container container) throws HeadlessException {
    graphicManagers.add(this);
    lastGraphicManager = this;
    container.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
            //            System.out.println("GainFocus " + GraphicManager.this.hashCode());
            setMeAsLastGraphicManager();
        }

        public void focusLost(FocusEvent e) {
            //            System.out.println("LostFocus " + GraphicManager.this.hashCode());
        }
    });

    projectFactory = ProjectFactory.getInstance();
    projectFactory.getPortfolio().addObjectListener(this);

    //this.projectUrl = projectUrl;
    GraphicManager.server = server;
    this.container = container;
    if (container instanceof Frame)
        frame = (Frame) container;
    else if (container instanceof JApplet)
        frame = JOptionPane.getFrameForComponent(container);
    if (container instanceof FrameHolder)
        ((FrameHolder) container).setGraphicManager(this);
    //      else if (container instanceof BootstrapApplet){
    else {
        try {
            FrameHolder holder = (FrameHolder) Class.forName("com.projity.bootstrap.BootstrapApplet")
                    .getMethod("getObject", null).invoke(container, null);
            holder.setGraphicManager(this);
        } catch (Exception e) {
        }
    }
    registerForMacOSXEvents();
}

From source file:livecanvas.mesheditor.MeshEditor.java

private void save(File file) {
    if (!canSave()) {
        return;/*  w  ww .  j  av a 2 s. co m*/
    }
    if (file == null) {
        FileDialog fd = new FileDialog(JOptionPane.getFrameForComponent(MeshEditor.this), "Save");
        fd.setVisible(true);
        String file_str = fd.getFile();
        if (file_str == null) {
            return;
        }
        file = new File(fd.getDirectory() + "/" + file_str);
    }
    try {
        Layer rootLayer = layersView.getRootLayer();
        for (Layer l : rootLayer.getSubLayersRecursively()) {
            Path path = l.getPath();
            if (path.isFinalized()) {
                Mesh mesh = path.getMesh();
                if (mesh.getControlPointsCount() < 2) {
                    String msg = "At least one mesh has less than 2 control points.\n"
                            + "You may not be able to use it for animation. Do you\n"
                            + "still want to continue?";
                    if (JOptionPane.showConfirmDialog(this, msg, "Warning", JOptionPane.YES_NO_OPTION,
                            JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION) {
                        return;
                    } else {
                        break;
                    }
                }
            }
        }
        PrintWriter out = new PrintWriter(new FileOutputStream(file));
        JSONObject doc = new JSONObject();
        doc.put("rootLayer", rootLayer.toJSON());
        doc.put("canvas", canvas.toJSON());
        doc.write(out);
        out.close();
    } catch (Exception e1) {
        e1.printStackTrace();
        String msg = "An error occurred while trying to load.";
        JOptionPane.showMessageDialog(JOptionPane.getFrameForComponent(MeshEditor.this), msg, "Error",
                JOptionPane.ERROR_MESSAGE);
    }
    repaint();
}

From source file:livecanvas.mesheditor.MeshEditor.java

private void showImage(Image image) {
    if (image == null) {
        return;/*  w  ww.  j a v  a  2 s .c  om*/
    }
    JDialog d = new JDialog(JOptionPane.getFrameForComponent(MeshEditor.this), "Image View", true);
    d.setContentPane(new JLabel(new ImageIcon(image)));
    d.pack();
    d.setLocationRelativeTo(d.getParent());
    d.setVisible(true);
    d.dispose();
}

From source file:com.biosis.biosislite.vistas.AsignarPermiso.java

private void imprimirBoleta(Permiso seleccionada) {
    File reporte = new File("reportes/reporte_papeleta_salida.jasper");
    //        List<Long> lista = new ArrayList<>();

    Map<String, Object> parametros = new HashMap<>();
    parametros.put("permiso_id", seleccionada.getId());
    parametros.put("por_lote", true);
    parametros.put("reporte_ususario", UsuarioActivo.getUsuario().getLogin());
    parametros.put("reporte_institucion", Main.REPORTE_INSTITUCION);

    reporteador.setConn(controlador.getDao().getConexion());
    reporteador.generarReporte(reporte, parametros, JOptionPane.getFrameForComponent(this));

}

From source file:com.biosis.biosislite.vistas.AsignarPermiso.java

private void imprimirBoleta(AsignacionPermiso seleccionada) {

    File reporte = new File("reportes/reporte_papeleta_salida.jasper");
    //        List<Long> lista = new ArrayList<>();

    Map<String, Object> parametros = new HashMap<>();
    parametros.put("permiso_id", seleccionada.getPermiso().getId());
    parametros.put("pers_nro_documento", seleccionada.getEmpleado().getNroDocumento());
    parametros.put("por_lote", false);
    parametros.put("reporte_ususario", UsuarioActivo.getUsuario().getLogin());
    parametros.put("reporte_institucion", Main.REPORTE_INSTITUCION);

    reporteador.setConn(controlador.getDao().getConexion());
    reporteador.generarReporte(reporte, parametros, JOptionPane.getFrameForComponent(this));

}