Java Code Examples for javax.swing.JLabel.setPreferredSize()

The following are Jave code examples for showing how to use setPreferredSize() of the javax.swing.JLabel 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: InitPanel.java   View Source Code Vote up 6 votes
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();  
    }
}
 
Example 2
Project: openjdk-jdk10   File: Test8039464.java   View Source Code Vote up 6 votes
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);
}
 
Example 3
Project: JavaGraph   File: FindReplaceDialog.java   View Source Code Vote up 6 votes
/**
 * 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;
}
 
Example 4
Project: incubator-netbeans   File: TaskListTable.java   View Source Code Vote up 5 votes
/** 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;
}
 
Example 5
Project: AgentWorkbench   File: MainWindow.java   View Source Code Vote up 5 votes
/**
 * 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;
}
 
Example 6
Project: rapidminer   File: ColorRGBComboBoxCellRenderer.java   View Source Code Vote up 5 votes
@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;
}
 
Example 7
Project: brModelo   File: FrameSobre.java   View Source Code Vote up 5 votes
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();
        }
    }
 
Example 8
Project: rapidminer   File: IOObjectCacheEntryPanel.java   View Source Code Vote up 5 votes
/**
 * 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);
}
 
Example 9
Project: zencash-swing-wallet-ui   File: MessagingOptionsEditDialog.java   View Source Code Vote up 5 votes
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);
}
 
Example 10
Project: zooracle   File: GUISettings.java   View Source Code Vote up 5 votes
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;
}
 
Example 11
Project: zencash-swing-wallet-ui   File: IdentityInfoDialog.java   View Source Code Vote up 5 votes
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);
}
 
Example 12
Project: openjdk-jdk10   File: DisplayListenerLeak.java   View Source Code Vote up 5 votes
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);
}
 
Example 13
Project: JavaGraph   File: FindReplaceDialog.java   View Source Code Vote up 5 votes
/** 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;
}
 
Example 14
Project: alevin-svn2   File: Gui.java   View Source Code Vote up 4 votes
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);
}
 
Example 15
Project: rapidminer   File: ConfigurableDialog.java   View Source Code Vote up 4 votes
/**
 * 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);
}
 
Example 16
Project: rapidminer   File: OAuthDialog.java   View Source Code Vote up 4 votes
/**
 * Basic method to initialize the GUI.
 */
private void initGUI() {
	JPanel outerPanel = new JPanel();
	outerPanel.setLayout(new GridBagLayout());
	GridBagConstraints gbc = new GridBagConstraints();

	gbc.gridx = 0;
	gbc.gridy = 0;
	gbc.weightx = 1;
	gbc.fill = GridBagConstraints.BOTH;
	outerPanel.add(createStep1Panel(), gbc);

	if (oAuth.isOAuth2()) {
		gbc.gridy += 1;
		outerPanel.add(createStep2Panel(), gbc);
	}

	statusLabel = new JLabel();
	statusLabel.setMinimumSize(new Dimension(400, 25));
	statusLabel.setPreferredSize(new Dimension(400, 25));
	statusLabel.setHorizontalAlignment(JLabel.RIGHT);
	gbc.gridy += 1;
	gbc.insets = new Insets(5, 5, 5, 5);
	outerPanel.add(statusLabel, gbc);

	gbc.gridy += 1;
	Component btPanel = createButtons();
	outerPanel.add(btPanel, gbc);

	add(outerPanel);
	layoutDefault(outerPanel, confirmButton, cancelButton);
	if (oAuth.isOAuth2()) {
		setPreferredSize(new Dimension(375, 430));
	} else {
		setPreferredSize(new Dimension(375, 320));
	}
	setResizable(false);
	setModal(true);
	pack();
	setLocationRelativeTo(ApplicationFrame.getApplicationFrame());
}
 
