Search in sources :

Example 61 with Container

use of java.awt.Container in project jdk8u_jdk by JetBrains.

the class WPageDialog method addNotify.

@Override
@SuppressWarnings("deprecation")
public void addNotify() {
    synchronized (getTreeLock()) {
        Container parent = getParent();
        if (parent != null && parent.getPeer() == null) {
            parent.addNotify();
        }
        if (getPeer() == null) {
            ComponentPeer peer = ((WToolkit) Toolkit.getDefaultToolkit()).createWPageDialog(this);
            setPeer(peer);
        }
        super.addNotify();
    }
}
Also used : Container(java.awt.Container) ComponentPeer(java.awt.peer.ComponentPeer)

Example 62 with Container

use of java.awt.Container in project jdk8u_jdk by JetBrains.

the class ServiceDialog method initPageDialog.

/**
     * Initialize "page setup" dialog
     */
void initPageDialog(int x, int y, PrintService ps, DocFlavor flavor, PrintRequestAttributeSet attributes) {
    this.psCurrent = ps;
    this.docFlavor = flavor;
    this.asOriginal = attributes;
    this.asCurrent = new HashPrintRequestAttributeSet(attributes);
    if (attributes.get(DialogOnTop.class) != null) {
        setAlwaysOnTop(true);
    }
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    pnlPageSetup = new PageSetupPanel();
    c.add(pnlPageSetup, BorderLayout.CENTER);
    pnlPageSetup.updateInfo();
    JPanel pnlSouth = new JPanel(new FlowLayout(FlowLayout.TRAILING));
    btnApprove = createExitButton("button.ok", this);
    pnlSouth.add(btnApprove);
    getRootPane().setDefaultButton(btnApprove);
    btnCancel = createExitButton("button.cancel", this);
    handleEscKey(btnCancel);
    pnlSouth.add(btnCancel);
    c.add(pnlSouth, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent event) {
            dispose(CANCEL);
        }
    });
    getAccessibleContext().setAccessibleDescription(getMsg("dialog.pstitle"));
    setResizable(false);
    setLocation(x, y);
    pack();
}
Also used : Container(java.awt.Container) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter)

Example 63 with Container

use of java.awt.Container in project jdk8u_jdk by JetBrains.

the class ServiceDialog method initPrintDialog.

/**
     * Initialize print dialog.
     */
void initPrintDialog(int x, int y, PrintService[] services, int defaultServiceIndex, DocFlavor flavor, PrintRequestAttributeSet attributes) {
    this.services = services;
    this.defaultServiceIndex = defaultServiceIndex;
    this.asOriginal = attributes;
    this.asCurrent = new HashPrintRequestAttributeSet(attributes);
    this.psCurrent = services[defaultServiceIndex];
    this.docFlavor = flavor;
    SunPageSelection pages = (SunPageSelection) attributes.get(SunPageSelection.class);
    if (pages != null) {
        isAWT = true;
    }
    if (attributes.get(DialogOnTop.class) != null) {
        setAlwaysOnTop(true);
    }
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    tpTabs = new JTabbedPane();
    tpTabs.setBorder(new EmptyBorder(5, 5, 5, 5));
    String gkey = getMsg("tab.general");
    int gmnemonic = getVKMnemonic("tab.general");
    pnlGeneral = new GeneralPanel();
    tpTabs.add(gkey, pnlGeneral);
    tpTabs.setMnemonicAt(0, gmnemonic);
    String pkey = getMsg("tab.pagesetup");
    int pmnemonic = getVKMnemonic("tab.pagesetup");
    pnlPageSetup = new PageSetupPanel();
    tpTabs.add(pkey, pnlPageSetup);
    tpTabs.setMnemonicAt(1, pmnemonic);
    String akey = getMsg("tab.appearance");
    int amnemonic = getVKMnemonic("tab.appearance");
    pnlAppearance = new AppearancePanel();
    tpTabs.add(akey, pnlAppearance);
    tpTabs.setMnemonicAt(2, amnemonic);
    c.add(tpTabs, BorderLayout.CENTER);
    updatePanels();
    JPanel pnlSouth = new JPanel(new FlowLayout(FlowLayout.TRAILING));
    btnApprove = createExitButton("button.print", this);
    pnlSouth.add(btnApprove);
    getRootPane().setDefaultButton(btnApprove);
    btnCancel = createExitButton("button.cancel", this);
    handleEscKey(btnCancel);
    pnlSouth.add(btnCancel);
    c.add(pnlSouth, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent event) {
            dispose(CANCEL);
        }
    });
    getAccessibleContext().setAccessibleDescription(getMsg("dialog.printtitle"));
    setResizable(false);
    setLocation(x, y);
    pack();
}
Also used : FlowLayout(java.awt.FlowLayout) WindowAdapter(java.awt.event.WindowAdapter) javax.print(javax.print) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) WindowEvent(java.awt.event.WindowEvent) SunPageSelection(sun.print.SunPageSelection) EmptyBorder(javax.swing.border.EmptyBorder)

