使标签栏中字体成为凹凸状,如何处理? JLabel txt = new JLabel("sahaja");txt.setEnabled(false);这样字体颜色就没法显示了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 忘记说了,先要设置 Windows LookAndFeel下面这段你编译试试================= demo.java ======================================import java.awt.*;import javax.swing.*;public class demo extends JFrame { public demo() { JLabel txt = new JLabel("不是有的嘛!"); txt.setFont(new Font("宋体", 0, 15)); txt.setEnabled(false); getContentPane().add(txt); setSize(100, 100); setLocation(200, 200); show(); } public static void main(String args[]) { try { UIManager.setLookAndFeel( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception e) {} new demo(); }} 以下代码为label上的字符增加一个阴影,凹凸显示的方法类似,修改paintComponent方法。import javax.swing.*;import java.awt.*;public class TestLabel extends JFrame{ /** Creates a new instance of TestLabel */ public TestLabel() { setDefaultCloseOperation(EXIT_ON_CLOSE); test1(); } private void test1() { getContentPane().add(new MyLabel("This is"), "Center"); } class MyLabel extends JLabel { boolean backFlag = false; public MyLabel(String str) { super(str); } public void paintComponent(Graphics g) { g.translate(-1, -1); backFlag = true; super.paintComponent(g); g.translate(1, 1); super.paintComponent(g); } public Color getForeground() { if (backFlag) { return Color.BLACK; } return super.getForeground(); } } /** * @param args the command line arguments */ public static void main(String[] args) { JFrame f = new TestLabel(); f.setSize(100, 100); f.show(); } } 3xp(kk),JDK自带的例子中有关于浮雕文字处理的源代码,不凡去看看。这个例子在jfc/java2d工程下,文件名为Stars3D.java。 关于抽象类和接口的一小问题,在线等 表单自提交得不到text中的值。 自己做的一个图片工具类,运行时正常,但关闭窗口的时候出异常 新手问题! 消息传递问题 杭州文三西路去滨江UT的班车 在画布上写一个字母,但要将这字母右转90度,能坐到吗?! 求JAVA API中文版 文档 打印今天的日期,我用Calendar c=Calendar.getInstance();直接打印,和用c.set(2002,10,11)得到不同的结果,请问是什么意思?? java新手 scjp求助,这道题应该选什么 [[急问]]jtextpane 如何进行图文混编?(在线等!!!!!!!!!!!!!!!)
下面这段你编译试试================= demo.java ======================================
import java.awt.*;
import javax.swing.*;public class demo extends JFrame {
public demo() {
JLabel txt = new JLabel("不是有的嘛!");
txt.setFont(new Font("宋体", 0, 15));
txt.setEnabled(false);
getContentPane().add(txt);
setSize(100, 100);
setLocation(200, 200);
show();
}
public static void main(String args[]) {
try {
UIManager.setLookAndFeel(
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) {}
new demo();
}
}
import javax.swing.*;
import java.awt.*;public class TestLabel extends JFrame{
/** Creates a new instance of TestLabel */
public TestLabel() {
setDefaultCloseOperation(EXIT_ON_CLOSE);
test1();
}
private void test1()
{
getContentPane().add(new MyLabel("This is"), "Center");
}
class MyLabel extends JLabel
{
boolean backFlag = false;
public MyLabel(String str)
{
super(str);
}
public void paintComponent(Graphics g)
{
g.translate(-1, -1);
backFlag = true;
super.paintComponent(g);
g.translate(1, 1);
super.paintComponent(g);
}
public Color getForeground()
{
if (backFlag)
{
return Color.BLACK;
}
return super.getForeground();
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
JFrame f = new TestLabel();
f.setSize(100, 100);
f.show();
}
}