在Stackoverflow的这找到了答案,需要设置一下系统参数:

    static {
System.setProperty("sun.java2d.noddraw", "true");
System.setProperty("sun.java2d.d3d", "false");
}

另外还有个修改paintComponent的方式:

import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*; public class Test { public static class JTextField2 extends JTextField {
private static final long serialVersionUID = 1L;
private BufferedImage buffer = null; @Override public void paintComponent(Graphics g) {
Component window = this.getTopLevelAncestor();
if (window instanceof Window && !((Window)window).isOpaque()) {
// This is a translucent window, so we need to draw to a buffer
// first to work around a bug in the DirectDraw rendering in Swing.
int w = this.getWidth();
int h = this.getHeight();
if (buffer == null || buffer.getWidth() != w || buffer.getHeight() != h) {
// Create a new buffer based on the current size.
GraphicsConfiguration gc = this.getGraphicsConfiguration();
buffer = gc.createCompatibleImage(w, h, BufferedImage.TRANSLUCENT);
} // Use the super class's paintComponent implementation to draw to
// the buffer, then write that buffer to the original Graphics object.
Graphics bufferGraphics = buffer.createGraphics();
try {
super.paintComponent(bufferGraphics);
} finally {
bufferGraphics.dispose();
}
g.drawImage(buffer, 0, 0, w, h, 0, 0, w, h, null);
} else {
// This is not a translucent window, so we can call the super class
// implementation directly.
super.paintComponent(g);
}
}
} public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override public void run() {
final JFrame frame = new JFrame();
frame.setUndecorated(true);
frame.setBackground(new Color(96, 128, 160, 192)); JTextField textField = new JTextField2();
JButton exitButton = new JButton("Exit");
exitButton.addActionListener(new ActionListener() {
@Override public void actionPerformed(ActionEvent e) {
frame.dispose();
}
}); frame.add(exitButton, BorderLayout.PAGE_START);
frame.add(textField, BorderLayout.PAGE_END); frame.setSize(400, 400);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
}
}

原帖链接

java7中使用透明时与输入法冲突的更多相关文章

  1. 浅析Java7中的ConcurrentHashMap

    引入ConcurrentHashMap 模拟使用hashmap在多线程场景下发生线程不安全现象 import java.util.HashMap; import java.util.Map; impo ...

  2. 关于Entity Framework更新的几种方式以及可能遇到的问题(附加类型“Model”的实体失败,因为相同类型的其他实体已具有相同的主键值)在使用 "Attach" 方法或者将实体的状态设置为 "Unchanged" 或 "Modified" 时如果图形中的任何实体具有冲突键值,则可能会发生上述行为

    在日常使用Entity Framework中,数据更新通常会用到.下面就简单封装了一个DBContext类 public partial class EFContext<T> : DbCo ...

  3. C#中图片透明【转】

    C#中图片透明 /// <summary> /// 处理图片透明操作 /// </summary> /// <param name="srcImage" ...

  4. 安装完Linux Mint后,发现系统中竟没有中文输入法

    安装完Linux Mint后,发现系统中竟没有中文输入法,语言支持之后自动更新过程中有些安装包下载失败. 可以采取下面的方法安装上中文输入法. 1. 安装iBus: sudo add-apt-repo ...

  5. Zookeeper包中,slf4j-log4j12和log4j冲突问题解决

    程序启动时会有日志警告 SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/E ...

  6. 【JVM】Java8 和 Java7中JVM内存模型有什么区别

    规范和实现 针对Java虚拟机的实现有专门的<Java虚拟机规范>,在遵守规范的前提下,不同的厂商会对虚拟机进行不同的实现. 就好比开发的过程中定义了接口,具体的接口实现大家可以根据不同的 ...

  7. myeclipse和输入法冲突的问题

    问题:在myeclipse中编写注释的时候,偶尔出现繁体字的现象令人头疼. 原因:myeclipse中格式化快捷键为"ctrl+shift+f" 与搜狗输入法快捷键冲突.按下后输入 ...

  8. 解决ambiguous symbol命名空间中类名、变量名冲突的问题

    最近在将一个复杂的工程集成到现有的项目中.编译时发现,有的变量名冲突了,提示就是xxxx ambiguous symbol,并且在编译输出时,指明了两个文件当中特定的变量名或者类名相同.出现这个编译错 ...

  9. npoi与memcached中的ICSharpCode.SharpZipLib版本冲突的解决方案

    项目中一直使用NPOI与memcached,一直相安无事,但是最近升级了npoi到最新版本,发生了ICSharpCode.SharpZipLib的版本冲突问题. 因为此前一直使用的是NPOI的1.x的 ...

随机推荐

  1. mxnet.base.MXNetError: src/imperative/./imperative_utils.h:70: Check failed: inputs[i]->ctx().dev_mask() == ctx.dev_mask() (1 vs. 2)

    mxnet 训练错误: mxnet.base.MXNetError: [14:42:22] src/imperative/./imperative_utils.h:70: Check failed: ...

  2. 全国高校绿色计算大赛 预赛第一阶段(Python)

    第1关将字符串反转 #!/usr/bin/env python # -*- coding: utf-8 -*- class Task: def inversion(self, str): # **** ...

  3. 零基础入门学习Python(19)--函数:我的地盘听我的

    知识点 函数与过程 在许多编程语言中,函数(function)是有返回值的,过程(procedure)是简单.特殊并且没有返回值的.而在Python中,严格来说只有函数没有过程. 例如: >&g ...

  4. impdp导入

    //导入命令impdp 用户/密码@数据库链接 directory=数据库中映射路径 schemas=原用户 remap_schema=原用户:现用户 remap_tablespace=原表空间:现表 ...

  5. 监听服务器 重启apache

    import requests import os import time url = 'http://www.ydyigo.com/findPwd.php' def get_server_statu ...

  6. 第十七节:Scrapy爬虫框架之item.py文件以及spider中使用item

    Scrapy原理图: item位于原理图的最左边 item.py文件是报存爬取数据的容器,他使用的方法和字典很相似,但是相比字典item多了额外的保护机制,可以避免拼写错误或者定义错误. 1.创建it ...

  7. Spring核心技术(八)——Spring自动装载的注解

    本文针对自动装载的一些注解进行描述. 基于注解的容器配置 @Required注解 @Required注解需要应用到Bean的属性的setter方法上面,如下面的例子: public class Sim ...

  8. js给对象添加属性

    obj.prototype = shuxing: shuxing['属性']=值: function Person(){}; var person = new Person(); person.nam ...

  9. Thinkphp5.0 的响应方式

    Thinkphp5.0 的响应方式 $res = config('default_return_type'); dump($res);//默认是html //修改为json \think\Config ...

  10. 创建Django项目(七)——表单

    2013-08-15 19:43:01|         1.URL配置和视图 "blog\urls.py"文件中:添加url(r'write_article/$', 'write ...