Example 17
Project: jmt   File: KMeansInfoClustering.java   View Source Code Vote up 4 votes
private void initPanel() {
	Box mainPanel = Box.createHorizontalBox();
	Box allPanel = Box.createVerticalBox();
	mainPanel.add(Box.createHorizontalStrut(5));
	mainPanel.add(allPanel);
	mainPanel.add(Box.createHorizontalStrut(5));

	//this.setLayout(new BorderLayout());
	this.setLayout(new GridLayout(1, 1));
	this.add(mainPanel);

	JPanel constr = new JPanel(new BorderLayout());

	/** Pannello informazione clustering **/
	JPanel north = new JPanel(new FlowLayout(FlowLayout.LEFT, 20, 0));
	north.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "General information on clustering"));

	JLabel res = new JLabel();
	res.setPreferredSize(new Dimension((int) (BUTTONSIZE * 1.5), (int) (BUTTONSIZE * 1.5)));
	if (info.isGoodCluster == 1) {
		res.setIcon(JMTImageLoader.loadImage("Measure_ok", new Dimension((int) (BUTTONSIZE * 1.5), (int) (BUTTONSIZE * 1.5))));
	} else {
		res.setIcon(JMTImageLoader.loadImage("Measure_fail", new Dimension((int) (BUTTONSIZE * 1.5), (int) (BUTTONSIZE * 1.5))));
	}
	north.add(res);

	JPanel p = new JPanel(new GridLayout(2, 1, 5, 5));
	JLabel omsr = new JLabel(OMSR_START_TEXT + OMSR_END_TEXT + defaultFormat.format(info.omsr) + HTML_FONT_NOR_END + HTML_END);
	JLabel ratio = new JLabel(RATIO_START_TEXT + defaultFormat.format(info.ratio) + HTML_FONT_NOR_END + HTML_END);
	p.add(omsr);
	p.add(ratio);
	north.add(p, BorderLayout.CENTER);
	//this.add(north,BorderLayout.NORTH);
	constr.add(north, BorderLayout.NORTH);

	/** Pannello centrale **/
	JPanel center = new JPanel(new GridLayout(2, 1));

	/** Pannello clusters details **/
	JPanel clustDet = new JPanel(new BorderLayout(15, 5));
	clustDet.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Clusters details"));
	JScrollPane tabCluDetScroll = new JScrollPane(getClustDetTable());
	clustDet.add(tabCluDetScroll, BorderLayout.CENTER);
	clustDet.add(setPie1(), BorderLayout.EAST);

	/** Pannello variables details **/
	JPanel due = new JPanel(new BorderLayout(0, 0));
	due.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Distribution of the variable values among the clusters"));
	//combo variabili
	JPanel var = new JPanel(new BorderLayout(5, 0));
	chartVars = setPie2(0);
	var.add(new JLabel(HTML_START + HTML_FONT_TITLE + "Variables" + HTML_FONT_TIT_END + HTML_END, SwingConstants.CENTER), BorderLayout.NORTH);
	var.add(getListVars(), BorderLayout.CENTER);
	due.add(var, BorderLayout.WEST);
	//tabella info variabile
	JScrollPane tabVarsDetScroll = new JScrollPane(getVarsDetTable());
	//Update graphic interface
	listVars.clearSelection();
	due.add(tabVarsDetScroll, BorderLayout.CENTER);
	due.add(chartVars, BorderLayout.EAST);

	center.add(clustDet);
	center.add(due);

	//this.add(center,BorderLayout.CENTER);
	constr.add(center, BorderLayout.CENTER);
	allPanel.add(constr);
}
 
Example 18
Project: Recaf   File: MemberNodeRenderer.java   View Source Code Vote up 4 votes
private void addIcon(JPanel content, boolean selected, Icon icon) {
	JLabel lbl = new JLabel(icon);
	lbl.setPreferredSize(new Dimension(18, 16));
	formatLabel(lbl, selected);
	content.add(lbl);
}
 
