當前位置: 首頁>>代碼示例>>Java>>正文


Java JPanel.setForeground方法代碼示例

本文整理匯總了Java中javax.swing.JPanel.setForeground方法的典型用法代碼示例。如果您正苦於以下問題:Java JPanel.setForeground方法的具體用法?Java JPanel.setForeground怎麽用?Java JPanel.setForeground使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JPanel的用法示例。


在下文中一共展示了JPanel.setForeground方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getListCellRendererComponent

import javax.swing.JPanel; //導入方法依賴的package包/類
@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;
}
 
開發者ID:VISNode,項目名稱:VISNode,代碼行數:34,代碼來源:ProcessBrowser.java

示例2: actionPerformed

import javax.swing.JPanel; //導入方法依賴的package包/類
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);					
}
 
開發者ID:guilhebl,項目名稱:routerapp,代碼行數:36,代碼來源:GASettings.java

示例3: RRDraw

import javax.swing.JPanel; //導入方法依賴的package包/類
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");

}
 
開發者ID:marcelrv,項目名稱:XiaomiRobotVacuumProtocol,代碼行數:42,代碼來源:RRDraw.java

示例4: GASettings

import javax.swing.JPanel; //導入方法依賴的package包/類
/**
 * 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);		
}
 
開發者ID:guilhebl,項目名稱:routerapp,代碼行數:55,代碼來源:GASettings.java


注:本文中的javax.swing.JPanel.setForeground方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。