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

The following are Jave code examples for showing how to use setForeground() of the javax.swing.JPanel 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: VISNode   File: ProcessBrowser.java   View Source Code Vote up 5 votes
@Override
public Component getListCellRendererComponent(JList<? extends Class<Process>> list, Class<Process> value, int index, boolean isSelected, boolean cellHasFocus) {
    ProcessMetadata metadata = processMetadata.get(value);
    // Title label
    JLabel label = (JLabel) defaultRenderer.getListCellRendererComponent(list, "", index, isSelected, cellHasFocus);
    label.setText(metadata.getName());
    label.setFont(new Font("Segoe UI", Font.BOLD, 12));
    // Description label
    JLabel description = new JLabel(metadata.getDescription());
    description.setForeground(description.getForeground());
    description.setBorder(BorderFactory.createEmptyBorder(1, 10, 3, 3));
    description.setFont(new Font("Segoe UI", Font.PLAIN, 10));
    if (metadata.getDescription() == null || metadata.getDescription().isEmpty()) {
        description.setText("<No description specified>");
        description.setForeground(description.getForeground().darker());
    }
    // Builds the component
    JPanel component = new JPanel();
    component.setLayout(new BorderLayout());
    component.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0));
    if (isSelected) {
        component.setBackground(new Color(0xEDEDED));
    } else {
        if (index % 2 == 0) {
            component.setBackground(new Color(0x555555));
        }
    }
    component.add(label);
    component.add(description, BorderLayout.SOUTH);
    component.setOpaque(true);
    component.setForeground(description.getForeground());
    return component;
}
 
Example 2
Project: routerapp   File: GASettings.java   View Source Code Vote up 5 votes
public void actionPerformed (ActionEvent evt) {
	centerPanel = new JPanel(new FlowLayout());

	maxGenerationsLabel = new JLabel("Max Generations");		
	maxGenerationsField = new JTextField((new Integer(TSProblemModel.DEFAULT_GA_MAX_GENERATIONS)).toString(), 5);
	
	popSizeLabel = new JLabel("Population Size");		
	popSizeField = new JTextField((new Integer(TSProblemModel.DEFAULT_GA_POP_SIZE)).toString(), 5);

	mutationRateLabel = new JLabel("Mutation Rate");		
	mutationRateField = new JTextField((new Double(TSProblemModel.DEFAULT_MUTATION_RATE)).toString(), 5);
	
	orderedCrossoverBox = new JCheckBox("Ordered Crossover", TSProblemModel.DEFAULT_ORDERED_CROSSOVER);
	cyclicCrossoverBox = new JCheckBox("Cyclic Crossover", TSProblemModel.DEFAULT_CYCLIC_CROSSOVER);
	pmxCrossoverBox = new JCheckBox("PMX Crossover", TSProblemModel.DEFAULT_PMX_CROSSOVER);
	simulatedAnnealingBox = new JCheckBox("Simulated Annealing", TSProblemModel.DEFAULT_ANNEAL);
	inverOverBox = new JCheckBox("Inver Over", TSProblemModel.DEFAULT_INVER_OVER);

	centerPanel.add(maxGenerationsLabel);
	centerPanel.add(maxGenerationsField);		
	centerPanel.add(popSizeLabel);
	centerPanel.add(popSizeField);
	centerPanel.add(mutationRateLabel);
	centerPanel.add(mutationRateField);			
	centerPanel.add(orderedCrossoverBox);
	centerPanel.add(cyclicCrossoverBox);	
	centerPanel.add(pmxCrossoverBox);
	centerPanel.add(inverOverBox);
	centerPanel.add(simulatedAnnealingBox);
	
	centerPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
	centerPanel.setForeground(Color.getColor("202,198,202"));
	
	getContentPane().add(centerPanel,BorderLayout.CENTER);					
}
 
