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

The following are Jave code examples for showing how to use setSize() 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: myster   File: MessageManager.java   View Source Code Vote up 7 votes
public MessagePreferencesPanel() {
    setLayout(null);

    refuseMessages = new JCheckBox("Refuse Messages");
    refuseMessages.setSize(150, 25);
    refuseMessages.setLocation(10, 25);
    refuseMessages.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            updateEnabled();
        }
    });
    add(refuseMessages);

    denyMessageLabel = new JLabel("Refusal Message:");
    denyMessageLabel.setSize(150, 25);
    denyMessageLabel.setLocation(20, 50);
    add(denyMessageLabel);

    denyMessageText = new JTextField(REFUSAL_MESSAGE_DEFAULT);
    denyMessageText.setSize(400, 25);
    denyMessageText.setLocation(25, 75);
    add(denyMessageText);

    setSize(STD_XSIZE, STD_YSIZE);
}
 
Example 2
Project: SER316-Munich   File: App.java   View Source Code Vote up 7 votes
/**
 * Method showSplash.
 */
private void showSplash() {
	splash = new JFrame();
	ImageIcon spl =
		new ImageIcon(App.class.getResource("resources/splash.png"));
	JLabel l = new JLabel();
	l.setSize(400, 300);
	l.setIcon(spl);
	splash.getContentPane().add(l);
	splash.setSize(400, 300);
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	splash.setLocation(
		(screenSize.width - 400) / 2,
		(screenSize.height - 300) / 2);
	splash.setUndecorated(true);
	splash.setVisible(true);
}
 
Example 3
Project: FreeCol   File: MapViewer.java   View Source Code Vote up 6 votes
/**
 * Draw the unit's image and occupation indicator in one JLabel object.
 *
 * @param unit The unit to be drawn
 * @return A JLabel object with the unit's image.
 */
