下面列出了javax.swing.JSplitPane#setName ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Create an instance of SampleVerifier.
*/
private SampleVerifier ()
{
// Pane split vertically: selectors then browser
JSplitPane vertSplitPane = new JSplitPane(
JSplitPane.VERTICAL_SPLIT,
getSelectorsPanel(),
glyphBrowser.getComponent());
vertSplitPane.setName("SampleVerifierSplitPane");
vertSplitPane.setDividerSize(1);
// Hosting frame
frame = new JFrame();
frame.setName("SampleVerifierFrame");
frame.add(vertSplitPane);
// Resource injection
ResourceMap resource = MainGui.getInstance().getContext().
getResourceMap(
getClass());
resource.injectComponents(frame);
}
/**
* Define the layout of components within the provided frame.
*
* @param frame the bare frame
* @return the populated frame
*/
private JFrame defineLayout (JFrame frame)
{
frame.setName("SampleBrowserFrame"); // For SAF life cycle
// |- left --||-- center ---|--------------- right ---------------|
//
// +=========++=============+=====================================+
// | . . . . || . . . . . . | . . . . . . . . . . . . . . . . . . |
// | . . . . || . sheet . . | . . . . . . . . shape 1 pane. . . . |
// | . . . . || . . . . . . | . . sample. . . . . . . . . . . . . |
// | . . . . || . selector. | . . . . . . . . shape 2 pane. . . . |
// | . . . . || . . . . . . | . . listing . . . . . . . . . . . . |
// | . . . . ||=============| . . . . . . . . shape 3 pane. . . . |
// | . . . . || . . . . . . | . . . . . . . . . . . . . . . . . . |
// | . . . . || . sample. . |=====================================|
// | . . . . || . . . . . . | . . . . . . . . . . . . . . . . . . |
// | . . . . || . board . . | . . . . . . . . . . . . . . . . . . |
// | . . . . || . . . . . . | . . . . . . . . . . . . . . . . . . |
// | shape . ||-------------| . . . . . . . . . . . . . . . . . . |
// | . . . . || . . . . . . | . . . . . . . . . . . . . . . . . . |
// | selector|| . . . . . . | . . . . . . . . . . . . . . . . . . |
// | . . . . || . . . . . . | . . . . . . . . . . . . . . . . . . |
// | . . . . || . . . . . . | . . . . . . . . . . . . . . . . . . |
// | . . . . || . eval. . . | . . . . sample. . . . . . . . . . . |
// | . . . . || . . . . . . | . . . . . . . . . . . . . . . . . . |
// | . . . . || . board . . | . . . . context . . . . . . . . . . |
// | . . . . || . . . . . . | . . . . . . . . . . . . . . . . . . |
// | . . . . || . . . . . . | . . . . . . . . . . . . . . . . . . |
// | . . . . || . . . . . . | . . . . . . . . . . . . . . . . . . |
// | . . . . || . . . . . . | . . . . . . . . . . . . . . . . . . |
// | . . . . || . . . . . . | . . . . . . . . . . . . . . . . . . |
// +=========++=============+=====================================+
//
// Left = shapeSelector
shapeSelector.setName("shapeSelector");
// Center
BoardsPane boardsPane = new BoardsPane();
boardsPane.addBoard(new SampleBoard(sampleController));
boardsPane.addBoard(
new SampleEvaluationBoard(sampleController, BasicClassifier.getInstance()));
// boardsPane.addBoard(
// new SampleEvaluationBoard(sampleController, DeepClassifier.getInstance()));
//
JSplitPane centerPane = new JSplitPane(
VERTICAL_SPLIT,
sheetSelector,
boardsPane.getComponent());
centerPane.setBorder(null);
centerPane.setOneTouchExpandable(true);
centerPane.setName("centerPane");
// Right
JSplitPane rightPane = new JSplitPane(
VERTICAL_SPLIT,
sampleListing,
sampleContext.getComponent());
rightPane.setBorder(null);
rightPane.setOneTouchExpandable(true);
rightPane.setName("rightPane");
// Center + Right
JSplitPane centerPlusRightPane = new JSplitPane(HORIZONTAL_SPLIT, centerPane, rightPane);
centerPlusRightPane.setBorder(null);
centerPlusRightPane.setOneTouchExpandable(true);
centerPlusRightPane.setName("centerPlusRightPane");
// Global
JSplitPane mainPane = new JSplitPane(HORIZONTAL_SPLIT, shapeSelector, centerPlusRightPane);
mainPane.setBorder(null);
mainPane.setOneTouchExpandable(true);
mainPane.setResizeWeight(0d); // Give all free space to center+right part
mainPane.setName("mainPane");
frame.add(mainPane);
// Menu bar
frame.setJMenuBar(buildMenuBar());
// Resource injection
ResourceMap resource = OmrGui.getApplication().getContext().getResourceMap(getClass());
resource.injectComponents(frame);
// Wiring
boardsPane.connect();
// Initialize sheet selector with all repository sheet names
sheetSelector.stateChanged(null);
return frame;
}
/**
* Creates a new {@code BookBrowser} object.
*
* @param book the related book
*/
public BookBrowser (Book book)
{
this.book = book;
component = new JPanel();
// Set up the tree
model = new Model(book);
///model.addTreeModelListener(new ModelListener()); // Debug
/** The tree entity */
JTree tree = new JTree(model);
// Build left-side view
JScrollPane treeView = new JScrollPane(tree);
// Build right-side view
htmlPane = new JEditorPane("text/html", "");
htmlPane.setEditable(false);
JScrollPane htmlView = new JScrollPane(htmlPane);
// Allow only single selections
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
// Display lines to explicit relationships
tree.putClientProperty("JTree.lineStyle", "Angled");
// Wire the two views together. Use a selection listener
// created with an anonymous inner-class adapter.
// Listen for when the selection changes.
tree.addTreeSelectionListener(new SelectionListener());
// To be notified of expansion / collapse actions (debug ...)
///tree.addTreeExpansionListener(new ExpansionListener());
// Build split-pane view
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treeView, htmlView);
splitPane.setName("treeHtmlSplitPane");
splitPane.setContinuousLayout(true);
splitPane.setBorder(null);
splitPane.setDividerSize(2);
// Add GUI components
component.setLayout(new BorderLayout());
component.add("Center", splitPane);
}
/**
* Creates a new ScoreTree object.
*
* @param score the related score
*/
public ScoreTree (Score score)
{
this.score = score;
component = new JPanel();
// Set up the tree
model = new Model(score);
///model.addTreeModelListener(new ModelListener()); // Debug
/** The tree entity */
JTree tree = new JTree(model);
// Build left-side view
JScrollPane treeView = new JScrollPane(tree);
// Build right-side view
htmlPane = new JEditorPane("text/html", "");
htmlPane.setEditable(false);
JScrollPane htmlView = new JScrollPane(htmlPane);
// Allow only single selections
tree.getSelectionModel().setSelectionMode(
TreeSelectionModel.SINGLE_TREE_SELECTION);
// Display lines to explicit relationships
tree.putClientProperty("JTree.lineStyle", "Angled");
// Wire the two views together. Use a selection listener
// created with an anonymous inner-class adapter.
// Listen for when the selection changes.
tree.addTreeSelectionListener(new SelectionListener());
// To be notified of expansion / collapse actions (debug ...)
///tree.addTreeExpansionListener(new ExpansionListener());
// Build split-pane view
JSplitPane splitPane = new JSplitPane(
JSplitPane.HORIZONTAL_SPLIT,
treeView,
htmlView);
splitPane.setName("treeHtmlSplitPane");
splitPane.setContinuousLayout(true);
splitPane.setBorder(null);
splitPane.setDividerSize(2);
// Add GUI components
component.setLayout(new BorderLayout());
component.add("Center", splitPane);
}