Created
December 17, 2013 23:18
-
-
Save resarahadian/8014486 to your computer and use it in GitHub Desktop.
Membuat Background JTable Transparan
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.UIManager; | |
import javax.swing.border.EmptyBorder; | |
import javax.swing.JScrollPane; | |
import javax.swing.JTable; | |
import javax.swing.table.DefaultTableModel; | |
import javax.swing.JLabel; | |
import javax.swing.ImageIcon; | |
@SuppressWarnings("serial") | |
public class frameTransparantTable extends JFrame { | |
private JPanel contentPane; | |
private JScrollPane scrollPane; | |
private JTable tabel; | |
DefaultTableModel tabelModel; | |
String header[] = {"ID", "Nama", "Harga"}; | |
String isi[][] = {{"B001","Kecap DEF", "6000"}, {"B002","Mie Goreng", "1800"}}; | |
private JLabel lblWall; | |
/** | |
* Create the frame. | |
*/ | |
public frameTransparantTable() | |
{ | |
setTitle("Transparant Background Table"); | |
setResizable(false); | |
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
setBounds(100, 100, 674, 380); | |
contentPane = new JPanel(); | |
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); | |
setContentPane(contentPane); | |
contentPane.setLayout(null); | |
scrollPane = new JScrollPane(); | |
scrollPane.setBounds(16, 21, 447, 293); | |
contentPane.add(scrollPane); | |
tabelModel = new DefaultTableModel(isi,header); | |
tabel = new JTable(); | |
tabel.setModel(tabelModel); | |
scrollPane.setOpaque(false); | |
scrollPane.getViewport().setOpaque(false); | |
tabel.setShowGrid(false); | |
scrollPane.setViewportView(tabel); | |
JLabel lblIcon = new JLabel(""); | |
lblIcon.setIcon(new ImageIcon("/home/resa/Aplikasi Java/SwingJava/src/transparantBackgroundTable/icon1.png")); | |
lblIcon.setBounds(497, 78, 152, 129); | |
contentPane.add(lblIcon); | |
lblWall = new JLabel(""); | |
lblWall.setIcon(new ImageIcon("/home/resa/Aplikasi Java/SwingJava/src/transparantBackgroundTable/wall.png")); | |
lblWall.setBounds(0, -13, 672, 367); | |
contentPane.add(lblWall); | |
setLocationRelativeTo(null); | |
} | |
/** | |
* Launch the application. | |
*/ | |
public static void main(String[] args) { | |
EventQueue.invokeLater(new Runnable() { | |
public void run() { | |
try { | |
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); | |
frameTransparantTable frame = new frameTransparantTable(); | |
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