Created
December 31, 2013 08:12
-
-
Save resarahadian/8193950 to your computer and use it in GitHub Desktop.
Membuat Transparan TextPane
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.Color; | |
import java.awt.Graphics; | |
import javax.swing.JTextPane; | |
@SuppressWarnings("serial") | |
public class ClTransparanTextPane extends JTextPane | |
{ | |
public ClTransparanTextPane() | |
{ | |
super(); | |
this.setOpaque(false); | |
} | |
public void paintComponent(Graphics g) | |
{ | |
g.setColor(new Color(255,255,255,128)); | |
g.fillRect(0, 0, getWidth(), getHeight()); | |
super.paintComponent(g); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.EventQueue; | |
import javax.swing.JFrame; | |
import javax.swing.JPanel; | |
import javax.swing.border.EmptyBorder; | |
import javax.swing.JLabel; | |
import javax.swing.JTextPane; | |
import javax.swing.ImageIcon; | |
@SuppressWarnings("serial") | |
public class frameTransparanTextPane extends JFrame | |
{ | |
private JPanel contentPane; | |
private JLabel lblWall; | |
private JTextPane textPane; | |
private JLabel lblIcon; | |
/** | |
* Create the frame. | |
*/ | |
public frameTransparanTextPane() | |
{ | |
setTitle("Transparan TextPane"); | |
setResizable(false); | |
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
setBounds(100, 100, 691, 458); | |
contentPane = new JPanel(); | |
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); | |
setContentPane(contentPane); | |
contentPane.setLayout(null); | |
textPane = new ClTransparanTextPane(); | |
textPane.setBounds(32, 32, 466, 333); | |
contentPane.add(textPane); | |
lblIcon = new JLabel(""); | |
lblIcon.setIcon(new ImageIcon("/home/resa/Aplikasi Java/SwingJava/src/transparanTextPane/icon.png")); | |
lblIcon.setBounds(510, 110, 162, 139); | |
contentPane.add(lblIcon); | |
lblWall = new JLabel(""); | |
lblWall.setIcon(new ImageIcon("/home/resa/Aplikasi Java/SwingJava/src/transparanTextPane/wall.jpg")); | |
lblWall.setBounds(0, -12, 689, 444); | |
contentPane.add(lblWall); | |
setLocationRelativeTo(null); | |
} | |
/** | |
* Launch the application. | |
*/ | |
public static void main(String[] args) { | |
EventQueue.invokeLater(new Runnable() { | |
public void run() { | |
try { | |
frameTransparanTextPane frame = new frameTransparanTextPane(); | |
frame.setVisible(true); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment