Java Code Examples for javax.swing.JPanel.getPreferredSize()

The following are Jave code examples for showing how to use getPreferredSize() of the javax.swing.JPanel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: ReferencesBrowserController.java   View Source Code Vote up 6 votes
Dialog createProgressPanel(final String message, BoundedRangeModel model) {
    Dialog dialog;
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout(10, 10));
    panel.setBorder(new EmptyBorder(15, 15, 15, 15));
    panel.add(new JLabel(message), BorderLayout.NORTH);

    final Dimension ps = panel.getPreferredSize();
    ps.setSize(Math.max(ps.getWidth(), DEFAULT_WIDTH), Math.max(ps.getHeight(), DEFAULT_HEIGHT));
    panel.setPreferredSize(ps);

    final JProgressBar progress = new JProgressBar();
    if (model == null) {
        progress.setIndeterminate(true);
    } else {
        progress.setStringPainted(true);
        progress.setModel(model);
    }
    panel.add(progress, BorderLayout.SOUTH);
    dialog = DialogDisplayer.getDefault().createDialog(new DialogDescriptor(panel, Bundle.ReferencesBrowserController_ProgressDialogCaption(), true, new Object[] {  },
                                                       DialogDescriptor.CANCEL_OPTION, DialogDescriptor.RIGHT_ALIGN,
                                                       null, null));

    return dialog;
}
 
Example 2
Project: freecol   File: InfoPanel.java   View Source Code Vote up 6 votes
/**
 * Updates this {@code InfoPanel}.
 *
 * @param mapTransform The current MapTransform.
 */
public void update(MapTransform mapTransform) {
    final JPanel p = (mapTransform == null) ? null
        : mapTransform.getDescriptionPanel();
    if (p != null) {
        p.setOpaque(false);
        final Dimension d = p.getPreferredSize();
        p.setBounds(0, (this.mapEditorPanel.getHeight() - d.height)/2,
            this.mapEditorPanel.getWidth(), d.height);
        this.mapEditorPanel.removeAll();
        this.mapEditorPanel.add(p, BorderLayout.CENTER);
        this.mapEditorPanel.validate();
        this.mapEditorPanel.revalidate();
    }
    update();
}
 
Example 3
Project: FreeCol   File: InfoPanel.java   View Source Code Vote up 6 votes
/**
 * Updates this {@code InfoPanel}.
 *
 * @param mapTransform The current MapTransform.
 */
public void update(MapTransform mapTransform) {
    final JPanel p = (mapTransform == null) ? null
        : mapTransform.getDescriptionPanel();
    if (p != null) {
        p.setOpaque(false);
        final Dimension d = p.getPreferredSize();
        p.setBounds(0, (this.mapEditorPanel.getHeight() - d.height)/2,
            this.mapEditorPanel.getWidth(), d.height);
        this.mapEditorPanel.removeAll();
        this.mapEditorPanel.add(p, BorderLayout.CENTER);
        this.mapEditorPanel.validate();
        this.mapEditorPanel.revalidate();
    }
    update();
}
 
Example 4
Project: incubator-netbeans   File: SettingsPanel.java   View Source Code Vote up 5 votes
private static int defaultHeight() {
    if (DEFAULT_HEIGHT == -1) {
        JPanel ref = new JPanel(null);
        ref.setLayout(new BoxLayout(ref, BoxLayout.LINE_AXIS));
        ref.setOpaque(false);
        
        ref.add(new JLabel("XXX")); // NOI18N
        
        ref.add(new JButton("XXX")); // NOI18N
        ref.add(new PopupButton("XXX")); // NOI18N
        
        ref.add(new JCheckBox("XXX")); // NOI18N
        ref.add(new JRadioButton("XXX")); // NOI18N
        
        ref.add(new JTextField("XXX")); // NOI18N
        
        ref.add(new JExtendedSpinner(new SpinnerNumberModel(1, 1, 655535, 1)));
        
        Component separator = Box.createHorizontalStrut(1);
        Dimension d = separator.getMaximumSize(); d.height = 20;
        separator.setMaximumSize(d);
        ref.add(separator);
        
        DEFAULT_HEIGHT = ref.getPreferredSize().height;
    }
    return DEFAULT_HEIGHT;
}
 
