下面列出了javax.swing.JSplitPane#setDividerSize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public SqlViewer(Color color, SqlSchema info, SqlInstance inst) {
super(new GridLayout(1, 1));
this.info = info;
this.inst = inst;
this.color = color;
makeCards();
makeGraph();
makeUI();
if (inst == null) {
add(top);
} else {
JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
pane.setResizeWeight(.75);
pane.setDividerSize(2);
pane.add(top);
pane.add(bottom);
add(pane);
}
setBorder(BorderFactory.createEtchedBorder());
}
@Override
protected JComponent getCenter()
{
// Build the settings panel
JPanel emptyPanel = new JPanel();
emptyPanel.setPreferredSize(new Dimension(780, 420));
settingsTree = new TreeView<>();
settingsTree.setRoot(new TreeItem<>(null));
// Build the split pane
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, GuiUtility.wrapParentAsJFXPanel(settingsTree),
emptyPanel
);
splitPane.setOneTouchExpandable(true);
splitPane.setDividerSize(10);
return splitPane;
}
private void initializeComponent() {
setJMenuBar( createMenu() );
myVPLineChart = new DomLineChart(myEngine.getPlayers(), "VP");
myBarChart = new DomBarChart(myEngine.getPlayers());
myMoneyLineChart = new DomLineChart(myEngine.getPlayers(), "Money");
myTopSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, new JScrollPane(getControlPanel()), myVPLineChart.getChartPanel());
myBottomSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, myBarChart.getChartPanel(), myMoneyLineChart.getChartPanel());
myBigSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, myTopSplit, myBottomSplit);
myBigSplit.setResizeWeight(0.8);
myTopSplit.setResizeWeight(0.50);
myBottomSplit.setResizeWeight(0.5);
myBottomSplit.setDividerSize(5);
myBigSplit.setDividerSize(5);
myTopSplit.setDividerSize(5);
add(myBigSplit);
}
/**
* 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);
}
private void initialize() {
mgr = new ExplorerManager();
mgr.addPropertyChangeListener(this);
mgr.setRootContext(controller.getRoot());
// following line tells the top component which lookup should be associated with it
associateLookup (ExplorerUtils.createLookup (mgr, getActionMap ()));
setLayout(new java.awt.BorderLayout());
tree = new BeanTreeView();
tree.setDefaultActionAllowed(true);
tree.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(TransactionView.class).getString("ACS_MON_treeName"));
tree.getAccessibleContext().setAccessibleName(NbBundle.getBundle(TransactionView.class).getString("ACS_MON_treeDesc"));
createLogPanel();
createDataPanel();
splitPanel =
new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, logPanel, dataPanel);
splitPanel.setDividerLocation((int)(logD.getWidth()));
splitPanel.setResizeWeight(dividerRatio);
splitPanel.setDividerSize(1);
splitPanel.setOneTouchExpandable(true);
this.add(splitPanel);
setName(NbBundle.getBundle(TransactionView.class).getString("MON_Title"));
}
private SqlMapper() {
super(new BorderLayout());
JButton transButton = new JButton("Guess Mapping");
transButton.addActionListener(x -> doRun());
JPanel tp = new JPanel(new GridLayout(1, 4));
tp.add(transButton);
tp.add(new JLabel());
tp.add(new JLabel());
tp.add(new JLabel());
JSplitPane jspX = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
jspX.setBorder(BorderFactory.createEmptyBorder());
jspX.setDividerSize(2);
jspX.setResizeWeight(0.5d);
jspX.add(input1);
jspX.add(input2);
JSplitPane jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
jsp.setBorder(BorderFactory.createEmptyBorder());
jsp.setDividerSize(4);
jsp.setResizeWeight(0.7d);
jsp.add(jspX);
jsp.add(output);
JPanel ret = new JPanel(new GridLayout(1, 1));
ret.add(jsp);
add(ret, BorderLayout.CENTER);
add(tp, BorderLayout.NORTH);
setBorder(BorderFactory.createEtchedBorder());
}
private void tweakSplitPaneUI(JSplitPane splitPane) {
splitPane.setOpaque(false);
splitPane.setBorder(null);
splitPane.setDividerSize(3);
if (!(splitPane.getUI() instanceof BasicSplitPaneUI)) {
return;
}
BasicSplitPaneDivider divider = ((BasicSplitPaneUI) splitPane.getUI()).getDivider();
if (divider != null) {
divider.setBorder(null);
}
}
private void situateNotElongated() {
JPanel cp = new JPanel(new BorderLayout());
cp.add(sp);
cp.add(errorStrip, BorderLayout.LINE_END);
cp.setBorder(BorderFactory.createEtchedBorder());
JComponent newtop = cp;
if (enable_outline) {
JSplitPane xx2 = new Split(.8, JSplitPane.HORIZONTAL_SPLIT);
xx2.setDividerSize(6);
if (outline_on_left) {
xx2.setResizeWeight(.2);
xx2.add(p);
xx2.add(cp);
} else {
xx2.setResizeWeight(.8);
xx2.add(cp);
xx2.add(p);
}
xx2.setBorder(BorderFactory.createEmptyBorder());
newtop = xx2;
}
JSplitPane xx1 = new Split(.8, JSplitPane.VERTICAL_SPLIT);
xx1.setDividerSize(6);
xx1.setResizeWeight(.8);
xx1.add(newtop);
xx1.add(respAreaX);
xx1.setBorder(BorderFactory.createEmptyBorder());
respAreaX.setMinimumSize(new Dimension(0, 0));
this.removeAll();
add(xx1);
revalidate();
}
private JSplitPane getTopSplit() {
JSplitPane theSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false, getLogPanel(), getInfoPanel());
theSplit.setResizeWeight(1);
theSplit.setDividerSize(1);
// theSplit.resetToPreferredSizes();
return theSplit;
}
private void initialize() {
this.setIcon(
new ImageIcon(ZAP.class.getResource("/resource/icon/16/059.png"))); // 'script' icon
this.setDefaultAccelerator(
extension
.getView()
.getMenuShortcutKeyStroke(
KeyEvent.VK_C,
KeyEvent.ALT_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK,
false));
this.setMnemonic(Constant.messages.getChar("scripts.panel.mnemonic"));
this.setLayout(new BorderLayout());
startPollingForChanges();
runnableScriptsToThreadMap =
Collections.synchronizedMap(
new HashMap<ScriptWrapper, WeakReference<ScriptExecutorThread>>());
panelContent = new JPanel(new GridBagLayout());
this.add(panelContent, BorderLayout.CENTER);
JSplitPane splitPane = new JSplitPane();
splitPane.setDividerSize(3);
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
splitPane.setResizeWeight(0.5D);
splitPane.setTopComponent(getCommandPanel());
splitPane.setBottomComponent(getOutputPanel());
panelContent.add(this.getPanelToolbar(), LayoutHelper.getGBC(0, 0, 1, 1.0D, 0.0D));
panelContent.add(splitPane, LayoutHelper.getGBC(0, 1, 1, 1.0D, 1.0D));
}
private void initView() {
this.setLayout(new GridLayout(1, 1));
if (roomId == null) {
messagePanel.setVisible(false);
messageEditorPanel.setVisible(false);
DebugUtil.debug("roomId == null");
}
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true);
// splitPane.setBorder(new RCBorder(RCBorder.BOTTOM,
// Colors.LIGHT_GRAY));
splitPane.setBorder(null);
// splitPane.setUI(new BasicSplitPaneUI());
// BasicSplitPaneDivider divider = (BasicSplitPaneDivider)
// splitPane.getComponent(0);
// divider.setBackground(Colors.FONT_BLACK);
// divider.setBorder(null);
splitPane.setOneTouchExpandable(false);
splitPane.setDividerLocation(450);
// splitPane.setResizeWeight(0.1);
splitPane.setDividerSize(2);
splitPane.setTopComponent(messagePanel);
splitPane.setBottomComponent(messageEditorPanel);
splitPane.setPreferredSize(new Dimension(MainFrame.DEFAULT_WIDTH, MainFrame.DEFAULT_HEIGHT));
// add(splitPane, new GBC(0, 0).setFill(GBC.BOTH).setWeight(1, 4));
// add(splitPane, new GBC(0, 0).setFill(GBC.BOTH).setWeight(1, 10));
add(splitPane);
// add(messagePanel, new GBC(0, 0).setFill(GBC.BOTH).setWeight(1, 4));
// add(messageEditorPanel, new GBC(0, 1).setFill(GBC.BOTH).setWeight(1,
// 1));
}
private void tweakSplitPaneUI(JSplitPane splitPane) {
splitPane.setOpaque(false);
splitPane.setBorder(null);
splitPane.setDividerSize(3);
if (!(splitPane.getUI() instanceof BasicSplitPaneUI)) {
return;
}
BasicSplitPaneDivider divider = ((BasicSplitPaneUI) splitPane.getUI()).getDivider();
if (divider != null) {
divider.setBorder(null);
}
}
private void tweakSplitPaneUI(JSplitPane splitPane) {
splitPane.setOpaque(false);
splitPane.setBorder(null);
splitPane.setDividerSize(3);
if (!(splitPane.getUI() instanceof BasicSplitPaneUI)) {
return;
}
BasicSplitPaneDivider divider = ((BasicSplitPaneUI) splitPane.getUI()).getDivider();
if (divider != null) {
divider.setBorder(null);
}
}
private JSplitPane createUnderPane(JTree tree) {
JTextArea toStringArea = new JTextArea();
toStringArea.setLineWrap(true);
toStringArea.setEditable(false);
tree.addTreeSelectionListener(new ToStringListener(toStringArea));
JSplitPane result = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
new JScrollPane(tree),
new JScrollPane(toStringArea));
result.setOneTouchExpandable(true);
result.setDividerSize(8);
result.setDividerLocation(0.8);
return result;
}
private JSplitPane addSpectraMS2() {
JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
SpectraVisualizerWindow spectraWindowMS2 = new SpectraVisualizerWindow(rawFiles[0]);
spectraWindowMS2.loadRawData(rawFiles[0].getScan(feature.getMostIntenseFragmentScanNumber()));
pane.add(spectraWindowMS2.getSpectrumPlot());
pane.add(spectraWindowMS2.getToolBar());
pane.setResizeWeight(1);
pane.setEnabled(false);
pane.setDividerSize(0);
return pane;
}
public ChatPanel(final Chat chat, final ChatSoundProfile chatSoundProfile) {
setSize(300, 200);
chatPlayerPanel = new ChatPlayerPanel(chat);
chatMessagePanel = new ChatMessagePanel(chat, chatSoundProfile);
setLayout(new BorderLayout());
final JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
split.setLeftComponent(chatMessagePanel);
split.setRightComponent(chatPlayerPanel);
split.setOneTouchExpandable(false);
split.setDividerSize(DIVIDER_SIZE);
split.setResizeWeight(1);
add(split, BorderLayout.CENTER);
}
protected void buildUI() {
splitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT,
master.getJPanel(),
detail.getJPanel() );
splitPane.setDividerSize(5);
splitPane.setDividerLocation(0.5);
splitPane.setResizeWeight(1.0); // top get's more space
splitPane.setOneTouchExpandable(false);
splitPane.setContinuousLayout(true);
initUI();
mainPanel.add(splitPane);
}
public SqlChecker() {
JButton transButton = new JButton("Check");
JComboBox<Example> box = new JComboBox<>(examples);
box.setSelectedIndex(-1);
box.addActionListener((ActionEvent e) -> input.setText(((Example) box.getSelectedItem()).getText()));
transButton.addActionListener(x -> check());
JPanel p = new JPanel(new BorderLayout());
JSplitPane jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
jsp.setBorder(BorderFactory.createEmptyBorder());
jsp.setDividerSize(2);
jsp.setResizeWeight(0.5d);
jsp.add(input);
jsp.add(output);
JPanel tp = new JPanel(new GridLayout(1, 4));
tp.add(transButton);
tp.add(haltOnErrors);
tp.add(new JLabel("Load Example", SwingConstants.RIGHT));
tp.add(box);
p.add(jsp, BorderLayout.CENTER);
p.add(tp, BorderLayout.NORTH);
JSplitPane jspX = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
jspX.setBorder(BorderFactory.createEmptyBorder());
JPanel panX = new JPanel(new GridLayout(1, 1));
jspX.setDividerSize(2);
jspX.setResizeWeight(0.4d);
panX.add(jspX);
jspX.add(loader);
jspX.add(p);
p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "SQL Checker"));
JFrame f = new JFrame("SQL Checker");
f.setContentPane(panX);
f.pack();
f.setSize(new Dimension(700, 600));
f.setLocationRelativeTo(null);
f.setVisible(true);
}
/**
* Run two demo applications in separate panes.
*/
private void addApplications() {
/*
* In this demo we will create two swing panels with two
* independently running applications, each with a different font
* size.
*/
/*
* First we create a panel to put it on. We need this to pass to
* SwingBackend's constructor, so that it knows not to create a new
* frame.
*/
JPanel app1Panel = new JPanel();
/*
* Next, we create the Swing backend. The "listener" (second
* argument, set to null) is what the backend wakes up on every event
* received. Typically this is the TApplication. TApplication sets
* it in its constructor, so we can pass null here and be fine.
*/
SwingBackend app1Backend = new SwingBackend(app1Panel, null,
80, 25, 16);
// Now that we have the backend, construct the TApplication.
app1 = new DemoApplication(app1Backend);
/*
* The second panel is the same sequence, except that we also change
* the font from the default Terminus to JVM monospaced.
*/
JPanel app2Panel = new JPanel();
SwingBackend app2Backend = new SwingBackend(app2Panel, null,
80, 25, 18);
app2 = new DemoApplication(app2Backend);
Font font = new Font(Font.MONOSPACED, Font.PLAIN, 18);
app2Backend.setFont(font);
/*
* Now that the applications are ready, spin them off on their
* threads.
*/
(new Thread(app1)).start();
(new Thread(app2)).start();
/*
* The rest of this is standard Swing. Set up a frame, a split pane,
* put each of the panels on it, and make it visible.
*/
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.addWindowListener(this);
JSplitPane mainPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
app1Panel, app2Panel);
mainPane.setOneTouchExpandable(true);
mainPane.setDividerLocation(500);
mainPane.setDividerSize(6);
mainPane.setBorder(null);
frame.setContentPane(mainPane);
frame.setTitle("Two Jexer Apps In One Swing UI");
frame.setSize(1000, 640);
frame.setVisible(true);
}
private void defineLayout ()
{
/*
* +=============================================================+
* |toolKeyPanel . . . . . . . . . . . . . . . . . . . . . . . . |
* |+=================+=============================+===========+|
* || toolBar . . . . . . . . . .| progressBar . . .| Memory . .||
* |+=================+=============================+===========+|
* +=============================================================+
* | horiSplitPane . . . . . . . . . . . . . . . . . . . . . . . |
* |+=========================================+=================+|
* | . . . . . . . . . . . . . . . . . . . . .|boardsScrollPane ||
* | +========================================+ . . . . . . . . ||
* | | sheetController . . . . . . . . . . . .| . . . . . . . . ||
* | | . . . . . . . . . . . . . . . . . . . .| . . . . . . . . ||
* | | . . . . . . . . . . . . . . . . . . . .| . . . . . . . . ||
* |v| . . . . . . . . . . . . . . . . . . . .| . . . . . . . . ||
* |e| . . . . . . . . . . . . . . . . . . . .| . . . . . . . . ||
* |r| . . . . . . . . . . . . . . . . . . . .| . . . . . . . . ||
* |t| . . . . . . . . . . . . . . . . . . . .| . . . . . . . . ||
* |S| . . . . . . . . . . . . . . . . . . . .| . . . . . . . . ||
* |p| . . . . . . . . . . . . . . . . . . . .| . . . . . . . . ||
* |l| . . . . . . . . . . . . . . . . . . . .| . . . . . . . . ||
* |i| . . . . . . . . . . . . . . . . . . . .| . . . . . . . . ||
* |t| . . . . . . . . . . . . . . . . . . . .| . . . . . . . . ||
* |P+=====================+==================+ . . . . . . . . ||
* |a| logPane . . . . . . | errors . . . . . | . . . . . . . . ||
* |n| . . . . . . . . . . |. . . . . . . . . | . . . . . . . . ||
* |e| . . . . . . . . . . |. . . . . . . . . | . . . . . . . . ||
* | +=====================+==================+=================+|
* +=============================================================+
*/
// Individual panes
logPane = new LogPane();
boardsScrollPane = new BoardsScrollPane();
boardsScrollPane.setPreferredSize(new Dimension(350, 500));
// Bottom = Log & Errors
bottomPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
bottomPane.setBorder(null);
bottomPane.setDividerSize(1);
bottomPane.setResizeWeight(0.5d); // Cut in half initially
// mainPane = sheetsController / bottomPane
mainPane = new JSplitPane(
JSplitPane.VERTICAL_SPLIT,
sheetsController.getComponent(),
null);
mainPane.setBorder(null);
mainPane.setDividerSize(1);
mainPane.setResizeWeight(0.9d); // Give bulk space to upper part
// horiSplitPane = mainPane | boards
appPane = new Panel();
appPane.setNoInsets();
appPane.setBorder(null);
appPane.setLayout(new BorderLayout());
appPane.add(mainPane, BorderLayout.CENTER); // + boardsScrollPane later
appPane.setName("appPane");
// Global layout: Use a toolbar on top and a double split pane below
///toolBar.add(toolKeyPanel);
Container content = frame.getContentPane();
content.setLayout(new BorderLayout());
content.add(
ActionManager.getInstance().getToolBar(),
BorderLayout.NORTH);
content.add(appPane, BorderLayout.CENTER);
// Suppress all internal borders, recursively
///UIUtilities.suppressBorders(frame.getContentPane());
// Display the boards pane?
if (GuiActions.getInstance()
.isBoardsDisplayed()) {
appPane.add(boardsScrollPane, BorderLayout.EAST);
}
// Display the log pane?
if (GuiActions.getInstance()
.isLogDisplayed()) {
bottomPane.setLeftComponent(logPane.getComponent());
}
// Display the errors pane?
if (GuiActions.getInstance()
.isErrorsDisplayed()) {
bottomPane.setRightComponent(null);
}
// BottomPane = Log & Errors
if (needBottomPane()) {
mainPane.setBottomComponent(bottomPane);
}
}