Example usage for java.awt Container setSize

List of usage examples for java.awt Container setSize

Introduction

In this page you can find the example usage for java.awt Container setSize.

Prototype

public void setSize(int width, int height) 

Source Link

Document

Resizes this component so that it has width width and height height .

Usage

From source file:com.fedroot.dacs.swing.DacsNoticePresentationDialog.java

/**
 * Called by constructors to initialize the dialog.
 *///  w  w  w  .  jav a2  s .  c om
@Override
protected void dialogInit() {

    if (labels == null) {
        setLocale(Locale.getDefault());
    }

    ActionListener actionListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Object source = e.getSource();
            if (source == acceptButton) {
                pressed_ACCEPT = true;
                DacsNoticePresentationDialog.this.setVisible(false);
            } else if (source == declineButton) {
                pressed_ACCEPT = false;
                DacsNoticePresentationDialog.this.setVisible(false);
            } else {
                pressed_ACCEPT = false;
                DacsNoticePresentationDialog.this.setVisible(false);
            }
        }
    };

    acceptButton = new JButton(labels.getString("dialog.accept"));
    declineButton = new JButton(labels.getString("dialog.decline"));

    super.dialogInit();

    JPanel inputpane = new JPanel(new FlowLayout());

    inputpane.add(acceptButton);
    inputpane.add(declineButton);

    acceptButton.addActionListener(actionListener);
    inputpane.add(acceptButton);
    declineButton.addActionListener(actionListener);
    inputpane.add(declineButton);

    htmlpane = new JEditorPane();
    // htmlpane.setContentType("image/png");
    htmlpane.setEditable(false);
    // initialize htmlpane with something
    setDocumentContent("text/html",
            "<html><body><img src=\"http://fedroot.com/images/rick-and-frog.jpg\" width=400 height=300></body></html>");
    // not set when called from super() setDocumentContent(this.content);
    JScrollPane presentation = new JScrollPane(htmlpane);

    JPanel pane = new JPanel();
    pane.setLayout(new BorderLayout());
    pane.add(presentation, BorderLayout.CENTER);
    pane.add(inputpane, BorderLayout.SOUTH);

    Container container = getContentPane();
    container.add(pane);
    container.setSize(600, 400);
    pack();
}

From source file:pl.edu.icm.visnow.lib.utils.ImageUtilities.java

public static void sizeContainerToComponent(Container container, Component component) {
    if (container.isDisplayable() == false) {
        container.addNotify();/*from w  w w .  j  a v  a  2  s.  com*/
    }
    Insets insets = container.getInsets();
    Dimension size = component.getPreferredSize();
    int width = insets.left + insets.right + size.width;
    int height = insets.top + insets.bottom + size.height;
    container.setSize(width, height);
}

From source file:cc.siara.csv_ml_demo.MultiLevelCSVSwingDemo.java

/**
 * Constructor that adds components to the container, sets layout and opens
 * with window// w  w w.  j  a va 2  s  . c o  m
 * 
 * @param container
 */
