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

The following are Jave code examples for showing how to use setForeground() 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: 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 2
Project: GIFKR   File: ProgressFrame.java   View Source Code Vote up 6 votes
private void initializeComponents() {
	progressText = new JLabel(new ImageIcon(ImageTools.scaleToHeight(ImageTools.getResourceImage("iconsmall.png"), 50, false)));
	progressText.setForeground(Color.white);
	progressText.setVerticalTextPosition(JLabel.BOTTOM);
	progressText.setHorizontalTextPosition(JLabel.CENTER);
	cancelButton = new JButton("Cancel");
	
	setContentPane(new JPanel() {
		private static final long serialVersionUID = -8098561857624764691L;
		@Override
		public void paintComponent(Graphics g) {
			setOpaque(false);
			super.paintComponent(g);
			paintBG((Graphics2D) g);
		}
	});
	cancelButton.addActionListener(ae -> {if(onCancel != null) onCancel.actionPerformed(ae);});
}
 
Example 3
Project: Equella   File: ClientLauncher.java   View Source Code Vote up 5 votes
private JComponent createServerList()
{
	JLabel profileLabel = new JLabel("Choose a Server:");

	configureLink = new JLabel("Configure...");
	configureLink.setForeground(Color.BLUE);
	configureLink.addMouseListener(this);

	profileChoice = new JComboBox();
	profileChoice.addActionListener(this);
	profileChoice.setRenderer(new DefaultListCellRenderer()
	{
		@Override
		public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
			boolean cellHasFocus)
		{
			super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
			ServerProfile p = (ServerProfile) value;
			if( p != null )
			{
				setText(p.getName() + " - " + p.getServer());
			}
			return this;
		}
	});

	final int height1 = profileChoice.getPreferredSize().height;
	final int width1 = configureLink.getPreferredSize().width;

	final int[] rows = {height1, height1,};
	final int[] cols = {TableLayout.FILL, width1,};

	JPanel all = new JPanel(new TableLayout(rows, cols));
	all.add(profileLabel, new Rectangle(0, 0, 1, 1));
	all.add(configureLink, new Rectangle(1, 0, 1, 1));
	all.add(profileChoice, new Rectangle(0, 1, 2, 1));

	return all;
}
 
Example 4
Project: Progetto-A   File: PartitaOfflineGuiView.java   View Source Code Vote up 5 votes
private void stampaCartaCoperta() {
    int nGiocatori = model.getGiocatori().size();
    sfondo.removeAll();
    sfondo.repaint();
    for(int i = 0; i < nGiocatori; i++)
        stampaNomeFiches(model.getGiocatori().get(i));
    
    pausa(pausa_breve);
    
    Font font = new Font("Carte Coperte msg", Font.BOLD, 70);
    JLabel messaggioCartaCoperta = new JLabel("Distribuisco carta coperta...");
    messaggioCartaCoperta.setFont(font);
    messaggioCartaCoperta.setForeground(Color.black);
    int strWidth = messaggioCartaCoperta.getFontMetrics(font).stringWidth("Distribuisco carta coperta...");
    messaggioCartaCoperta.setBounds(this.getWidth()/2 - strWidth/2, this.getHeight()/2 - 60, strWidth, 90);
    
    sfondo.add(messaggioCartaCoperta);
    sfondo.repaint();
    
    for(int i = 0; i < nGiocatori; i++) {
        if(i != nGiocatori - 1)
            carteCoperteBots.add(stampaCarta((this.getWidth()*(2*i+1))/((nGiocatori-1)*2) - 125, 180, "retroCarta"));
        else {
                stampaCarta(this.getWidth()/2 - 125, 3*this.getHeight()/4 - 60, model.getGiocatori().get(i).getCartaCoperta().toString());
            valoriMano.put(model.getGiocatoreLocale().getNome(), stampaValoreMano(model.getGiocatoreLocale()));
        }
        pausa(pausa_breve);
    }
    
    sfondo.remove(messaggioCartaCoperta);
    sfondo.add(esci);
    sfondo.repaint();
    
    needCartaCoperta = false;
}
 
Example 5
Project: apcs_final   File: PauseMenu.java   View Source Code Vote up 5 votes
public void makePauseLabel()
{
	pauseLabel = new JLabel("PAUSE");
	pauseLabel.setForeground(GameConstants.PAUSE_FG_COLOR);
	pauseLabel.setBounds(0, 0, getWidth(), 2*getHeight()/3);
	pauseLabel.setHorizontalAlignment(SwingConstants.CENTER);
	add(pauseLabel);
}
 
