java setforeground_Java JPanel.setForeground方法代码示例

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);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值