Example 3
Project: XiaomiRobotVacuumProtocol   File: RRDraw.java   View Source Code Vote up 5 votes
public RRDraw() {
    super("File View Test Frame");
    setSize(350, 400);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    parent = this;
    rrDrawPanel = new RRDrawPanel();
    Container c = getContentPane();
    // The default BorderLayout will work better.
    // c.setLayout(new FlowLayout());

    JButton openButton = new JButton("Open");
    final JLabel statusbar = new JLabel("Output of your selection will go here");

    openButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            JFileChooser chooser = new JFileChooser("images");

            int option = chooser.showOpenDialog(parent);
            if (option == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                BufferedImage loadImage = loadImage(file);
                statusbar.setText(file.getName() + " size " + loadImage.getWidth() + "x" + loadImage.getHeight());
                // setSize(loadImage.getWidth(), loadImage.getHeight());
                rrDrawPanel.setSize(loadImage.getHeight(), loadImage.getWidth());
            } else {
                statusbar.setText("You cancelled.");
            }
        }
    });

    JPanel north = new JPanel();
    north.add(openButton);
    north.add(statusbar);

    north.setBackground(Color.GRAY);
    north.setForeground(Color.BLUE);
    c.add(north, "First");
    c.add(new JScrollPane(rrDrawPanel), "Center");

}
 
Example 4
Project: routerapp   File: GASettings.java   View Source Code Vote up 4 votes
/**
 * Creates an instance of this class.
 */
protected GASettings () {
	setTitle("Genetic Algorithm Settings");
	setBounds(50,50,520,520);

	centerPanel = new JPanel(new FlowLayout());
	JPanel southPanel  = new JPanel(new FlowLayout());

	maxGenerationsLabel = new JLabel("Max Generations");		
	maxGenerationsField = new JTextField((new Integer(TSProblemModel.DEFAULT_GA_MAX_GENERATIONS)).toString(), 5);
	
	popSizeLabel = new JLabel("Population Size");		
	popSizeField = new JTextField((new Integer(TSProblemModel.DEFAULT_GA_POP_SIZE)).toString(), 5);

	mutationRateLabel = new JLabel("Mutation Rate");		
	mutationRateField = new JTextField((new Double(TSProblemModel.DEFAULT_MUTATION_RATE)).toString(), 5);
	
	orderedCrossoverBox = new JCheckBox("Ordered Crossover", TSProblemModel.DEFAULT_ORDERED_CROSSOVER);
	cyclicCrossoverBox = new JCheckBox("Cyclic Crossover", TSProblemModel.DEFAULT_CYCLIC_CROSSOVER);
	pmxCrossoverBox = new JCheckBox("PMX Crossover", TSProblemModel.DEFAULT_PMX_CROSSOVER);
	simulatedAnnealingBox = new JCheckBox("Simulated Annealing", TSProblemModel.DEFAULT_ANNEAL);
	inverOverBox = new JCheckBox("Inver Over", TSProblemModel.DEFAULT_INVER_OVER);

	centerPanel.add(maxGenerationsLabel);
	centerPanel.add(maxGenerationsField);		
	centerPanel.add(popSizeLabel);
	centerPanel.add(popSizeField);
	centerPanel.add(mutationRateLabel);
	centerPanel.add(mutationRateField);			
	centerPanel.add(orderedCrossoverBox);
	centerPanel.add(cyclicCrossoverBox);	
	centerPanel.add(pmxCrossoverBox);
	centerPanel.add(inverOverBox);
	centerPanel.add(simulatedAnnealingBox);
	
	centerPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
	centerPanel.setForeground(Color.getColor("202,198,202"));
	
	// Create buttons and buttons panel
	JPanel buttonsPanel = new JPanel(new FlowLayout());
	buttonsPanel.add(new JButton(RESTORE_DEFAULT_ACTION));
	buttonsPanel.add(new JButton(OK_ACTION));
	buttonsPanel.add(new JButton(CANCEL_ACTION));

	// Add buttons panel in South Panel
	southPanel.add(buttonsPanel,BorderLayout.EAST);
	
	// Add panels in Main Panel
	this.getContentPane().setLayout(new BorderLayout());
	this.getContentPane().add(southPanel,BorderLayout.SOUTH);
	this.getContentPane().add(centerPanel,BorderLayout.CENTER);		
}