「java按钮美化」html按钮美化代码
今天给各位分享java按钮美化的知识,其中也会对html按钮美化代码进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
怎样美化Java GUI中的按钮啊
UIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel());
用这句话就可以了!
括号内还可以用其他的!
可以用以下这个方法来查看你本机的主题
public static void getSystemLookAndView()
{
UIManager.LookAndFeelInfo []info=UIManager.getInstalledLookAndFeels() ;
for(UIManager.LookAndFeelInfo tem:info)
{
System.out.println(tem.getClassName());
}
}
怎样改变java中按钮的字体和颜色
submit= new JButton("登陆");
submit.setFont(new Font("宋体", Font.PLAIN, 16));
三个参数分别表示: 字体,样式(粗体,斜体等),字号
submit.setForeground(Color.RED);
这个表示给组件上的文字设置颜色Color.RED表示红色
当然你也可以自己给RGB的值 比如 submit.setForeground(new Color(215,215,200));
JLabel组件支持HTML标记代码
infoLab= new JLabel("htmla href='地址'用户登陆系统/a/html", JLabel.CENTER);
*注意:地址要单引号引起来。这个表示给用户登录系统几个字增加超链接
infoLab .setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
这个表示给这个文字添加鼠标样式,当鼠标移动到文字上,鼠标变成手型
java改变按钮颜色
为yellow、blue、red3个按钮添加actionlistener,当按钮点击时执行setBackground(backgroundColor),同时执行 按钮.setBackground(backgroundColor)即可,比如:
JButton btnYellow = null;
JButton btnBlue = null;
JButton btnRed = null;
btnYellow.setActionCommand("yellow");
btnBlue.setActionCommand("blue");
btnRed.setActionCommand("red");
public void actionPerformed(ActionEvent e) {
String command = event.getActionCommand();
if( "yellow".equals(command) ){
setBackground(Color.yellow);
btnYellow.setBackground(Color.yellow);
}else if( "blue".equals(command) ){
setBackground(Color.blue);
btnBlue.setBackground(Color.blue);
}else if( "red".equals(command) ){
setBackground(Color.red);
btnRed.setBackground(Color.red);
}
}
写出了部分代码
java如何改变按钮的颜色,不是背景的颜色
setForeground() 设置前景/字体颜色
setBackground() 设置背景颜色
具体实现:(假设按钮名称为:button)
设置红字:
button.setForeground(Color.red);
设置黑色背影:
button.setBackground(Color.black);
java 怎么改变button的形状
1,首先明确button是安卓的一个控件,是用java语言写的。
2,设置大小的方法:btn.setbounds(x,y,width,height);//设置大小并定位
或者btn.setsize(width,height);//设置大小btn.setlocation(x,y);//定位
3,也可以在布局文件上直接给定大小
比如:
这个button控件高度和宽带都是100px
java按钮美化的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于html按钮美化代码、java按钮美化的信息别忘了在本站进行查找喔。
发布于:2022-12-10,除非注明,否则均为
原创文章,转载请注明出处。