Example 5
Project: Equella   File: BasicEditorPanel.java   View Source Code Vote up 5 votes
@SuppressWarnings("nls")
private void setupGUI(Node privNode)
{
	JPanel options = createOptions(privNode);

	listModel = new LimitedSetListModel();
	list = new JList(listModel);
	list.setCellRenderer(new ExpressionListCellRenderer(userService)
	{
		@Override
		public String getExpression(Object value)
		{
			return ((PrivilegeListEntry) value).getWho();
		}
	});

	listScroller = new JScrollPane(list);
	listScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

	select = new JButton(CurrentLocale.get("com.tle.admin.security.editors.basiceditorpanel.select"));
	select.addActionListener(this);

	final int height1 = options.getPreferredSize().height;
	final int height2 = select.getPreferredSize().height;
	final int width1 = select.getPreferredSize().width;

	final int[] rows = {height1, TableLayout.FILL, height2,};
	final int[] cols = {20, TableLayout.FILL, width1, TableLayout.FILL,};

	setLayout(new TableLayout(rows, cols));
	add(options, new Rectangle(0, 0, 4, 1));
	add(listScroller, new Rectangle(1, 1, 2, 1));
	add(select, new Rectangle(2, 2, 1, 1));
}
 
Example 6
Project: Equella   File: WizardFrame.java   View Source Code Vote up 4 votes
private void setup()
{
	header = Icons.getHeader(export);
	footer = new Footer();

	content = new JPanel(new GridLayout(1, 1));

	next = new JButton();
	back = new JButton("< Back");

	next.addActionListener(this);
	back.addActionListener(this);

	JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
	buttons.add(back);
	buttons.add(next);

	buttons.setPreferredSize(buttons.getPreferredSize());

	final int width = header.getPreferredSize().width;
	final int height1 = header.getPreferredSize().height;
	final int height2 = buttons.getPreferredSize().height;
	final int height3 = footer.getPreferredSize().height;

	final int[] rows = new int[]{height1, 300, height2, height3};
	final int[] cols = new int[]{width};

	JPanel all = new JPanel(new TableLayout(rows, cols, 5, 5));
	all.add(header, new Rectangle(0, 0, 1, 1));
	all.add(content, new Rectangle(0, 1, 1, 1));
	all.add(buttons, new Rectangle(0, 2, 1, 1));
	all.add(footer, new Rectangle(0, 3, 1, 1));

	getContentPane().add(all);

	pack();
	setResizable(false);
	setTitle(title);
	ComponentHelper.centreOnScreen(this);
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	updateButtons();
}
 
Example 7
Project: jaer   File: MultiInputPanel.java   View Source Code Vote up 4 votes
public MultiInputPanel(ProcessingNetwork.Node p) {
        super(p.filt);
        node=p;
        
//        this.setLayout(new GridBagLayout());
        
        node.setControlPanel(this); 
        
        
        
        // Hackity hackity hack hack hack hack
//        
//        JPanel old=this.jPanel1;
//        
//        this.removeAll();
//        
//        this.setLayout(new BorderLayout());
//        
//        this.add(old,BorderLayout.CENTER);
//        
//        JCheckBox butdisp = new JCheckBox("Display");
//        butdisp.addActionListener(new ActionListener(){
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                
//            }        
//        });
//        
//        old.add(butdisp);
//        
//        
        sourcePanel=new JPanel();
        sourcePanel.setLayout(new GridBagLayout());
        
//        
////        this.add(sourcePanel,BoxLayout.PAGE_AXIS);
//        
        this.enableResetControlsHelpPanel.add(sourcePanel);
//        
////        controlPanel=new JPanel(); 
////        controlPanel.setLayout(new BoxLayout(controlPanel,BoxLayout.Y_AXIS));
////        this.add(controlPanel,BorderLayout.SOUTH);
//        
        addSources();
        
//        this.jPanel1.revalidate();
//        this.jPanel1.repaint();
        
        Dimension size2=sourcePanel.getPreferredSize();
        
        Dimension size=enableResetControlsHelpPanel.getPreferredSize();
        
        enableResetControlsHelpPanel.setPreferredSize(new Dimension(size.width,size2.height));
        
//        Container c=this.getTopLevelAncestor();
//        if (c instanceof Window)
//            ((Window)c).pack();
        
//        this.setVisible(true);
        
//        ((JPanel)this.getParent()).revalidate();
//        this.repaint();
//        
//        
        this.enabledCheckBox.addActionListener(new ActionListener(){

            @Override
            public void actionPerformed(ActionEvent e) {
                node.setEnabled(enabledCheckBox.isSelected());
            }
        });
//        
        
        
        
        
    }