java中文本区可以设置透明的吗
展开全部
JScrollPane 需要透明的话,还要这样:
scrollPane.setOpaque(false);
scrollPane.getViewport().setOpaque(false);
以下为示例:
/** * Created with IntelliJ IDEA. * User: Administrator * Date: 12-7-1 * Time: 上午8:39 * To change this template use File | Settings | File Templates. */import javax.swing.*;import javax.swing.event.AncestorEvent;import javax.swing.event.AncestorListener;import java.awt.*;import java.awt.event.*;import com.sun.awt.AWTUtilities;public class a extends JPanel{ public static void main(String[] args) { JButton t1; String[] data = {"我是列表框one", "我是列表框two", "我是列表框three", "我是列表框four"}; JList dataList = new JList(data); JTextArea jt=new JTextArea(); JFrame f1=new JFrame(); JMenuBar mb =new JMenuBar(); mb.add(t1=new JButton("退出"),BorderLayout.EAST); dataList.setBounds(10, 10, 100, 20); jt.setText("其实我是文本框"); jt.setBackground(Color.red); t1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); f1.setJMenuBar(mb); f1.add(jt,BorderLayout.NORTH); f1.add(dataList, BorderLayout.SOUTH); f1.setSize(300, 300); f1.setUndecorated(true); AWTUtilities.setWindowOpacity(f1, 0.6F); f1.setLocationRelativeTo(null); f1.setVisible(true); }}
scrollPane.setOpaque(false);
scrollPane.getViewport().setOpaque(false);
以下为示例:
/** * Created with IntelliJ IDEA. * User: Administrator * Date: 12-7-1 * Time: 上午8:39 * To change this template use File | Settings | File Templates. */import javax.swing.*;import javax.swing.event.AncestorEvent;import javax.swing.event.AncestorListener;import java.awt.*;import java.awt.event.*;import com.sun.awt.AWTUtilities;public class a extends JPanel{ public static void main(String[] args) { JButton t1; String[] data = {"我是列表框one", "我是列表框two", "我是列表框three", "我是列表框four"}; JList dataList = new JList(data); JTextArea jt=new JTextArea(); JFrame f1=new JFrame(); JMenuBar mb =new JMenuBar(); mb.add(t1=new JButton("退出"),BorderLayout.EAST); dataList.setBounds(10, 10, 100, 20); jt.setText("其实我是文本框"); jt.setBackground(Color.red); t1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); f1.setJMenuBar(mb); f1.add(jt,BorderLayout.NORTH); f1.add(dataList, BorderLayout.SOUTH); f1.setSize(300, 300); f1.setUndecorated(true); AWTUtilities.setWindowOpacity(f1, 0.6F); f1.setLocationRelativeTo(null); f1.setVisible(true); }}
2015-12-25
展开全部
用css样式可以设置透明效果
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询