All pastes #955410 Raw Edit

kestaz

public java v1 · immutable
#955410 ·published 2008-03-24 16:32 UTC
rendered paste body
/*       CUT HERE < ernimril> kestaz: that code does not compile FIXED< ernimril> kestaz: 1) why so many blank lines? FIXED< ernimril> kestaz: 2) why do you leave auto generated comments? "To change this template, choose Tools | Template Manager..." FIXED< ernimril> kestaz: 3) test cases should not use packages. FIXED< ernimril> kestaz: 4) why did you not remove all commented code? FIXED< ernimril> kestaz: 4) you need to learn swing thread handling, your program can crash or hang or otherwise behave badly WORKING_ON_IT<ernimril> kestaz: 5) why do you extend JFrame? you do not add anything to it, you could just _use_ a JFrame instead FIXED< ernimril> kestaz: can you explain why I would waste more time on you? You_know_answear ;)       CUT HERE*/import java.awt.* ; import java.util.Vector;import javax.swing.* ;public class Main {    public static void main(String[] args) {                App window = new App() ;             }}class App  {       protected JTable table ;     protected JButton addButton ;     protected JButton deleteButton ;        App()    {        JFrame window = new JFrame() ;         Container content = window.getContentPane() ;         window.setSize(400, 200) ;         window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        content.setLayout(new BorderLayout());                 table = new JTable() ;           JPanel rightPanel = new JPanel() ;         JScrollPane scrollPane = new JScrollPane(table) ;         table.setFillsViewportHeight(true);           content.add(scrollPane, BorderLayout.CENTER) ;        addButton = new JButton("Add CD") ;         deleteButton = new JButton("Delete CD") ;         rightPanel.setLayout(new GridBagLayout())  ;        GridBagConstraints c = new GridBagConstraints() ;        c.fill = GridBagConstraints.VERTICAL ;         c.gridx = 0 ;        c.gridy = 0 ;           rightPanel.add(addButton, c) ;         c.gridy = 1 ;        rightPanel.add(deleteButton,c) ;          content.add(rightPanel, BorderLayout.LINE_END) ;                window.pack() ;         window.setVisible(true) ;     }   }