Example 19
Project: VASSAL-src   File: MultiRoll.java   View Source Code Vote up 4 votes
public HeaderRow() {

      Border raisedbevel = BorderFactory.createRaisedBevelBorder();
      Border myBorder = raisedbevel;

      //setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
      //setBorder(blackline);

      JLabel col1 = new JLabel("Roll");
      col1.setPreferredSize(new Dimension(COL1_WIDTH, ROW_HEIGHT));
      col1.setHorizontalAlignment(JTextField.CENTER);
      col1.setBorder(myBorder);

//      JLabel col2 = new JLabel("Roll");
//      col2.setPreferredSize(new Dimension(COL2_WIDTH, ROW_HEIGHT));
//      col2.setHorizontalAlignment(JTextField.CENTER);
//            col2.setBorder(myBorder);

      JLabel col3 = new JLabel("Details");
      col3.setPreferredSize(new Dimension(COL3_WIDTH, ROW_HEIGHT));
      col3.setBorder(myBorder);

      JLabel col4 = new JLabel("nDice");
      col4.setBorder(myBorder);
      col4.setHorizontalAlignment(JTextField.CENTER);
      col4.setPreferredSize(new Dimension(COL4_WIDTH, ROW_HEIGHT));

      JLabel col5 = new JLabel("nSides");
      col5.setBorder(myBorder);
      col5.setHorizontalAlignment(JTextField.CENTER);
      col5.setPreferredSize(new Dimension(COL5_WIDTH, ROW_HEIGHT));

      JLabel col6 = new JLabel("add");
      col6.setBorder(myBorder);
      col6.setPreferredSize(new Dimension(COL6_WIDTH, ROW_HEIGHT));

      JLabel col7 = new JLabel("Total");
      col7.setBorder(myBorder);
      col7.setPreferredSize(new Dimension(COL7_WIDTH, ROW_HEIGHT));

      add(col1);
      //add(col2);
      add(col3);
      add(col4);
      add(col5);
      add(col6);
      add(col7);
    }
 
Example 20
Project: QN-ACTR-Release   File: JWatMainPanel.java   View Source Code Vote up 4 votes
public JWatMainPanel(MainJwatWizard parent) {
	this.parent = parent;
	this.help = parent.getHelp();
	this.setLayout(new BorderLayout());
	JPanel upper = new JPanel(new FlowLayout());
	JLabel upperLabel = new JLabel();
	upperLabel.setPreferredSize(new Dimension(300, 10));
	upper.add(upperLabel);

	JPanel bottom = new JPanel(new FlowLayout());
	JLabel bottomLabel = new JLabel();
	bottomLabel.setPreferredSize(new Dimension(300, 10));
	bottom.add(bottomLabel);

	this.add(upper, BorderLayout.NORTH);
	this.add(bottom, BorderLayout.SOUTH);

	JPanel eastPanel = new JPanel(new FlowLayout());
	eastPanel.add(Box.createVerticalStrut(5), BorderLayout.NORTH);
	JPanel buttonPanel = new JPanel(new GridLayout(buttonAction.length, 1, 2, 15));
	eastPanel.add(buttonPanel, BorderLayout.CENTER);
	for (AbstractAction element : buttonAction) {
		buttonPanel.add(createButton(element));
	}
	JLabel imageLabel = new JLabel();
	imageLabel.setBorder(BorderFactory.createEmptyBorder(BUTTONSIZE - 5, 1, 0, 0));
	//imageLabel.setIcon(new ImageIcon(image));
	imageLabel.setIcon(new ImageIcon(new ImageIcon(imageURL).getImage().getScaledInstance(400, 315, Image.SCALE_SMOOTH)));
	imageLabel.setHorizontalAlignment(SwingConstants.RIGHT);
	imageLabel.setVerticalAlignment(SwingConstants.NORTH);

	//JLabel description = new JLabel("<html><body><h3>This is a simple<br>descirption added to this<br>page. Please don't mind it<br>will be replaced soon</h3></body></html>");
	//this.add(description,BorderLayout.WEST);
	this.add(imageLabel, BorderLayout.CENTER);
	this.add(eastPanel, BorderLayout.EAST);
	makeToolbar();
	makeMenubar();
	parent.setEnableButton("Solve", false);
	parent.setActionButton("Help", new AbstractAction() {
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		public void actionPerformed(ActionEvent e) {
			System.err.println("HELP");
		}
	});
}