快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

java代码变成蓝色 java代码不变色

java中按钮获得焦点后变成蓝色

((JButton) e.getSource()).setBackground(Color.blue) ;

成都创新互联公司长期为成百上千客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为碌曲企业提供专业的成都网站设计、成都网站制作,碌曲网站改版等技术服务。拥有十年丰富建站经验和众多成功案例,为您定制开发。

Color.blue颜色常量 验证的时候是用tab键

如果要鼠标放上去变颜色 应该是MouseMotionListener

而不是 FocusListener

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import java.util.*;

class calculator extends JFrame implements ActionListener,MouseListener

{

JTextField l ;//用标签显示文字.因为标签是不能鼠标点的

JButton b[];//直接定义数组

Container c ;//容器

JPanel p1 ;//第一个显示输入信息的区域

JPanel p2 ;//第二个..显示所有按键的区域

public calculator ()

{

l=new JTextField("0.",25);

b=new JButton[16] ;

b[0]=new JButton("=");

b[1]=new JButton("0");

b[2]=new JButton("1");

b[3]=new JButton("2");

b[4]=new JButton("3");

b[5]=new JButton("4");

b[6]=new JButton("5");

b[7]=new JButton("6");

b[8]=new JButton("7");

b[9]=new JButton("8");

b[10]=new JButton("9");

b[11]=new JButton("+");

b[12]=new JButton("-");

b[13]=new JButton("*");

b[14]=new JButton("/");

b[15]=new JButton("Exit");

for(int i=0 ;i16;i++)

{

b[i].addMouseListener(this) ;

b[i].addActionListener(this) ;

b[i].setBackground(Color.gray) ;

}

p1=new JPanel() ;

p2=new JPanel() ;

c=getContentPane() ;//获得容器

c.setLayout(new BorderLayout());//容器设置布局管理器

p1.setLayout(new FlowLayout(FlowLayout.RIGHT)) ;

p2.setLayout(new GridLayout(4,4,10,10)) ;

p1.add(l) ;//靠右边放标签

p2.add(b[11]) ;

p2.add(b[12]) ;

p2.add(b[13]) ;

p2.add(b[14]) ;

p2.add(b[2]) ;

p2.add(b[3]) ;

p2.add(b[4]) ;

p2.add(b[1]) ;

p2.add(b[5]) ;

p2.add(b[6]) ;

p2.add(b[7]) ;

p2.add(b[0]) ;

p2.add(b[8]) ;

p2.add(b[9]) ;

p2.add(b[10]) ;

p2.add(b[15]) ;

c.add(p1,BorderLayout.NORTH) ;

c.add(p2,BorderLayout.CENTER) ;

setSize(300,220) ;

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) ;

setLocation(300,300) ;

setVisible(true) ;

}

public void actionPerformed(ActionEvent e)

{

if(e.getSource()==b[15]) {System.exit(0) ;}

if(e.getSource()==b[14]) l.setText("你按下的是"+"/") ;

if(e.getSource()==b[13]) l.setText("你按下的是"+"*") ;

if(e.getSource()==b[12]) l.setText("你按下的是"+"-") ;

if(e.getSource()==b[11]) l.setText("你按下的是"+"+") ;

if(e.getSource()==b[10]) l.setText("你按下的是"+"9") ;

if(e.getSource()==b[9]) l.setText("你按下的是"+"8") ;

if(e.getSource()==b[8]) l.setText("你按下的是"+"7") ;

if(e.getSource()==b[7]) l.setText("你按下的是"+"6") ;

if(e.getSource()==b[6]) l.setText("你按下的是"+"5") ;

if(e.getSource()==b[5]) l.setText("你按下的是"+"4") ;

if(e.getSource()==b[4]) l.setText("你按下的是"+"3") ;

if(e.getSource()==b[3]) l.setText("你按下的是"+"2") ;

if(e.getSource()==b[2]) l.setText("你按下的是"+"1") ;

if(e.getSource()==b[1]) l.setText("你按下的是"+"0") ;

if(e.getSource()==b[0]) l.setText("你按下的是"+"=") ;

}

public void mouseClicked(MouseEvent e)

{}

public void mouseEntered(MouseEvent e)

{((JButton) e.getSource()).setBackground(Color.blue) ; }

public void mouseExited(MouseEvent e)

{((JButton) e.getSource()).setBackground(Color.gray) ; }

public void mousePressed(MouseEvent e)

{}

public void mouseReleased(MouseEvent e)

{}

public static void main(String args[])

{

new calculator();

}

}

JAVA的,点击按钮1,使变成它变成蓝色。再按按钮2,使按钮2变红色,同时使按钮1变成默认的颜色!

编程思路,点击按钮1时,将按钮1的backcolor设置成蓝色,以此类推

android Studio的java类变为蓝j怎么办

解决:这是因为你的studio设置了省电模式,你可以通过 FilePower Save Mode取消掉,或者通过点击右下角小人头像取消

部分java文件前标识图标显示为 j 而是 c,File size exceeds configured limit (2560000)

IDEA对能关联的文件大小做了限制,主要是为了保护内存,默认值为2500kb,对于一般的java文件也够用了,只是这里我用protocbuf生成的java文件过大,达到3M多

android studio安装目录下bin 下的idea.properties文件。

[java] view plain copy

# idea.max.intellisense.filesize=2500

idea.max.intellisense.filesize=5000

默认值为2500kb

解决方法:

这里我将其修改为5000kb,我的最大文件大小为3M多,解决问题

idea怎么把java包变成蓝色

选择Mark Directory As中的选项Sources Root,设置成功后可看到java文件夹颜色变为浅蓝色。


新闻标题:java代码变成蓝色 java代码不变色
网页路径:http://6mz.cn/article/dojhesi.html

其他资讯