1. infonode 的組成,主要是有一個 RootWindow,再加上很多的 Views,而 TabWindow, SplitWindow, FloatWindow 都是用來做為合成的視窗。
  2. RootWindow 最好藉由 DockingUtil.createRootWindow() 來取得,以確保唯一性。
  3. RootWindow 包含很多 Views,而 Views 最好放進 ViewMap 做管理。
import javax.swing.SwingUtilities; import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.JFrame; import net.infonode.docking.RootWindow; import net.infonode.docking.View; import net.infonode.docking.util.DockingUtil; import net.infonode.docking.util.ViewMap; public class test2 extends JFrame { private static final long serialVersionUID = 1L; private JPanel jContentPane = null; private ViewMap viewMap; private RootWindow rootWindow; private RootWindow getRootWindow() { if (rootWindow == null) { View[] views = new View[5]; viewMap = new ViewMap(); for (int i = 0; i < views.length; i++) { views[i] = new View("View " + i, null, new JButton("This is view " + i + "!")); viewMap.addView(i, views[i]); } rootWindow = DockingUtil.createRootWindow(viewMap, true); } return rootWindow; } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { test2 thisClass = new test2(); thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); thisClass.setVisible(true); } }); } public test2() { super(); initialize(); } private void initialize() { this.setSize(300, 200); this.setContentPane(getJContentPane()); this.setTitle("JFrame"); } private JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new JPanel(); jContentPane.setLayout(new BorderLayout()); jContentPane.add(getRootWindow(), BorderLayout.CENTER); } return jContentPane; } }

台南小新 發表在 痞客邦 PIXNET 留言(0) 人氣()