Example 64 with Container

use of java.awt.Container in project jabref by JabRef.

the class WrapLayout method layoutSize.

/**
     * Returns the minimum or preferred dimension needed to layout the target
     * container.
     *
     * @param target target to get layout size for
     * @param preferred should preferred size be calculated
     * @return the dimension to layout the target container
     */
private Dimension layoutSize(Container target, boolean preferred) {
    synchronized (target.getTreeLock()) {
        //  Each row must fit with the width allocated to the container.
        //  When the container width = 0, the preferred width of the container
        //  has not yet been calculated so lets ask for the maximum.
        int targetWidth = target.getSize().width;
        if (targetWidth == 0) {
            targetWidth = Integer.MAX_VALUE;
        }
        int hgap = getHgap();
        int vgap = getVgap();
        Insets insets = target.getInsets();
        int horizontalInsetsAndGap = insets.left + insets.right + (hgap * 2);
        int maxWidth = targetWidth - horizontalInsetsAndGap;
        //  Fit components into the allowed width
        Dimension dim = new Dimension(0, 0);
        int rowWidth = 0;
        int rowHeight = 0;
        int nmembers = target.getComponentCount();
        for (int i = 0; i < nmembers; i++) {
            Component m = target.getComponent(i);
            if (m.isVisible()) {
                Dimension d = preferred ? m.getPreferredSize() : m.getMinimumSize();
                if (d != null) {
                    if ((rowWidth + d.width) > maxWidth) {
                        addRow(dim, rowWidth, rowHeight);
                        rowWidth = 0;
                        rowHeight = 0;
                    }
                    if (rowWidth != 0) {
                        rowWidth += hgap;
                    }
                    rowWidth += d.width;
                    rowHeight = Math.max(rowHeight, d.height);
                }
            }
        }
        addRow(dim, rowWidth, rowHeight);
        dim.width += horizontalInsetsAndGap;
        dim.height += insets.top + insets.bottom + (vgap * 2);
        //	When using a scroll pane or the DecoratedLookAndFeel we need to
        //  make sure the preferred size is less than the size of the
        //  target container so shrinking the container size works
        //  correctly. Removing the horizontal gap is an easy way to do this.
        Container scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane.class, target);
        if (scrollPane != null) {
            dim.width -= (hgap + 1);
        }
        return dim;
    }
}
Also used : Container(java.awt.Container) Insets(java.awt.Insets) Dimension(java.awt.Dimension) Component(java.awt.Component)

Example 65 with Container

use of java.awt.Container in project JMRI by JMRI.

the class LogixTableAction method makeEditLogixWindow.

/**
     * Create and/or initialize the Edit Logix pane.
     */