Example 6
Project: incubator-netbeans   File: BrowserMenu.java   View Source Code Vote up 5 votes
private JLabel createLabel( String text ) {
    JLabel res = new JLabel(text);
    if( GTK ) {
        Color foreground = UIManager.getColor( "MenuItem.foreground"); //NOI18N
        if( null != foreground ) {
            res.setForeground( new Color(foreground.getRGB()) );
        }
    }
    return res;
}
 
Example 7
Project: JavaGraph   File: FreshNameDialog.java   View Source Code Vote up 5 votes
private JLabel getErrorLabel() {
    if (this.errorLabel == null) {
        JLabel result = this.errorLabel = new JLabel();
        result.setForeground(Color.RED);
        result.setMinimumSize(getOkButton().getPreferredSize());
    }
    return this.errorLabel;
}
 
Example 8
Project: COE1186   File: TrnControllerGUI.java   View Source Code Vote up 4 votes
public void stylizeInfoLabel_Bold(JLabel l){
	l.setHorizontalAlignment(SwingConstants.LEFT);
	l.setForeground(new Color(234, 201, 87));
	l.setFont(font_16_bold);
}
 
Example 9
Project: freecol   File: CompactLabourReport.java   View Source Code Vote up 4 votes
private JLabel createNonCountedLabel(int otherAmateurs) {
    JLabel label = createNumberLabel(otherAmateurs,
                                     "report.labour.notCounted.tooltip");
    label.setForeground(Color.GRAY);
    return label;
}
 
Example 10
Project: Library-app   File: GestionUsuarios.java   View Source Code Vote up 4 votes
public GestionUsuarios(Connection conn,JFrame principal) {
	super();
	this.conn=conn;		// Recibimos la conexi�n de Biblioteca
	this.principal=principal;
	this.principal.setEnabled(false);
	this.principal.setVisible(false);
	setTitle("Gesti�n de usuarios");
	
	txtApellido1 = new JTextField();
	txtApellido1.setEditable(false);
	txtApellido1.setHorizontalAlignment(SwingConstants.CENTER);
	txtApellido1.setBounds(14, 78, 110, 20);
	getContentPane().add(txtApellido1);
	txtApellido1.setColumns(10);
	
	txtApellido2 = new JTextField();
	txtApellido2.setEditable(false);
	txtApellido2.setHorizontalAlignment(SwingConstants.CENTER);
	txtApellido2.setBounds(138, 78, 110, 20);
	getContentPane().add(txtApellido2);
	txtApellido2.setColumns(10);
	
	txtNombre = new JTextField();
	txtNombre.setEditable(false);
	txtNombre.setHorizontalAlignment(SwingConstants.CENTER);
	txtNombre.setBounds(262, 78, 110, 20);
	getContentPane().add(txtNombre);
	txtNombre.setColumns(10);
	
	JLabel lblApellido = new JLabel("Apellido 1");
	lblApellido.setHorizontalAlignment(SwingConstants.CENTER);
	lblApellido.setBounds(41, 53, 56, 14);
	getContentPane().add(lblApellido);
	
	JLabel lblApellido_1 = new JLabel("Apellido 2");
	lblApellido_1.setHorizontalAlignment(SwingConstants.CENTER);
	lblApellido_1.setBounds(165, 53, 56, 14);
	getContentPane().add(lblApellido_1);
	
	JLabel lblNombre = new JLabel("Nombre");
	lblNombre.setHorizontalAlignment(SwingConstants.CENTER);
	lblNombre.setBounds(289, 53, 56, 14);
	getContentPane().add(lblNombre);
	
	txtCodigoUser = new JTextField();
	txtCodigoUser.setEditable(false);
	txtCodigoUser.setHorizontalAlignment(SwingConstants.CENTER);
	txtCodigoUser.setBounds(153, 136, 86, 20);
	getContentPane().add(txtCodigoUser);
	txtCodigoUser.setColumns(10);
	
	lblCodigo = new JLabel("Codigo");
	lblCodigo.setHorizontalAlignment(SwingConstants.CENTER);
	lblCodigo.setBounds(173, 111, 46, 14);
	getContentPane().add(lblCodigo);
	
	lblGestinDeUsuario = new JLabel("Gesti\u00F3n de usuario");
	lblGestinDeUsuario.setHorizontalAlignment(SwingConstants.CENTER);
	lblGestinDeUsuario.setForeground(Color.BLUE);
	lblGestinDeUsuario.setBounds(137, 11, 111, 14);
	getContentPane().add(lblGestinDeUsuario);
}
 