private JLabel createUnitLabel(Unit unit) {
    final BufferedImage unitImg = lib.getUnitImage(unit);
    final int width = halfWidth + unitImg.getWidth()/2;
    final int height = unitImg.getHeight();

    BufferedImage img = new BufferedImage(width, height,
                                          BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = img.createGraphics();

    final int unitX = (width - unitImg.getWidth()) / 2;
    g.drawImage(unitImg, unitX, 0, null);

    Player player = getMyPlayer();
    String text = Messages.message(unit.getOccupationLabel(player, false));
    g.drawImage(lib.getOccupationIndicatorChip(g, unit, text), 0, 0, null);

    final JLabel label = new JLabel(new ImageIcon(img));
    label.setSize(width, height);

    g.dispose();
    return label;
}
 
Example 4
Project: Reinickendorf_SER316   File: App.java   View Source Code Vote up 6 votes
/**
 * Method showSplash.
 */
private void showSplash() {
	splash = new JFrame();
	ImageIcon spl =
		new ImageIcon(App.class.getResource("resources/splash.png"));
	JLabel l = new JLabel();
	l.setSize(400, 300);
	l.setIcon(spl);
	splash.getContentPane().add(l);
	splash.setSize(400, 300);
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	splash.setLocation(
		(screenSize.width - 400) / 2,
		(screenSize.height - 300) / 2);
	splash.setUndecorated(true);
	splash.setVisible(true);
}
 
Example 5
Project: Jupiter   File: Splash.java   View Source Code Vote up 6 votes
public Splash(String splashText) throws InterruptedException, IOException{
		BufferedImage image;
		image = ImageIO.read(this.getClass().getClassLoader().getResourceAsStream("lang/jpn/Jupiter.jpg"));
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		label = new JLabel(new ImageIcon(image));
		label.setSize(408, 48);
		text = new JLabel(splashText);
		text.setSize(200, 30);
		text.setBackground(Color.BLACK);
		text.setForeground(Color.WHITE);
		text.setFont(new Font("MS Pゴシック", Font.PLAIN, 20));
		this.setSize(screenSize.width, 48);
		this.setLocation(0, 0);
		this.getContentPane().setBackground(Color.BLACK);
		this.setLayout(new BorderLayout());
		this.getContentPane().add(label, BorderLayout.CENTER);
		this.getContentPane().add(text, BorderLayout.EAST);
		this.setResizable(false);
		this.setUndecorated(true);
		this.setVisible(true);
		Thread.sleep(2000);
		this.setVisible(false);
}
 
Example 6
Project: freecol   File: MapViewer.java   View Source Code Vote up 6 votes
/**
 * Draw the unit's image and occupation indicator in one JLabel object.
 *
 * @param unit The unit to be drawn
 * @return A JLabel object with the unit's image.
 */
private JLabel createUnitLabel(Unit unit) {
    final BufferedImage unitImg = lib.getUnitImage(unit);
    final int width = halfWidth + unitImg.getWidth()/2;
    final int height = unitImg.getHeight();

    BufferedImage img = new BufferedImage(width, height,
                                          BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = img.createGraphics();

    final int unitX = (width - unitImg.getWidth()) / 2;
    g.drawImage(unitImg, unitX, 0, null);

    Player player = getMyPlayer();
    String text = Messages.message(unit.getOccupationLabel(player, false));
    g.drawImage(lib.getOccupationIndicatorChip(g, unit, text), 0, 0, null);

    final JLabel label = new JLabel(new ImageIcon(img));
    label.setSize(width, height);

    g.dispose();
    return label;
}
 
Example 7
Project: SER316-Aachen   File: App.java   View Source Code Vote up 6 votes
/**
 * Method showSplash.
 */
private void showSplash() {
	splash = new JFrame();
	ImageIcon spl =
		new ImageIcon(App.class.getResource("resources/splash.png"));
	JLabel l = new JLabel();
	l.setSize(400, 300);
	l.setIcon(spl);
	splash.getContentPane().add(l);
	splash.setSize(400, 300);
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	splash.setLocation(
		(screenSize.width - 400) / 2,
		(screenSize.height - 300) / 2);
	splash.setUndecorated(true);
	splash.setVisible(true);
}
 
Example 8
Project: openjdk-jdk10   File: TitledBorderLabelUITest.java   View Source Code Vote up 6 votes
private static void createAndShowGUI() {

        try {
            UIManager.setLookAndFeel(new TestLookAndFeel());

            JLabel label = new JLabel("Test Label");
            label.setSize(SIZE, SIZE);
            TitledBorder border = new TitledBorder("ABCDEF");
            label.setBorder(new TitledBorder(border));

            if (useLAF) {
                UIManager.setLookAndFeel(new NimbusLookAndFeel());
            } else {
                UIManager.getDefaults().put("LabelUI", MetalLabelUI.class.getName());
            }

            SwingUtilities.updateComponentTreeUI(label);

            paintToImage(label);

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
 
Example 9
Project: Dahlem_SER316   File: App.java   View Source Code Vote up 6 votes
/**
 * Method showSplash.
 */
private void showSplash() {
	splash = new JFrame();
	ImageIcon spl =
		new ImageIcon(App.class.getResource("resources/splash.png"));
	JLabel l = new JLabel();
	l.setSize(400, 300);
	l.setIcon(spl);
	splash.getContentPane().add(l);
	splash.setSize(400, 300);
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	splash.setLocation(
		(screenSize.width - 400) / 2,
		(screenSize.height - 300) / 2);
	splash.setUndecorated(true);
	splash.setVisible(true);
}
 
Example 10
Project: geomapapp   File: StartUp.java   View Source Code Vote up 5 votes
public StartUp( int which ) {
	try {
		URL url = null;
		switch (which) {
			case MapApp.MERCATOR_MAP:
				url = cl.getResource(startUpPath +"smallmapV3.jpg"); //New version3 images
				break;
			case MapApp.SOUTH_POLAR_MAP:
				url = cl.getResource(startUpPath + "MapAppSouthV3.jpg");
				break;
			case MapApp.NORTH_POLAR_MAP:
				url = cl.getResource(startUpPath + "MapAppNorthV3.jpg");
				break;
			case MapApp.WORLDWIND:
				url = cl.getResource(startUpPath + "VirtualOceanV3.jpg");
				break;
			default:
				url = cl.getResource(startUpPath + "smallmap.jpg");
		}
		image = ImageIO.read(url);
	} catch (Exception ex) {
		System.out.println(ex + " null");
		image=null;
	}
	setLayout(null);
	label = new JLabel("Initializing MapApp...");
	label.setFont( new Font("SansSerif", Font.PLAIN, 12) );
	label.setForeground( Color.black );
//	add( label );
	label.setLocation(10, 50);
	label.setSize( label.getPreferredSize() );
	JButton button = new JButton( "Abort" );
	add( button );
	button.setLocation( 3, 3);
	button.setSize( button.getPreferredSize() );
	button.addActionListener( this );
//	System.out.println( getComponentCount() + " components" );
	setBorder( BorderFactory.createLineBorder(Color.black, 2) );
}
 
Example 11
Project: KernelHive   File: ClusterVertex.java   View Source Code Vote up 5 votes
@Override
protected void paintComponent(Graphics g) {
	super.paintComponent(g);

	JLabel label = new JLabel("Cluster " + cluster.getHostname());
	label.setSize(200, 20);
	label.setHorizontalAlignment(SwingConstants.CENTER);
	add(label, BorderLayout.NORTH);
	//setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
}
 
Example 12
Project: cc-unespar   File: Mouse.java   View Source Code Vote up 5 votes
public void telinha() {	
	janela = new JFrame();
	//janela.addMouseListener(this);
	//janela.setSize(img.getWidth(null), img.getHeight(null));
	JLabel background = new JLabel();
	ImageIcon icone = new ImageIcon(img);
	background.addMouseListener(this);
	background.setSize(img.getWidth(null), img.getHeight(null));
	background.setIcon(icone);
	janela.add(background);
	janela.setVisible(true);
	janela.setFocusable(true);
	janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);	
}
 
Example 13
Project: hearthstone   File: Animacao.java   View Source Code Vote up 5 votes
/**
 * Criar JLabel padrão para as animações
 *
 * @return JLabel padrão
 */
private JLabel getJLabelDefault() {
    JLabel retorno = new JLabel("", SwingConstants.CENTER) {
        @Override
        public String toString() {
            return card.getToString();
        }
    };
    retorno.setSize(SIZE);
    retorno.setPreferredSize(SIZE);
    retorno.setVisible(false);
    return retorno;
}
 
Example 14
Project: hearthstone   File: Animacao.java   View Source Code Vote up 5 votes
/**
 * Criar JLabel padrão para as animações
 *
 * @return JLabel padrão
 */
private JLabel getJLabelDefault() {
    JLabel retorno = new JLabel("", SwingConstants.CENTER) {
        @Override
        public String toString() {
            return heroi.getToString();
        }
    };
    retorno.setSize(SIZE);
    retorno.setPreferredSize(SIZE);
    retorno.setVisible(false);
    return retorno;
}
 
Example 15
Project: hearthstone   File: PopUpSegredos.java   View Source Code Vote up 5 votes
public void showPopUp(List<Card> segredos){
    jPanelSegredos.removeAll();
    for(Card c : segredos){
        JLabel label = new JLabel(c.getImagemSmall());
        label.setPreferredSize(new Dimension(123, 190));
        label.setSize(new Dimension(123, 190));
        jPanelSegredos.add(label);
    }
    setVisible(true);
}
 
Example 16
Project: Tarski   File: mxRotationHandler.java   View Source Code Vote up 5 votes
/**
 * 
 */
protected JComponent createHandle() {
  JLabel label = new JLabel(ROTATE_ICON);
  label.setSize(ROTATE_ICON.getIconWidth(), ROTATE_ICON.getIconHeight());
  label.setOpaque(false);

  return label;
}
 
Example 17
Project: geomapapp   File: CustomDB.java   View Source Code Vote up 5 votes
protected JPanel createLassoPanel() {
		JPanel p2 = new JPanel(new BorderLayout());
		JToggleButton tb = new JToggleButton(Icons.getIcon(Icons.LASSO, false));
		tb.setSelectedIcon(Icons.getIcon(Icons.LASSO, true));
		tb.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
//				((AbstractButton)e.getSource()).setSelected(true);
				if (((AbstractButton)e.getSource()).isSelected()) {
					map.setBaseCursor(Cursors.getCursor(Cursors.LASSO));
				} else
					map.setBaseCursor(Cursor.getDefaultCursor());
			}
		});
		tb.setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 0));
		p2.add(tb, BorderLayout.WEST);
		p2.setBorder(null);
		JLabel l = new JLabel("<html>Lasso<br>Data</html>");
		l.setSize(35, 60);
		l.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0));
		p2.add(l);