void makeEditLogixWindow() {
    // Setup the name box components.
    setNameBoxListeners();
    //if (log.isDebugEnabled()) log.debug("makeEditLogixWindow ");
    editUserName.setText(_curLogix.getUserName());
    // clear conditional table if needed
    if (conditionalTableModel != null) {
        conditionalTableModel.fireTableStructureChanged();
    }
    inEditMode = true;
    if (editLogixFrame == null) {
        editLogixFrame = new JmriJFrame(rbx.getString("TitleEditLogix"), false, false);
        editLogixFrame.addHelpMenu("package.jmri.jmrit.beantable.LogixAddEdit", true);
        editLogixFrame.setLocation(100, 30);
        Container contentPane = editLogixFrame.getContentPane();
        contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
        JPanel panel1 = new JPanel();
        panel1.setLayout(new FlowLayout());
        JLabel systemNameLabel = new JLabel(Bundle.getMessage("ColumnSystemName") + ":");
        panel1.add(systemNameLabel);
        JLabel fixedSystemName = new JLabel(_curLogix.getSystemName());
        panel1.add(fixedSystemName);
        contentPane.add(panel1);
        JPanel panel2 = new JPanel();
        panel2.setLayout(new FlowLayout());
        JLabel userNameLabel = new JLabel(Bundle.getMessage("ColumnUserName") + ":");
        panel2.add(userNameLabel);
        panel2.add(editUserName);
        editUserName.setToolTipText(rbx.getString("LogixUserNameHint2"));
        contentPane.add(panel2);
        // add table of Conditionals
        JPanel pctSpace = new JPanel();
        pctSpace.setLayout(new FlowLayout());
        pctSpace.add(new JLabel("   "));
        contentPane.add(pctSpace);
        JPanel pTitle = new JPanel();
        pTitle.setLayout(new FlowLayout());
        pTitle.add(new JLabel(rbx.getString("ConditionalTableTitle")));
        contentPane.add(pTitle);
        // initialize table of conditionals
        conditionalTableModel = new ConditionalTableModel();
        JTable conditionalTable = new JTable(conditionalTableModel);
        conditionalTable.setRowSelectionAllowed(false);
        TableColumnModel conditionalColumnModel = conditionalTable.getColumnModel();
        TableColumn sNameColumn = conditionalColumnModel.getColumn(ConditionalTableModel.SNAME_COLUMN);
        sNameColumn.setResizable(true);
        sNameColumn.setMinWidth(100);
        sNameColumn.setPreferredWidth(130);
        TableColumn uNameColumn = conditionalColumnModel.getColumn(ConditionalTableModel.UNAME_COLUMN);
        uNameColumn.setResizable(true);
        uNameColumn.setMinWidth(210);
        uNameColumn.setPreferredWidth(260);
        TableColumn stateColumn = conditionalColumnModel.getColumn(ConditionalTableModel.STATE_COLUMN);
        stateColumn.setResizable(true);
        stateColumn.setMinWidth(50);
        stateColumn.setMaxWidth(100);
        TableColumn buttonColumn = conditionalColumnModel.getColumn(ConditionalTableModel.BUTTON_COLUMN);
        // install button renderer and editor
        ButtonRenderer buttonRenderer = new ButtonRenderer();
        conditionalTable.setDefaultRenderer(JButton.class, buttonRenderer);
        TableCellEditor buttonEditor = new ButtonEditor(new JButton());
        conditionalTable.setDefaultEditor(JButton.class, buttonEditor);
        JButton testButton = new JButton("XXXXXX");
        conditionalTable.setRowHeight(testButton.getPreferredSize().height);
        buttonColumn.setMinWidth(testButton.getPreferredSize().width);
        buttonColumn.setMaxWidth(testButton.getPreferredSize().width);
        buttonColumn.setResizable(false);
        JScrollPane conditionalTableScrollPane = new JScrollPane(conditionalTable);
        Dimension dim = conditionalTable.getPreferredSize();
        dim.height = 450;
        conditionalTableScrollPane.getViewport().setPreferredSize(dim);
        contentPane.add(conditionalTableScrollPane);
        // add message area between table and buttons
        JPanel panel4 = new JPanel();
        panel4.setLayout(new BoxLayout(panel4, BoxLayout.Y_AXIS));
        JPanel panel41 = new JPanel();
        panel41.setLayout(new FlowLayout());
        panel41.add(status);
        panel4.add(panel41);
        JPanel panel42 = new JPanel();
        panel42.setLayout(new FlowLayout());
        // Conditional panel buttons - New Conditional
        JButton newConditionalButton = new JButton(rbx.getString("NewConditionalButton"));
        panel42.add(newConditionalButton);
        newConditionalButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                newConditionalPressed(e);
            }
        });
        newConditionalButton.setToolTipText(rbx.getString("NewConditionalButtonHint"));
        // Conditional panel buttons - Reorder
        JButton reorderButton = new JButton(rbx.getString("ReorderButton"));
        panel42.add(reorderButton);
        reorderButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                reorderPressed(e);
            }
        });
        reorderButton.setToolTipText(rbx.getString("ReorderButtonHint"));
        // Conditional panel buttons - Calculate
        JButton calculateButton = new JButton(rbx.getString("CalculateButton"));
        panel42.add(calculateButton);
        calculateButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                calculatePressed(e);
            }
        });
        calculateButton.setToolTipText(rbx.getString("CalculateButtonHint"));
        panel4.add(panel42);
        Border panel4Border = BorderFactory.createEtchedBorder();
        panel4.setBorder(panel4Border);
        contentPane.add(panel4);
        // add buttons at bottom of window
        JPanel panel5 = new JPanel();
        panel5.setLayout(new FlowLayout());
        // Bottom Buttons - Done Logix
        JButton done = new JButton(Bundle.getMessage("ButtonDone"));
        panel5.add(done);
        done.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                donePressed(e);
            }
        });
        done.setToolTipText(rbx.getString("DoneButtonHint"));
        // Delete Logix
        JButton delete = new JButton(Bundle.getMessage("ButtonDelete"));
        panel5.add(delete);
        delete.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                deletePressed(e);
            }
        });
        delete.setToolTipText(rbx.getString("DeleteLogixButtonHint"));
        contentPane.add(panel5);
    }
    editLogixFrame.addWindowListener(new java.awt.event.WindowAdapter() {

        @Override
        public void windowClosing(java.awt.event.WindowEvent e) {
            if (inEditMode) {
                donePressed(null);
            } else {
                finishDone();
            }
        }
    });
    editLogixFrame.pack();
    editLogixFrame.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ButtonEditor(jmri.util.table.ButtonEditor) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) TableColumnModel(javax.swing.table.TableColumnModel) Dimension(java.awt.Dimension) TableColumn(javax.swing.table.TableColumn) Container(java.awt.Container) ActionListener(java.awt.event.ActionListener) JmriJFrame(jmri.util.JmriJFrame) JTable(javax.swing.JTable) TableCellEditor(javax.swing.table.TableCellEditor) Border(javax.swing.border.Border) ButtonRenderer(jmri.util.table.ButtonRenderer)

Aggregations

Container (java.awt.Container)250 JPanel (javax.swing.JPanel)70 JLabel (javax.swing.JLabel)65 JButton (javax.swing.JButton)56 JScrollPane (javax.swing.JScrollPane)55 BoxLayout (javax.swing.BoxLayout)50 FlowLayout (java.awt.FlowLayout)49 Component (java.awt.Component)46 BorderLayout (java.awt.BorderLayout)44 Dimension (java.awt.Dimension)39 ActionEvent (java.awt.event.ActionEvent)38 ActionListener (java.awt.event.ActionListener)26 JComponent (javax.swing.JComponent)22 JFrame (javax.swing.JFrame)22 JmriJFrame (jmri.util.JmriJFrame)20 Border (javax.swing.border.Border)18 JTable (javax.swing.JTable)17 JTextArea (javax.swing.JTextArea)17 Frame (java.awt.Frame)16 JTextField (javax.swing.JTextField)16