当前位置: 首页>>代码示例>>Java>>正文


Java JLabel.setPreferredSize方法代码示例

本文整理汇总了Java中javax.swing.JLabel.setPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:Java JLabel.setPreferredSize方法的具体用法?Java JLabel.setPreferredSize怎么用?Java JLabel.setPreferredSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JLabel的用法示例。


在下文中一共展示了JLabel.setPreferredSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initComponents

import javax.swing.JLabel; //导入方法依赖的package包/类
protected void initComponents() {        
    if (!oPanel.isPrepared()) {
        initComponent = new JLabel(NbBundle.getMessage(InitPanel.class, "LBL_computing")); // NOI18N
        initComponent.setPreferredSize(new Dimension(850, 450));
        // avoid flicking ?
        Color c = UIManager.getColor("Tree.background"); // NOI18N
        if (c == null) {
            //GTK 1.4.2 will return null for Tree.background
            c = Color.WHITE;
        }
        initComponent.setBackground(c);    // NOI18N               
        initComponent.setHorizontalAlignment(SwingConstants.CENTER);
        initComponent.setOpaque(true);
        
        CardLayout card = new CardLayout();
        setLayout(card);            
        add(initComponent, "init");    // NOI18N
        card.show(this, "init"); // NOI18N        
        Utilities.attachInitJob(this, this);
    } else {
        finished();  
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:InitPanel.java

示例2: init

import javax.swing.JLabel; //导入方法依赖的package包/类
private static void init(Container container) {
    container.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy = 1;
    JLabel label = new JLabel();
    Dimension size = new Dimension(111, 0);
    label.setPreferredSize(size);
    label.setMinimumSize(size);
    container.add(label, gbc);
    gbc.gridx = 1;
    gbc.weightx = 1;
    container.add(new JScrollBar(JScrollBar.HORIZONTAL, 1, 111, 1, 1111), gbc);
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 1;
    container.add(new JScrollBar(JScrollBar.VERTICAL, 1, 111, 1, 1111), gbc);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:Test8039464.java

示例3: getOptionPane

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Lazily creates and returns the option pane that is to form the content of
 * the dialog.
 */
private JOptionPane getOptionPane() {
    if (this.optionPane == null) {
        JLabel oldLabel = new JLabel(OLD_TEXT);
        JLabel newLabel = new JLabel(NEW_TEXT);
        oldLabel.setPreferredSize(newLabel.getPreferredSize());
        JPanel oldPanel = new JPanel(new BorderLayout());
        oldPanel.add(oldLabel, BorderLayout.WEST);
        oldPanel.add(getOldField(), BorderLayout.CENTER);
        oldPanel.add(getOldTypeLabel(), BorderLayout.EAST);
        JPanel newPanel = new JPanel(new BorderLayout());
        newPanel.add(newLabel, BorderLayout.WEST);
        newPanel.add(getNewField(), BorderLayout.CENTER);
        newPanel.add(getNewTypeCombobox(), BorderLayout.EAST);
        JPanel errorPanel = new JPanel(new BorderLayout());
        errorPanel.add(getErrorLabel());
        errorPanel.setPreferredSize(oldPanel.getPreferredSize());
        this.optionPane = new JOptionPane(new Object[] {oldPanel, newPanel, errorPanel},
            JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null,
            new Object[] {getFindButton(), getReplaceButton(), getCancelButton()});
    }
    return this.optionPane;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:27,代码来源:FindReplaceDialog.java

示例4: getTableCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
/** Overrides superclass method. */
public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column ) {
    if( null == table ) {
        return new JLabel();
    }
    Component comp = origRenderer.getTableCellRendererComponent( table, value, isSelected, hasFocus, row, column );

    if( comp instanceof JLabel ) {
        JLabel label = (JLabel)comp;
        TaskListModel tlm = (TaskListModel)getModel();
        if( column == tlm.getSortingColumnn() ) {
            label.setIcon( getProperIcon( !tlm.isAscendingSort() ) );
            label.setHorizontalTextPosition( SwingConstants.LEADING );
        } else {
            label.setIcon( NO_ICON );
        }
        if( isGTK() && null != defaultRenderer ) {
            defaultRenderer.setText(label.getText());
            Dimension prefSize = defaultRenderer.getPreferredSize();
            if( prefSize.width > 1 && prefSize.height > 1 )
                label.setPreferredSize(prefSize);
            label.setText(" " + label.getText());
        }
    }

    return comp;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:TaskListTable.java

示例5: getStatusBar

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Gets the status bar.
 * @return the status bar
 */
private JPanel getStatusBar() {

	// --- Linker Teil ----------------------
	statusBar = new JLabel();
	statusBar.setPreferredSize(new Dimension(300, 16));
	statusBar.setFont(new Font("Dialog", Font.PLAIN, 12));

	// --- Mittlerer Teil -------------------
	statusJade = new JLabel();
	statusJade.setPreferredSize(new Dimension(200, 16));
	statusJade.setFont(new Font("Dialog", Font.PLAIN, 12));
	statusJade.setHorizontalAlignment(SwingConstants.RIGHT);
	setStatusJadeRunning(false);

	// --- Rechter Teil ---------------------
	JPanel RightPart = new JPanel(new BorderLayout());
	RightPart.add(new JLabel(new AngledLinesWindowsCornerIcon()), BorderLayout.SOUTH);
	RightPart.setOpaque(false);

	// --- StatusBar zusammenbauen ------------------
	JPanel JPStat = new JPanel(new BorderLayout());
	JPStat.setPreferredSize(new Dimension(10, 23));
	JPStat.add(statusBar, BorderLayout.WEST);
	JPStat.add(statusJade, BorderLayout.CENTER);
	JPStat.add(RightPart, BorderLayout.EAST);
	return JPStat;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:32,代码来源:MainWindow.java

示例6: getListCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
		boolean cellHasFocus) {
	JLabel listCellRendererComponent = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index,
			isSelected, cellHasFocus);

	listCellRendererComponent.setPreferredSize(new Dimension(50, 20));

	if (!(value instanceof Color)) {
		return listCellRendererComponent;
	}

	listCellRendererComponent.setText("");

	Color color = (Color) value;

	Icon iicon = colorMap.get(color);
	if (iicon == null) {
		colorMap.put(color, createColoredRectangleIcon(color));
		iicon = colorMap.get(color);
	}

	listCellRendererComponent.setIcon(iicon);
	listCellRendererComponent.setBackground(color);

	if (isSelected && index != -1) {
		listCellRendererComponent.setBorder(focusBorder);
	} else {
		listCellRendererComponent.setBorder(noFocusBorder);
	}

	return listCellRendererComponent;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:34,代码来源:ColorRGBComboBoxCellRenderer.java

示例7: Inicie

import javax.swing.JLabel; //导入方法依赖的package包/类
void Inicie(ParteAjuda sel) {
        this.setTitle(sel.getTitulo());
        if (sel.getByteImage() != null || sel.getHtml() != null) {//.isEmpty()) {
            Pan.removeAll();
            int H = 0;
            int W = 0;
            if (!sel.getHtml().isEmpty()) {
                JLabel htmLbl = new JLabel();
                htmLbl.setText(sel.getHtml());
                htmLbl.repaint();
                Dimension d = htmLbl.getPreferredSize();
                int x = (getPreferredSize().width - d.width) / 2;
                if (getPreferredSize().width < d.width) {
                    x = 0;
                }
//                int y = (getPreferredSize().height - d.height - subPan.getPreferredSize().height) / 2;
//                if (getPreferredSize().height - subPan.getPreferredSize().height < d.height) {
//                    y = 0;
//                }
                htmLbl.setBounds(x, 0, d.width, d.height);
                //Pan.setBackground(Color.yellow);
                Pan.add(htmLbl);
                H = d.height + 10;
                W = d.width;
            }
            if (sel.getByteImage() != null) {
                ImageIcon img = new ImageIcon(sel.getByteImage());
                JLabel picLabel = new JLabel(img);
                W = W > img.getIconWidth() ? W : img.getIconWidth();
                picLabel.setBounds(0, H, img.getIconWidth(), img.getIconHeight());
                picLabel.setPreferredSize(new Dimension(img.getIconWidth(), img.getIconHeight()));
                H += img.getIconHeight();
                Pan.setPreferredSize(new Dimension(W, H));
                Pan.add(picLabel);
            }
            Pan.revalidate();
            Pan.repaint();
        }
    }
 
开发者ID:chcandido,项目名称:brModelo,代码行数:40,代码来源:FrameSobre.java

示例8: IOObjectCacheEntryPanel

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Creates a new {@link IOObjectCacheEntryPanel}.
 *
 * @param icon
 *            The {@link Icon} associated with the entry's type.
 * @param entryType
 *            Human readable representation of the entry's type (e.g., 'Data Table').
 * @param openAction
 *            The action to be performed when clicking in the entry.
 * @param removeAction
 *            An action triggering the removal of the entry.
 */
public IOObjectCacheEntryPanel(Icon icon, String entryType, Action openAction, Action removeAction) {
	super(ENTRY_LAYOUT);

	this.openAction = openAction;

	// add icon label
	JLabel iconLabel = new JLabel(icon);
	add(iconLabel, ICON_CONSTRAINTS);

	// add object type label
	JLabel typeLabel = new JLabel(entryType);
	typeLabel.setMaximumSize(new Dimension(MAX_TYPE_WIDTH, 24));
	typeLabel.setPreferredSize(typeLabel.getMaximumSize());
	typeLabel.setToolTipText(entryType);
	add(typeLabel, TYPE_CONSTRAINTS);

	// add link button performing the specified action, the label displays the entry's key name
	LinkLocalButton openButton = new LinkLocalButton(openAction);
	openButton.setMargin(new Insets(0, 0, 0, 0));
	add(openButton, KEY_CONSTRAINTS);

	// add removal button
	JButton removeButton = new JButton(removeAction);
	removeButton.setBorderPainted(false);
	removeButton.setOpaque(false);
	removeButton.setMinimumSize(buttonSize);
	removeButton.setPreferredSize(buttonSize);
	removeButton.setContentAreaFilled(false);
	removeButton.setText(null);
	add(removeButton, REMOVE_BUTTON_CONSTRAINTS);

	// register mouse listeners
	addMouseListener(hoverMouseListener);
	iconLabel.addMouseListener(dispatchMouseListener);
	typeLabel.addMouseListener(dispatchMouseListener);
	openButton.addMouseListener(dispatchMouseListener);
	removeButton.addMouseListener(dispatchMouseListener);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:51,代码来源:IOObjectCacheEntryPanel.java

示例9: addFormField

import javax.swing.JLabel; //导入方法依赖的package包/类
private void addFormField(JPanel detailsPanel, String name, JComponent field)
{
	JPanel tempPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 2));
	JLabel tempLabel = new JLabel(name, JLabel.RIGHT);
	// TODO: hard sizing of labels may not scale!
	final int width = new JLabel("ZEN amount to send with every message:").getPreferredSize().width + 30;
	tempLabel.setPreferredSize(new Dimension(width, tempLabel.getPreferredSize().height));
	tempPanel.add(tempLabel);
	tempPanel.add(field);
	detailsPanel.add(tempPanel);
}
 
开发者ID:ZencashOfficial,项目名称:zencash-swing-wallet-ui,代码行数:12,代码来源:MessagingOptionsEditDialog.java

示例10: getDefaultLabel

import javax.swing.JLabel; //导入方法依赖的package包/类
public static JLabel getDefaultLabel(String title, int width, int height, int align, int valign)
{
	JLabel label = new JLabel(" " + title + " ", align);
	label.setPreferredSize(new Dimension(width, height));
	label.setVerticalAlignment(valign);
	return label;
}
 
开发者ID:fossasia,项目名称:zooracle,代码行数:8,代码来源:GUISettings.java

示例11: addFormField

import javax.swing.JLabel; //导入方法依赖的package包/类
private void addFormField(JPanel detailsPanel, String name, JComponent field)
{
	JPanel tempPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 2));
	JLabel tempLabel = new JLabel(name, JLabel.RIGHT);
	// TODO: hard sizing of labels may not scale!
	final int width = new JLabel("Sender identiication T address:").getPreferredSize().width + 10;
	tempLabel.setPreferredSize(new Dimension(width, tempLabel.getPreferredSize().height));
	tempPanel.add(tempLabel);
	tempPanel.add(field);
	detailsPanel.add(tempPanel);
}
 
开发者ID:ZencashOfficial,项目名称:zencash-swing-wallet-ui,代码行数:12,代码来源:IdentityInfoDialog.java

示例12: createAndShowGUI

import javax.swing.JLabel; //导入方法依赖的package包/类
private static void createAndShowGUI() {
    Thread.currentThread().setUncaughtExceptionHandler((t, e) -> {
        e.printStackTrace();
        failed = true;
    });
    frame = new JFrame();
    JLabel emptyLabel = new JLabel("");
    emptyLabel.setPreferredSize(new Dimension(600, 400));
    frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
    frame.pack();
    frame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:DisplayListenerLeak.java

示例13: getOldTypeLabel

import javax.swing.JLabel; //导入方法依赖的package包/类
/** Returns the combo box for the old label's type. */
private JLabel getOldTypeLabel() {
    if (this.oldTypeLabel == null) {
        final JLabel result = this.oldTypeLabel = new JLabel();
        result.setText(getOldLabel().getRole().getDescription(true));
        result.setPreferredSize(getNewTypeCombobox().getPreferredSize());
        result.setBorder(new EtchedBorder());
        result.setEnabled(true);
        result.setFocusable(false);
    }
    return this.oldTypeLabel;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:13,代码来源:FindReplaceDialog.java

示例14: Gui

import javax.swing.JLabel; //导入方法依赖的package包/类
public Gui(String title) {
	super(title);

	try {
		// Set System L&F
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		SwingUtilities.updateComponentTreeUI(this);
	} catch (Exception e) {
		e.printStackTrace();
	}

	// Set the frame icon.
	ImageIcon icon = Resources.getIconByName("/img/mulavito-logo.png");
	if (icon != null)
		setIconImage(icon.getImage());

	setLayout(new BorderLayout());

	toolBarPane = new JPanel();
	toolBarPane.setLayout(new BoxLayout(toolBarPane, BoxLayout.PAGE_AXIS));
	add(toolBarPane, BorderLayout.NORTH);

	toolBoxPane = new JPanel();
	toolBoxPane.setLayout(new BoxLayout(toolBoxPane, BoxLayout.Y_AXIS));
	add(toolBoxPane, BorderLayout.WEST);

	statusBar = new JLabel();
	statusBar.setPreferredSize(new Dimension(16, 16));
	statusBar.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
	add(statusBar, BorderLayout.SOUTH);
	//
	hints = new MouseOverHintManager(statusBar);
	hints.enterStatus("Ready");

	// layout of content with split panes
	JComponent content;
	// vertical group
	JComponent bottom = createBottomPane();
	JComponent center = createCenterPane();
	// if (bottom != null)
	// add(bottom, BorderLayout.SOUTH);
	if (center != null && bottom != null)
		content = new MySplit(JSplitPane.VERTICAL_SPLIT, center, bottom,
				0.9);
	else if (center != null)
		content = center;
	else
		content = bottom;
	// horizontal group
	JComponent right = createRightPane(), left = createLeftPane();
	if (content != null && right != null)
		content = new MySplit(JSplitPane.HORIZONTAL_SPLIT, content, right,
				0.9);
	else if (right != null)
		content = right;
	//
	if (content != null && left != null)
		content = new MySplit(JSplitPane.HORIZONTAL_SPLIT, left, content,
				0.1);
	else if (left != null)
		content = left;
	//
	if (content != null)
		add(content, BorderLayout.CENTER);
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:66,代码来源:Gui.java

示例15: initGUI

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Initializes the GUI.
 */
private void initGUI() {
	realOuterPanel = new JPanel(new BorderLayout());

	outerLayer = new JLayer<JPanel>(realOuterPanel);
	savingGlassPane = new TransparentGlassPanePanel(WAITING_ICON,
			I18N.getGUILabel("configurable_dialog.saving_configurables"), getBackground(), 0.5f);
	outerLayer.setGlassPane(savingGlassPane);
	savingGlassPane.setVisible(false);

	JPanel pagePanel = new JPanel(new BorderLayout());

	// list of configurables
	JPanel configPanel = createConfigPanel();
	// force size so it does not resize itself depending on entered values
	configPanel.setMinimumSize(CONFIG_LIST_SIZE);
	configPanel.setMaximumSize(CONFIG_LIST_SIZE);
	configPanel.setPreferredSize(CONFIG_LIST_SIZE);
	buttonPanel = createConfigurableButtonPanel();
	// create middle spacer
	JLabel spacer = new JLabel();
	spacer.setMinimumSize(DIMENSION_SPACER_MIDDLE);
	spacer.setMaximumSize(DIMENSION_SPACER_MIDDLE);
	spacer.setPreferredSize(DIMENSION_SPACER_MIDDLE);
	// add both to an outer panel for layout reasons
	JPanel outerConfigPanel = new JPanel(new BorderLayout());
	outerConfigPanel.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, Color.LIGHT_GRAY));
	outerConfigPanel.add(configPanel, BorderLayout.CENTER);
	outerConfigPanel.add(buttonPanel, BorderLayout.SOUTH);
	// another panel for layouting
	JPanel outermostConfigPanel = new JPanel(new BorderLayout());
	outermostConfigPanel.add(outerConfigPanel, BorderLayout.CENTER);
	outermostConfigPanel.add(spacer, BorderLayout.EAST);

	// glass pane showed if the user is not able to edit connections due to an old version of
	// the server
	simpleGlassPane = new TransparentGlassPanePanel(null, null, getBackground(), 0.5f);

	// panel displaying the selected configurable
	JPanel paramPanel = createParameterPanel();

	GridBagConstraints c = new GridBagConstraints();
	c.fill = GridBagConstraints.BOTH;
	c.weightx = 1;
	c.weighty = 0.3;
	c.gridwidth = GridBagConstraints.REMAINDER;

	// add panels to page panel
	pagePanel.add(outermostConfigPanel, BorderLayout.WEST);
	pagePanel.add(paramPanel, BorderLayout.CENTER);

	// add page and button panel to outer panel
	realOuterPanel.add(pagePanel, BorderLayout.CENTER);

	layoutDefault(outerLayer, makeSaveButton(), makeCancel());
	setDefaultSize(ButtonDialog.HUGE);
	setLocationRelativeTo(ApplicationFrame.getApplicationFrame());
	setModal(true);
	setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
	addWindowListener(new WindowAdapter() {

		@Override
		public void windowClosing(WindowEvent e) {
			cancelButton.doClick();
		}
	});

	updateButtonState(true);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:72,代码来源:ConfigurableDialog.java


注:本文中的javax.swing.JLabel.setPreferredSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。