Example 11
Project: scorekeeperfrontend   File: DifferenceRenderer.java   View Source Code Vote up 4 votes
/**
 * Create the renderer using a particular font, if given.
 */
public DifferenceRenderer()
{
	super();

	colorA = new Color(210, 150, 0);
	colorB = new Color(0, 140, 160);

	//setOpaque(true);
	setLayout(new MigLayout("debug 100, fill, ins 1 10 1 10, gap 1", "[grow 0, right][grow 100, center][grow 0, right]"));

	Font fix = new Font("fixed", Font.PLAIN, 18);
	Font lblfont = new Font("serif", Font.PLAIN, 18);
	Font msgfont = new Font("serif", Font.PLAIN, 20);

	overleft = new JLabel();
	overleft.setFont(fix);

	overlbl = new JLabel();
	overlbl.setFont(lblfont);

	overright = new JLabel();
	overright.setFont(fix);

	coverleft = new JLabel();
	coverleft.setFont(fix);

	coverlbl = new JLabel();
	coverlbl.setFont(lblfont);

	coverright = new JLabel();
	coverright.setFont(fix);

	newdialleft = new JLabel();
	newdialleft.setFont(fix);
	newdialleft.setForeground(Color.RED);

	newdiallbl = new JLabel();
	newdiallbl.setFont(lblfont);

	newdialright = new JLabel();
	newdialright.setFont(fix);
	newdialright.setForeground(Color.RED);

	msg1 = new JLabel();
	msg1.setFont(msgfont);

	msg2 = new JLabel();
	msg2.setFont(msgfont);

	add(overleft, "");
	add(overlbl, "");
	add(overright, "wrap");

	add(coverleft, "");
	add(coverlbl, "");
	add(coverright, "wrap");

	add(newdialleft, "");
	add(newdiallbl, "");
	add(newdialright, "wrap");

	add(msg1, "alignx center, spanx 3, wrap"); 
	add(msg2, "alignx center, spanx 3, wrap");
}
 
Example 12
Project: nbreleaseplugin   File: ViewerPanel.java   View Source Code Vote up 4 votes
private JLabel display(String text, Color col) {
    JLabel comp = new JLabel(text);
    comp.setForeground(col);
    return comp;
}
 
Example 13
Project: geomapapp   File: BaseMapSelect.java   View Source Code Vote up 4 votes
public int getBaseMap() {
	ButtonGroup bg = new ButtonGroup();
	mapsTB = new JToggleButton[MapApp.SUPPORTED_MAPS.size()];
	maps = new int[MapApp.SUPPORTED_MAPS.size()];
	JPanel panel2 = new JPanel( new FlowLayout() );

	UIManager.put("ToggleButton.shadow", Color.decode("#7EA5C6"));
	UIManager.put ("ToggleButton.select",
			(Color) UIManager.get ("ToggleButton.shadow"));
	int i = 0;
	for (Iterator<Integer> iter = MapApp.SUPPORTED_MAPS.iterator(); iter.hasNext();) {
		int map = iter.next().intValue();
		mapsTB[i] = getMapToggleButton(map);
		maps[i] = map;

		bg.add(mapsTB[i]);
		mapsTB[i].addActionListener( this);
		panel2.add( mapsTB[i] );
		i++;
	}

	mapsTB[initialMapSelection].setSelected(true);
	JPanel panel = new JPanel( new BorderLayout() );
	panel.add(panel2);

	JLabel label = new JLabel( "Choose a Base Map Projection:  ");
	label.setForeground( Color.black);

	selected = new JLabel( NAMES.get(new Integer(maps[initialMapSelection])).toString() + " Selected" + '\n');
	selected.setForeground( Color.decode("#496781"));

	JPanel panelN = new JPanel( new BorderLayout() );
	panelN.add(label, "West");
	panelN.add(selected);
	panelN.add(new JLabel("version " + haxby.map.MapApp.VERSION), "East");
	panel.add( panelN,"North" );

	JPanel southPanel1 = new JPanel( new GridLayout(0,1) );

	infoLabel = new JLabel("<html>Created By: William F. Haxby <font size=2>('03-'06)</font>, William B.F. Ryan <font size=2>('03-present)</font></font>" +
			"<br>Developers: Neville Shane <font size=2>('16-present)</font>, Justin Coplan <font size=2>('04-'11)</font>, Sze-Man(Samantha) Chan <font size=2>('09-'15)</font>, Andrew K. Melkonian <font size=2>('06-'09)</font>,<br>&#09; Donald E. Pomeroy <font size=2>('11-'12)</font>" +
			"<br>Funded By: National Science Foundation & Trustees of Columbia University" +
			"<br><br><center><font color=#CC3333>The Displayed Maps, Images, Data Tables are not to be used for Navigation Purposes.</font></center></html>");
	southPanel1.add(infoLabel);

	JPanel panelS = new JPanel( new BorderLayout() );
	panelS.add(southPanel1,"North");

	panel.add(panelS,"South");
	// Control over button dialogs. Default to Agree Selection
	Object[] options = {"Agree","Cancel"};
	
	// Signify if running in Development Mode
	String devText = "";
	if(MapApp.BASE_URL.matches(MapApp.DEV_URL))
		 devText = "**DEVELOPMENT MODE** ";
	
	int ok = JOptionPane.showOptionDialog( null, panel, devText + "Choose a Base Map Projection",
			JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null,
			options,
			options[0]);
	if(ok == JOptionPane.YES_OPTION) {
		for (i = 0; i < mapsTB.length; i++) {
			if (mapsTB[i].isSelected())
				ok = maps[i];
			mapsTB[i] = null;
		}
	}else {
		ok = -1;
	}
	return ok;
}
 
