* 하나의 Frame에서 다른 Frame을 열어야 할 경우가 있는데 * 각각 Frame의 종료 이벤트가 Exit로 설정되어 있을경우 다른 창까지 모두 종료되기 때문에 * 원하는 하나의 Frame만 종료 시키기 위해서는 dispose() 메소드를 사용하여야 한다. "Show Another Frame" 버튼을 클릭하면 아래의 새 프레임이 생성된다. 위의 두 프레임이 생성되 있는 상황에서 "Dispose" 버튼을 클릭하면 해당 프레임만 사라지고 "Exit" 버튼을 클릭하면 두 프레임 모두 사라진다. public class Frame extends JFrame { public Frame() { setTitle("Difference between Exit and Dispose First Frame"); setSi..
public class CountLineOfTextFile { public static void main(String[] args) { int lineCnt = 0; JFileChooser fc = new JFileChooser(); fc.showOpenDialog(null); File file = fc.getSelectedFile(); try { BufferedReader in = new BufferedReader(new FileReader(file)); while(in.readLine() != null) lineCnt++; } catch(Exception ex) {ex.printStackTrace();} System.out.println(lineCnt); } }
public class Frame extends JFrame { public Frame() { setTitle("Control wheel speed of JScrollPane"); setSize(500, 500); getContentPane().setLayout(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JScrollPane jsp = new JScrollPane(); jsp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jsp.getVerticalScrollBar().setUnitIncrement(16);//스크롤 속도 jsp.setBorder(null);..