当前位置: 首页>>代码示例>>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;未经允许,请勿转载。