- Code: Select all
import java.awt.Graphics;
public class TicTacToe extends javax.swing.JFrame {
...
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
...
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 400, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 300, Short.MAX_VALUE)
);
...
สิ่งที่มันเพิ่มขึ้นมาก็คือ ตัวจัดการ Layout component (org.jdesktop.layout.GroupLayout) แบบเป็นกลุ่มซึ่งโค้ดตรงนี้มันยังไม่ได้รวมเข้าไปใน Library มาตรฐานดังนั้นถ้าจะ compile ผ่านทาง command prompt จะขึ้น error ทันทีเพราะมันจะหา library ดังกล่าวไม่เจอ ต้องคอมไพล์ผ่าน netbeans เอา หรือไม่ก็ไปก๊อบ class ที่ว่าออกมาจาก netbeans มาใส่ใน directory เดียวกัน
สำหรับคนที่ใช้ Eclipse คงไม่เจอปัญหานี้แต่ก็คงปวดหัวกับ Visual Editor พอสมควรที่มันกินทรัพยากรได้มหาศาลดีจิงๆ
ว่าแล้วเดี๊ยวไปลอง intelliJ ดีกว่าว่ามันจะดีขนาดไหน แต่ตอนนี้ป๋มก็ใช้ Eclipse อยู่นะคร๊าบ
ปล. สำหรับใครที่ต้องการดูรายละเอียด GroupLayoutManager ดูได้ที่เว็บ http://www.jdesktop.org