public MultiLevelCSVSwingDemo(Container container) {
    if (container == null)
        container = this;
    if (container instanceof JFrame) {
        JFrame frame = (JFrame) container;
        frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        frame.setLocationByPlatform(true);
        frame.setTitle("Demonstration of Multi-level CSV parsing (csv_ml)");
    }
    container.setSize(800, 600);
    container.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 6));
    container.add(lblInput);
    container.add(cbExamples);
    container.add(lblInputSize);
    container.add(tfInputSize);
    container.add(lblDelimiter);
    container.add(cbDelimiter);
    container.add(tfDelimiter);
    container.add(btnAbout);
    container.add(taInputScroll);
    container.add(lblOutput);
    container.add(btnDDLDML);
    container.add(btnJSON);
    container.add(btnXML);
    container.add(btnXPath);
    container.add(tfXPath);
    container.add(cbPretty);
    container.add(taOutputScroll);
    container.add(lblOutputSize);
    container.add(tfOutputSize);
    container.add(btnToCSV);
    container.add(lblJDBCURL);
    container.add(tfDBURL);
    container.add(btnRunDDL);
    container.add(lblID);
    container.add(tfID);
    container.add(btnGetData);
    JTextField tfID = new JTextField("1", 4);
    taInput.setBorder(BorderFactory.createLineBorder(getForeground()));
    taOutput.setBorder(BorderFactory.createLineBorder(getForeground()));
    setInputText();
    cbExamples.addActionListener(this);
    cbDelimiter.addActionListener(this);
    btnAbout.addActionListener(this);
    btnXML.addActionListener(this);
    btnDDLDML.addActionListener(this);
    btnJSON.addActionListener(this);
    btnToCSV.addActionListener(this);
    btnXPath.addActionListener(this);
    btnRunDDL.addActionListener(this);
    btnGetData.addActionListener(this);
    taInput.addKeyListener(new KeyListener() {
        public void keyTyped(KeyEvent arg0) {
            isInputChanged = true;
        }

        public void keyReleased(KeyEvent arg0) {
        }

        public void keyPressed(KeyEvent arg0) {
        }
    });
    tfInputSize.setEditable(false);
    tfOutputSize.setEditable(false);
    setVisible(true);
}

From source file:lcmc.LCMC.java

/** Create the GUI and show it. */
protected static void createAndShowGUI(final Container mainFrame) {
    final java.util.List<Object> buttonGradient = Arrays.asList(new Object[] { new Float(.3f), new Float(0f),
            new ColorUIResource(ClusterBrowser.PANEL_BACKGROUND), new ColorUIResource(0xFFFFFF),
            new ColorUIResource(ClusterBrowser.BUTTON_PANEL_BACKGROUND) });
    final java.util.List<Object> checkboxGradient = Arrays.asList(
            new Object[] { new Float(.3f), new Float(0f), new ColorUIResource(ClusterBrowser.PANEL_BACKGROUND),
                    new ColorUIResource(ClusterBrowser.PANEL_BACKGROUND), new ColorUIResource(0xFFFFFF) });
    ToolTipManager.sharedInstance().setInitialDelay(TOOLTIP_INITIAL_DELAY);
    ToolTipManager.sharedInstance().setDismissDelay(TOOLTIP_DISMISS_DELAY);
    UIManager.put("TableHeader.background", Tools.getDefaultColor("DrbdMC.TableHeader"));
    UIManager.put("TableHeader.font", UIManager.getFont("Label.font"));
    UIManager.put("Button.gradient", buttonGradient);
    UIManager.put("Button.select", ClusterBrowser.PANEL_BACKGROUND);

    UIManager.put("CheckBox.gradient", checkboxGradient);
    UIManager.put("CheckBoxMenuItem.gradient", checkboxGradient);
    UIManager.put("RadioButton.gradient", checkboxGradient);
    UIManager.put("RadioButton.rollover", Boolean.TRUE);
    UIManager.put("RadioButtonMenuItem.gradient", checkboxGradient);
    UIManager.put("ScrollBar.gradient", buttonGradient);
    UIManager.put("ToggleButton.gradient", buttonGradient);

    UIManager.put("Menu.selectionBackground", ClusterBrowser.BUTTON_PANEL_BACKGROUND);
    UIManager.put("MenuItem.selectionBackground", ClusterBrowser.BUTTON_PANEL_BACKGROUND);
    UIManager.put("List.selectionBackground", ClusterBrowser.BUTTON_PANEL_BACKGROUND);
    UIManager.put("ComboBox.selectionBackground", ClusterBrowser.BUTTON_PANEL_BACKGROUND);
    UIManager.put("OptionPane.background", ClusterBrowser.BUTTON_PANEL_BACKGROUND);
    UIManager.put("Panel.background", ClusterBrowser.PANEL_BACKGROUND);

    /* Create and set up the window. */
    Tools.getGUIData().setMainFrame(mainFrame);

    /* Display the window. */
    mainFrame.setSize(Tools.getDefaultInt("DrbdMC.width"), Tools.getDefaultInt("DrbdMC.height"));
    mainFrame.setVisible(true);/*from w  ww  .ja v a 2 s  .  co  m*/
}