Example 14
Project: COE1186   File: SimulatorGui.java   View Source Code Vote up 4 votes
public void stylizeInfoLabel_Small(JLabel l){
	l.setHorizontalAlignment(SwingConstants.LEFT);
	l.setForeground(UIManager.getColor("Button.disabledToolBarBorderBackground"));
	l.setFont(font_14_bold);
}
 
Example 15
Project: snake-game   File: MainWindow.java   View Source Code Vote up 4 votes
private JLabel getStylizedLabel(String text) {
	JLabel label = new JLabel(text);
	label.setFont(defaultFont);
	label.setForeground(DEFAULT_SNAKE_COLOR);
	return label;
}
 
Example 16
Project: FreeCol   File: CompactLabourReport.java   View Source Code Vote up 4 votes
private void addLocationSummary(LabourData.LocationData data, int row) {
    int rows = data.getRowCount();

    JLabel colonistsLabel = createNumberLabel(data.getTotalColonists(), null);
    if (data.getUnitData().isSummary()) {
        if (isOverview()) {
            reportPanel.add(createEmptyLabel(), "cell " + UNIT_TYPE_COLUMN + " " + row + " 1 " + rows);
        }
    } else {
        Utility.localizeToolTip(colonistsLabel, StringTemplate
            .template("report.labour.unitTotal.tooltip")
            .addName("%unit%", data.getUnitData().getUnitName()));
    }

    reportPanel.add(colonistsLabel, "cell " + COLONIST_SUMMARY_COLUMN + " " + row + " 1 " + data.getRowCount());

    if (showProduction && !data.getUnitData().showProduction()) {
        reportPanel.add(createEmptyLabel(), "cell " + PRODUCTION_SYMBOL_COLUMN + " " + row + " 4 " + rows);
        return;
    }

    if (showProduction) {
        JLabel productionLabel = createNumberLabel(data.getTotalProduction(), "report.labour.potentialProduction.tooltip");
        if (!data.isTotal() && data.getTotalProduction() == 0) {
            productionLabel.setText("");
        }

        reportPanel.add(productionLabel, "cell " + PRODUCTION_SUMMARY_COLUMN + " " + row + " 1 " + rows);
    }

    if (showNetProduction) {
        int net = data.getNetProduction();
        JLabel netProductionLabel = createNumberLabel(net, "report.labour.netProduction.tooltip");

        if (!data.getUnitData().showNetProduction() || (!data.isTotal() && net == 0)) {
            netProductionLabel.setText("");
            netProductionLabel.setToolTipText("");
        } else if (net >= 0) {
            netProductionLabel.setText("+" + net);
        } else {
            netProductionLabel.setForeground(Color.RED);
        }
        reportPanel.add(netProductionLabel, "cell " + NETPRODUCTION_SUMMARY_COLUMN + " " + row + " 1 " + rows);
    }

    if (showProductionSymbols) {
        JLabel icon = new JLabel();
        icon.setBorder(Utility.CELLBORDER);
        GoodsType goods = data.getUnitData().getExpertProduction();
        if (goods != null) {
            icon.setIcon(new ImageIcon(getImageLibrary().getIconImage(goods)));
        }
        reportPanel.add(icon, "cell " + PRODUCTION_SYMBOL_COLUMN + " " + row + " 1 " + rows);
    }
}
 
