當前位置: 首頁>>代碼示例>>Java>>正文


Java JPanel.getPreferredSize方法代碼示例

本文整理匯總了Java中javax.swing.JPanel.getPreferredSize方法的典型用法代碼示例。如果您正苦於以下問題:Java JPanel.getPreferredSize方法的具體用法?Java JPanel.getPreferredSize怎麽用?Java JPanel.getPreferredSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JPanel的用法示例。


在下文中一共展示了JPanel.getPreferredSize方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createProgressPanel

import javax.swing.JPanel; //導入方法依賴的package包/類
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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:ReferencesBrowserController.java

示例2: update

import javax.swing.JPanel; //導入方法依賴的package包/類
/**
 * 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();
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:21,代碼來源:InfoPanel.java

示例3: defaultHeight

import javax.swing.JPanel; //導入方法依賴的package包/類
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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:SettingsPanel.java

示例4: setupGUI

import javax.swing.JPanel; //導入方法依賴的package包/類
@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));
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:35,代碼來源:BasicEditorPanel.java

示例5: setup

import javax.swing.JPanel; //導入方法依賴的package包/類
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();
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:44,代碼來源:WizardFrame.java

示例6: MultiInputPanel

import javax.swing.JPanel; //導入方法依賴的package包/類
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());
            }
        });
//        
        
        
        
        
    }
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:78,代碼來源:MultiInputPanel.java


注:本文中的javax.swing.JPanel.getPreferredSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。