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:Main.java

/**
 * Shows a warning message dialog./*from   w w  w  .j a v  a 2  s  .c  om*/
 * 
 * @param c
 *            determines the Frame in which the dialog is displayed.
 * @param msg
 *            the message to display.
 */
public static void showWarningDialog(Component c, String msg) {
    JOptionPane.showMessageDialog(JOptionPane.getFrameForComponent(c), msg,
            UIManager.getString("OptionPane.warningDialogTitle"), JOptionPane.WARNING_MESSAGE);
}

From source file:Main.java

/**
 * Shows an input dialog.//from ww w  . j  a  v  a 2 s.c  o  m
 * 
 * @param c
 *            the parent component.
 * @param msg
 *            the message to display.
 * @return the string typed by the user, or <code>null</code> if the user cancels the option pane.
 */
public static String showInputDialog(Component c, String msg) {
    return JOptionPane.showInputDialog(JOptionPane.getFrameForComponent(c), msg);
}

From source file:Main.java

/**
 * Shows a confirm dialog.//from   w  w w . jav a 2  s. co  m
 * 
 * @param c
 *            the parent component.
 * @param msg
 *            the message to display.
 * @param messageType
 *            the type of message to display.
 * @return an int indicating the option selected by the user.
 */
public static int showConfirmDialog(Component c, String msg, int messageType) {
    return JOptionPane.showConfirmDialog(JOptionPane.getFrameForComponent(c), msg,
            UIManager.getString("OptionPane.confirmDialogTitle"), JOptionPane.YES_NO_OPTION, messageType);
}

From source file:com.jdom.util.patterns.mvp.swing.RadioButtonGroupDialog.java

public static String showDialog(Component frameComp, Component locationComp, String labelText, String title,
        Collection<String> possibleValues, String initialValue, String longValue) {
    Frame frame = JOptionPane.getFrameForComponent(frameComp);
    dialog = new RadioButtonGroupDialog(frame, locationComp, labelText, title, possibleValues, initialValue,
            longValue);//w  w  w .  j a  va2 s .  c o m
    dialog.setVisible(true);
    return selectedValue;
}

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

public DlgDatosEmpleado(JInternalFrame parent, boolean modal) {
    super(JOptionPane.getFrameForComponent(parent), modal);
    initComponents();/*from  w ww  .j  av a  2  s . c om*/
    this.setLocationRelativeTo(parent);

    FormularioUtil.activarComponente(dtFechaNacimiento, false);
    FormularioUtil.activarComponente(dtFechaContrato, false);
    dtFechaNacimiento.getCalendarButton().setVisible(false);
    dtFechaContrato.getCalendarButton().setVisible(false);

    dtFechaNacimiento.setDate(new Date());
}

From source file:com.biosis.sgb.vistas.dialogos.PersonaCRUD.java

public PersonaCRUD(Component component, boolean modal, int accion, Persona persona) {
    super(JOptionPane.getFrameForComponent(component), modal);
    initComponents();//from  w w w.j  a v a 2 s  .c  o  m
    initComponents2();
    this.persona = persona;
    this.accion = accion;
    inicializar(persona, accion);
    this.setLocationRelativeTo(component);
}

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

public DlgDatosEmpleado(JDialog parent, boolean modal) {
    super(JOptionPane.getFrameForComponent(parent), modal);
    initComponents();//  w  w w.j ava 2 s.com
    this.setLocationRelativeTo(parent);

    FormularioUtil.activarComponente(dtFechaNacimiento, false);
    FormularioUtil.activarComponente(dtFechaContrato, false);
    dtFechaNacimiento.getCalendarButton().setVisible(false);
    dtFechaContrato.getCalendarButton().setVisible(false);

    dtFechaNacimiento.setDate(new Date());
}

From source file:components.ListDialog.java

/**
 * Set up and show the dialog.  The first Component argument
 * determines which frame the dialog depends on; it should be
 * a component in the dialog's controlling frame. The second
 * Component argument should be null if you want the dialog
 * to come up with its left corner in the center of the screen;
 * otherwise, it should be the component on top of which the
 * dialog should appear.//  w w  w  . ja  v a  2  s . c  o  m
 */
public static String showDialog(Component frameComp, Component locationComp, String labelText, String title,
        String[] possibleValues, String initialValue, String longValue) {
    Frame frame = JOptionPane.getFrameForComponent(frameComp);
    dialog = new ListDialog(frame, locationComp, labelText, title, possibleValues, initialValue, longValue);
    dialog.setVisible(true);
    return value;
}

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

/**
 * Callback method for receiving notification of a mouse click on a chart.
 *
 * @param event information about the event.
 *//*from w ww .  j a  v a  2 s.co m*/