Example 17
Project: COE1186   File: TrackModelGUI.java   View Source Code Vote up 4 votes
public void stylizeInfoLabel_Small(JLabel l){
	l.setHorizontalAlignment(SwingConstants.LEFT);
	l.setForeground(UIManager.getColor("Button.disabledToolBarBorderBackground"));
	l.setFont(font_14_bold);
}
 
Example 18
Project: faitic-checker   File: About.java   View Source Code Vote up 4 votes
private static void selectOption(JLabel selectedLabel, String filename){
	
	JLabel[] labels=new JLabel[]{lblLicensesAndAttributions, lblFaicheckLicense, lblContributors, lblChangelog};
	
	for(JLabel label : labels){
		
		if(label.equals(selectedLabel)){
			
			// Selected label
			
			label.setForeground(SystemColor.controlText);
			
		} else{
			
			// Not selected label
			
			label.setForeground(new Color(0,110,198,255));
			
		}
		
	}
	
	if(filename!=null) loadTextFile(filename);
	
}
 
Example 19
Project: Star-Ride--RiverRaid   File: PanelScore.java   View Source Code Vote up 4 votes
/**
 * Inicia los componentes del panel del Score
 */
public void initComponents(){
    int extra = 30;
    //FUENTE
    StarJedi = this.cargarFuente("../Starjedi.ttf");
    
    /**
     * TODO TIEMPO
     */
    iconTiempo = new JLabel("tiempo");               
    iconTiempo.setBounds(40, 10+extra, 200, 50);
    iconTiempo.setForeground(Color.yellow);
    iconTiempo.setFont(StarJedi);
    
    intTiempo = 0;
    tiempo = new JLabel(String.valueOf(intTiempo));
    tiempo.setBounds(82, 80+extra, 100, 30);
    tiempo.setForeground(Color.yellow);
    tiempo.setFont(StarJedi.deriveFont(1, 22f));
    
    /**
     * TODO SCORE
     */
    iconScore = new JLabel("score");               
    iconScore.setBounds(45, 130+extra, 200, 50);
    iconScore.setForeground(Color.yellow);
    iconScore.setFont(StarJedi);
    
    intScore = 0;
    score = new JLabel(String.valueOf(intScore));
    score.setForeground(Color.yellow);
    score.setFont(StarJedi.deriveFont(1, 22f));
    score.setBounds(90, 200+extra, 100, 30);
    
    /**
     * TODO COMBUSTIBLE
     */
    iconFuel = new JLabel();               
    iconFuel.setBounds(10, 250+extra, 200, 50);
    iconFuel.setForeground(Color.yellow);
    iconFuel.setFont(StarJedi.deriveFont(1, 22f));
    iconFuel.setText("Combustible");
    
    fuel = new JProgressBar(0);
    fuel.setBounds(25, 325+extra, 150, 30);  
    fuel.setValue(100);
    fuel.setBackground(Color.BLACK);
    
    /**
     * TODO VIDAS
     */
    iconLives = new JLabel();               
    iconLives.setBounds(43, 380+extra, 200, 50);
    iconLives.setForeground(Color.yellow);
    iconLives.setFont(StarJedi);
    iconLives.setText("vidas");
    
    intLives = 3;
    lives = new JLabel(String.valueOf(intLives));
    lives.setForeground(Color.yellow);
    lives.setFont(StarJedi.deriveFont(1, 22f));
    lives.setBounds(90, 450+extra, 100, 30);
    
    super.add(iconTiempo, 0);
    super.add(tiempo, 0);
    super.add(iconScore, 0);
    super.add(score, 0);
    super.add(iconFuel, 0);
    super.add(fuel, 0);
    super.add(iconLives, 0);
    super.add(lives, 0);
}
 
Example 20
Project: FreeCol   File: CompactLabourReport.java   View Source Code Vote up 4 votes
private JLabel createNonCountedLabel(int otherAmateurs) {
    JLabel label = createNumberLabel(otherAmateurs,
                                     "report.labour.notCounted.tooltip");
    label.setForeground(Color.GRAY);
    return label;
}