Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BorderLayout;
- import java.awt.EventQueue;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.border.EmptyBorder;
- import javax.swing.JLabel;
- import java.awt.Font;
- import java.awt.SystemColor;
- import java.util.Vector;
- import javax.swing.JTable;
- import javax.swing.border.LineBorder;
- import java.awt.Color;
- import javax.swing.ListSelectionModel;
- import javax.swing.SwingConstants;
- import java.awt.Dimension;
- import javax.swing.JScrollPane;
- @SuppressWarnings("serial")
- public class RevisonList3 extends JFrame {
- protected static final int PREF_W = 1400;
- protected static final int PREF_H = 500;
- private JPanel contentPane;
- private JScrollPane scrollPane;
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- RevisonList3 frame = new RevisonList3();
- frame.pack();
- frame.setLocationRelativeTo(null);
- frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- public RevisonList3() {
- setTitle("SVN Connector");
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- contentPane = new JPanel(){
- @Override
- public Dimension getPreferredSize() {
- if (isPreferredSizeSet()) {
- return super.getPreferredSize();
- }
- return new Dimension(PREF_W, PREF_H);
- }
- };
- contentPane.setBackground(Color.LIGHT_GRAY);
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(new BorderLayout());
- JLabel label = new JLabel(" SVN Connect", SwingConstants.CENTER);
- label.setForeground(SystemColor.controlHighlight);
- label.setFont(new Font("Lucida Grande", Font.BOLD, 14));
- contentPane.add(label, BorderLayout.PAGE_START);
- scrollPane = new JScrollPane();
- scrollPane.setViewportBorder(new LineBorder(new Color(0, 0, 0)));
- contentPane.add(scrollPane, BorderLayout.CENTER);
- String[] columnNames = { "FileName", "Revision", "Author", "Date Modified", "URL" };
- Vector<Vector<Integer>> data = new Vector<>();
- for (int i = 0; i < 130; i++) {
- Vector<Integer> row = new Vector<>();
- row.addElement(i);
- for (int j = 0; j < columnNames.length - 1; j++) {
- row.addElement((int) (100 * Math.random()));
- }
- data.add(row);
- }
- Vector<String> colNamesVector = new Vector<>();
- for (String object : columnNames) {
- colNamesVector.add(object);
- }
- JTable table = new JTable(data, colNamesVector);
- table.setBackground(Color.LIGHT_GRAY);
- table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- table.setBorder(new LineBorder(Color.BLACK));
- table.getColumnModel().getColumn(0).setMaxWidth(150);
- table.getColumnModel().getColumn(1).setMaxWidth(55);
- table.getColumnModel().getColumn(2).setMaxWidth(77);
- table.getColumnModel().getColumn(3).setMaxWidth(220);
- table.getColumnModel().getColumn(0).setMinWidth(150);
- table.getColumnModel().getColumn(1).setMinWidth(55);
- table.getColumnModel().getColumn(2).setMinWidth(77);
- table.getColumnModel().getColumn(3).setMinWidth(220);
- table.getColumnModel().getColumn(4).setMinWidth(850);
- scrollPane.setViewportView(table);
- }
- }
Add Comment
Please, Sign In to add comment