public void chartMouseClicked(ChartMouseEvent event) {
    if (event.getTrigger().getClickCount() > 1) {
        if (event.getEntity() instanceof XYItemEntity) {
            XYItemEntity item = (XYItemEntity) event.getEntity();
            Component c = event.getTrigger().getComponent();
            final JDialog dialog = new JDialog(JOptionPane.getFrameForComponent(c), "Item Data", false);
            dialog.setSize(400, 300);
            dialog.setLocation(getDialogLocation(dialog, c));
            dialog.add(getItemPanel(dialog, item, event));
            dialog.setVisible(true);
        } else {
            XYItemEntity item = (XYItemEntity) event.getEntity();
            Component c = event.getTrigger().getComponent();
            final JDialog dialog = new JDialog(JOptionPane.getFrameForComponent(c), "Item Data", false);
            dialog.setSize(400, 300);
            dialog.setLocation(getDialogLocation(dialog, c));
            dialog.add(getSeriesPanel(dialog, event));
            dialog.setVisible(true);
        }
    } else {
        if (!(event.getChart().getXYPlot().getRenderer() instanceof MotionBubbleRenderer)) {
            return;
        }

        MotionBubbleRenderer renderer = (MotionBubbleRenderer) event.getChart().getXYPlot().getRenderer();
        MotionDataSet dataset = (MotionDataSet) event.getChart().getXYPlot().getDataset();

        if (event.getEntity() instanceof XYItemEntity) {
            boolean selected;
            XYItemEntity entity = (XYItemEntity) event.getEntity();
            int series = entity.getSeriesIndex();
            int item = entity.getItem();
            Object category = dataset.getCategory(series, item);

            if (category == null) {
                selected = !renderer.isSelectedItem(series, item);
                renderer.setSelectedItem(series, item, selected);
            } else {
                selected = !renderer.isSelectedCategory(category);
                renderer.setSelectedCategory(category, selected);
            }
        }
    }
}

From source file:gui.AdministracionGrupos.java

/**
     * Creates new form AdministracionGrupos
     *///from w w  w .  j  av  a  2  s .  co m
    public AdministracionGrupos(Desktop aparent) {
        //         super(aparent, true);
        this.parent = aparent;
        initComponents();
        setLocationRelativeTo(null);

        //        setClosable(true);
        //        this.pack();
        //        this.setFrameIcon(new ImageIcon(this.getClass().getResource("/resources/logo tru-test.png")));
        cargarPuertos();

        cargarStick();

        corralSelector.valor_nuevo = true;
        razaSelector.valor_nuevo = true;

        Frame F = JOptionPane.getFrameForComponent(this);
        reporteEntradas = new ReporteEntradas(F);

        String titulos[] = { "Id Animal", "Arete Visual", "Arete Electronico", "Proveedor", "Fecha de Compra",
                "Arete Siniiga", "Arete Campaa", "Sexo", "Ingreso al Corral", "Numero de Lote", "No. Compra",
                "Peso Actual", "Peso de Compra" };

        t_animales.setTitulos(titulos);
        t_animales.cambiarTitulos();

        t_animales.setFormato(new int[] { Table.letra, Table.letra, Table.letra, Table.letra, Table.fecha,
                Table.letra, Table.letra, Table.letra, Table.fecha, Table.numero_double, Table.letra,
                Table.numero_double, Table.numero_double });

        t_animales.ocultarcolumna(0);

        corralActivo = true;

        //   graficar();
        ListSelectionModel lsm = this.t_animales.getSelectionModel();

        lsm.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                selectAnimal();
            }
        });

        t_pesos = new Table();

        t_pesos.setModel(
                new javax.swing.table.DefaultTableModel(new Object[][] {}, new String[] { "Title 1", "Title 2" }));

        String titulos2[] = { "Fecha", "Peso (kg)" };

        t_pesos.setTitulos(titulos2);
        t_pesos.cambiarTitulos();
        t_pesos.setFormato(new int[] { 3, 1 });

        g = new Grafica();

        Grafica = g.createChart(g.createDatasetPesos(t_pesos));

        jPanel1 = new ChartPanel(Grafica);

        jPanel1.setBackground(new java.awt.Color(0, 0, 0));
        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(jPanel1Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 216, Short.MAX_VALUE));
        jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 186, Short.MAX_VALUE));

        panelGrafica.add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, panelGrafica.getWidth(),
                panelGrafica.getHeight()));

        cargarDatosIniciales();

        graficar();

        //        Image i = null;
        //        i = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/resources/logo tru-test.png"));
        //        setIconImage(i);
        this.t_alimentoIngresado.textFieldDouble();
        this.t_pesoMaximo.textFieldDouble();
        this.t_pesoMinimo.textFieldDouble();
        this.t_pesoPromedio.textFieldDouble();
        this.t_totalKilos.textFieldDouble();

        this.setTitle(this.getTitle() + " " + rancho.descripcion);

        cargarComponentes();

    }