//		***** GMA 1.6.2: Listen for lasso button to ensure that it works correctly with the 
//		zoom buttons in the main toolbar
		lassoTB = tb;
		lassoTB.addMouseListener(this);

		return p2;
	}
 
Example 18
Project: freecol   File: CornerMapControls.java   View Source Code Vote up 4 votes
/**
 * The basic constructor.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 */
public CornerMapControls(final FreeColClient freeColClient) {
    super(freeColClient, true);

    compassRose = new JLabel(new ImageIcon(ResourceManager.getImage("image.skin.compass")));
    compassRose.setFocusable(false);
    compassRose.setSize(compassRose.getPreferredSize());
    compassRose.addMouseListener(new MouseAdapter() {

            /**
             * {@inheritDoc}
             */
            @Override
            public void mouseClicked(MouseEvent e) {
                Unit unit = getGUI().getActiveUnit();
                if (unit == null) return;
                int x = e.getX() - compassRose.getWidth()/2;
                int y = e.getY() - compassRose.getHeight()/2;
                double theta = Math.atan2(y, x) + Math.PI/2 + Math.PI/8;
                if (theta < 0) {
                    theta += 2*Math.PI;
                }
                igc().moveUnit(unit, Direction.angleToDirection(theta));
            }
        });

    miniMapPanel = new MiniMapPanel();
    miniMapPanel.setFocusable(false);
    
    /**
     * In order to make the setLocation setup work, we need to set
     * the layout to null first, then set the size of the minimap,
     * and then its location.
     */
    miniMapPanel.setLayout(null);
    miniMap.setSize(MAP_WIDTH, MAP_HEIGHT);
    // Add buttons:
    miniMapPanel.add(miniMapToggleBorders);
    miniMapPanel.add(miniMapToggleFogOfWarButton);
    miniMapPanel.add(miniMapZoomInButton);
    miniMapPanel.add(miniMapZoomOutButton);
    miniMapPanel.add(miniMap);

    String miniMapSkinKey = "image.skin.MiniMap";
    if (ResourceManager.hasImageResource(miniMapSkinKey)) {
        miniMapSkin = ResourceManager.getImage(miniMapSkinKey);
        miniMapPanel.setBorder(null);
        miniMapPanel.setSize(miniMapSkin.getWidth(null),
                             miniMapSkin.getHeight(null));
        miniMapPanel.setOpaque(false);
        // FIXME: LATER: The values below should be specified by a
        // skin-configuration-file.
        miniMap.setLocation(38, 75);
        miniMapToggleBorders.setLocation(4,114);
        miniMapToggleFogOfWarButton.setLocation(4, 144);
        miniMapZoomInButton.setLocation(4, 174);
        miniMapZoomOutButton.setLocation(264, 174);
    } else {
        miniMapSkin = null;
        int width = miniMapZoomOutButton.getWidth()
            + miniMapZoomInButton.getWidth() + 4 * GAP;
        miniMapPanel.setOpaque(true);
        miniMap.setBorder(new BevelBorder(BevelBorder.RAISED));
        miniMap.setLocation(width/2, GAP);
        miniMapZoomInButton.setLocation(GAP, 
            MAP_HEIGHT + GAP - miniMapZoomInButton.getHeight());
        miniMapZoomOutButton.setLocation(
            miniMapZoomInButton.getWidth() + MAP_WIDTH + 3 * GAP,
            MAP_HEIGHT + GAP - miniMapZoomOutButton.getHeight());
    }
}
 
Example 19
Project: openjdk-jdk10   File: ColorCustomizationTest.java   View Source Code Vote up 4 votes
ColorCustomizationTest() {
    label = new JLabel();
    label.setSize(200, 100);

    g = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB).getGraphics();
}
 
Example 20
Project: jdk8u-jdk   File: ColorCustomizationTest.java   View Source Code Vote up 4 votes
ColorCustomizationTest() {
    label = new JLabel();
    label.setSize(200, 100);

    g = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB).getGraphics();
}