下面列出了javax.swing.JSplitPane#setResizeWeight ( ) 实例代码,或者点击链接到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());
}
public RegexDialog(RegexModel regexModel) {
setTitle(DIALOG_TITLE);
this.regexPanel = new RegexPanel(regexModel, () -> somethingChanged());
this.testValuePanel = new TestValuePanel(regexModel, () -> somethingChanged());
this.matchPanel = new MatchPanel(regexModel);
setPreferredSize(new Dimension(1024, 768));
JSplitPane centerSplit =
new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, testValuePanel, matchPanel);
centerSplit.setResizeWeight(0.5);
centerSplit.setBorder(BorderFactory.createEmptyBorder());
getContentPane().add(regexPanel, BorderLayout.NORTH);
getContentPane().add(centerSplit, BorderLayout.CENTER);
}
private void initComponents() {
JSplitPane querySplitter = new JExtendedSplitPane(JSplitPane.HORIZONTAL_SPLIT,
oqlController.getQueryController().getPanel(),
oqlController.getSavedController().getPanel());
tweakSplitPaneUI(querySplitter);
querySplitter.setResizeWeight(1d);
JSplitPane mainSplitter = new JExtendedSplitPane(JSplitPane.VERTICAL_SPLIT,
oqlController.getResultsController().getPanel(),
querySplitter);
tweakSplitPaneUI(mainSplitter);
mainSplitter.setResizeWeight(1d);
setLayout(new BorderLayout());
add(mainSplitter, BorderLayout.CENTER);
}
private JSplitPane createSplitPane(int orientation) {
final JTabbedPane tabbedPaneRequest = new JTabbedPane();
tabbedPaneRequest.addTab(REQUEST_CAPTION, null, requestPanel, null);
final JTabbedPane tabbedPaneResponse = new JTabbedPane();
tabbedPaneResponse.addTab(RESPONSE_CAPTION, null, responsePanel, null);
final JSplitPane splitPane =
new JSplitPane(orientation, tabbedPaneRequest, tabbedPaneResponse);
splitPane.setDividerSize(3);
splitPane.setResizeWeight(0.5d);
splitPane.setContinuousLayout(false);
splitPane.setDoubleBuffered(true);
int dividerLocation;
if (orientation == JSplitPane.HORIZONTAL_SPLIT) {
dividerLocation = horizontalDividerLocation;
} else {
dividerLocation = verticalDividerLocation;
}
splitPane.setDividerLocation(dividerLocation);
return splitPane;
}
/**
* Creates a new {@code CSSStylesSelectionPanel}.
*/
CSSStylesSelectionPanel() {
setLayout(new BorderLayout());
JSplitPane splitPane = createSplitPane();
splitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
splitPane.setTopComponent(initPropertyPane());
splitPane.setBottomComponent(initRulePane());
splitPane.setDividerSize(4);
splitPane.setResizeWeight(0.5);
splitPane.setBorder(null);
selectionView = splitPane;
initMessagePanel();
initSelectionOfOwningRule();
add(selectionView, BorderLayout.CENTER);
updateContent(null, false);
}
public MatchPanel(RegexModel regexModel) {
super(new BorderLayout());
this.regexModel = regexModel;
resultField = createTextArea();
captureField = createTextArea();
matchField = new JLabel();
matchField.setText(String.format(MATCHES_LABEL, ""));
lookingAtField = new JLabel();
lookingAtField.setText(String.format(LOOKING_AT_LABEL, ""));
JPanel matchPanel = createPanel(MATCH_RESULT_HEADER);
matchPanel.add(matchField, BorderLayout.NORTH);
matchPanel.add(lookingAtField, BorderLayout.SOUTH);
matchPanel.setPreferredSize(new Dimension(0, 80));
JPanel findPanel = createPanel(resultField, FIND_RESULT_HEADER);
JPanel capturePanel = createPanel(captureField, FIND_CAPTURE_HEADER);
JSplitPane findSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, findPanel, capturePanel);
findSplit.setResizeWeight(0.35);
findSplit.setBorder(BorderFactory.createEmptyBorder());
add(matchPanel, BorderLayout.NORTH);
add(findSplit, BorderLayout.CENTER);
}
private JSplitPane addSpectraMS1() {
JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
SpectraVisualizerWindow spectraWindowMS1 = new SpectraVisualizerWindow(rawFiles[0]);
spectraWindowMS1.loadRawData(rawFiles[0].getScan(feature.getRepresentativeScanNumber()));
pane.add(spectraWindowMS1.getSpectrumPlot());
pane.add(spectraWindowMS1.getToolBar());
pane.setResizeWeight(1);
pane.setEnabled(false);
pane.setDividerSize(0);
return pane;
}
private Container getMainContentContainer() {
// card pool
cardPoolDefs = filterPanel.getFilteredCards();
cardPoolTable = new CardTablePanelB(cardPoolDefs, generatePoolTitle(), false);
cardPoolTable.addMouseListener(new CardPoolMouseListener());
cardPoolTable.addCardSelectionListener(this);
cardPoolTable.setDeckEditorSelectionMode();
deckDefs = this.deck;
deckTable = new CardTablePanelB(deckDefs, generateDeckTitle(deckDefs), true);
deckTable.addMouseListener(new DeckMouseListener());
deckTable.addCardSelectionListener(this);
deckTable.setDeckEditorSelectionMode();
deckTable.showCardCount(true);
final JPanel deckPanel = new JPanel();
deckPanel.setOpaque(false);
deckPanel.setLayout(new MigLayout("insets 0, gap 0, flowy"));
deckPanel.add(buttonsPanel, "w 100%, h 40!");
deckPanel.add(deckTable, "w 100%, h 100%");
cardsSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
cardsSplitPane.setOneTouchExpandable(false);
cardsSplitPane.setLeftComponent(cardPoolTable);
cardsSplitPane.setRightComponent(deckPanel);
cardsSplitPane.setResizeWeight(0.5);
cardsSplitPane.setDividerSize(14);
cardsSplitPane.setBorder(null);
cardsSplitPane.setOpaque(false);
cardsSplitPane.setDividerLocation(getDividerPosition());
// update deck stats
sideBarPanel.setDeck(this.deck);
return cardsSplitPane;
}
private void init() {
setLayout(new BorderLayout());
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitPane.setOneTouchExpandable(true);
splitPane.setBottomComponent(objectTable);
TreeSearch tSearch = TreeSearch.installForOR(objectTree.getTree());
splitPane.setTopComponent(tSearch);
splitPane.setResizeWeight(.5);
splitPane.setDividerLocation(.5);
add(splitPane);
}
private static JPanel createSplitPanel(
JPanel leftPanel,
JPanel rightPanel,
final SyncScrollBarsAdjustmentListener syncScrollPanes) {
JPanel panel = new JPanel();
GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
layout.setAutoCreateGaps(true);
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel);
splitPane.setDividerLocation(0.5D);
splitPane.setResizeWeight(0.5D);
JCheckBox syncScrollBarsCheckbox = new JCheckBox(LOCK_SCROLL_BARS_BUTTON_LABEL);
syncScrollBarsCheckbox.setSelected(true);
syncScrollBarsCheckbox.addItemListener(
new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
syncScrollPanes.setSync(e.getStateChange() == ItemEvent.SELECTED);
}
});
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(splitPane)
.addComponent(syncScrollBarsCheckbox));
layout.setVerticalGroup(
layout.createSequentialGroup()
.addComponent(splitPane)
.addComponent(syncScrollBarsCheckbox));
return panel;
}
private JSplitPane createSplitPane(Component lower) {
JSplitPane pane = new JSplitPane();
if (firstSplit == null) {
firstSplit = Boolean.TRUE;
} else {
firstSplit = Boolean.FALSE;
}
pane.setRightComponent(lower);
pane.setOrientation(JSplitPane.VERTICAL_SPLIT);
pane.setContinuousLayout(true);
pane.setResizeWeight(1);
pane.setDividerLocation(0.80f);
pane.setBorder(BorderFactory.createEmptyBorder());
//Do not install our custom split pane UI on Nimbus L&F
if (!"Nimbus".equals(UIManager.getLookAndFeel().getID())) {
pane.setUI(PropUtils.createSplitPaneUI());
}
// #52188: default F6 behaviour doesn't make to much sense in NB
// property sheet and blocks NetBeans default F6
pane.getActionMap().getParent().remove("toggleFocus");
if( PropUtils.isAqua ) {
pane.setBackground( UIManager.getColor("NbExplorerView.background") ); //NOI18N
}
return pane;
}
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;
}
/**
* Creates a new debug event list panel where debug events are displayed.
*
* @param eventListManager Provides the event lists that are displayed in this panel.
*/
public CDebugEventListPanel(final ITraceListProvider eventListManager) {
super(new BorderLayout());
Preconditions.checkNotNull(
eventListManager, "IE01369: Event list manager argument can't be null");
// Create the table that shows the recorded event lists.
m_tracesTable = new CEventListTable(eventListManager);
// Add a selection listener that updates the right table
// if the selection in the left table changes.
m_tracesTable.getSelectionModel().addListSelectionListener(new InternalSelectionListener());
final JPanel rightPanel = new JPanel(new BorderLayout());
m_traceEventTable = new CEventTable(new CEventTableModel());
m_traceEventTable.getSelectionModel()
.addListSelectionListener(new InternalEventSelectionListener());
final CTablePanel<ITraceEvent> filteredPanel = new CTraceEventsPanel(m_traceEventTable);
m_eventValueTable = new CEventValueTable(m_eventModel);
m_eventValueTable.addMouseListener(new InternalMouseListener());
final JSplitPane splitPane1 = new JSplitPane(
JSplitPane.HORIZONTAL_SPLIT, true, filteredPanel, new JScrollPane(m_eventValueTable));
rightPanel.add(splitPane1, BorderLayout.CENTER);
splitPane1.setResizeWeight(0.5);
m_tracesPanel = new CTracesPanel(m_tracesTable);
final JSplitPane splitPane =
new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, m_tracesPanel, rightPanel);
add(splitPane, BorderLayout.CENTER);
splitPane.setResizeWeight(0.5);
}
private void init() {
setLayout(new BorderLayout());
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitPane.setOneTouchExpandable(true);
splitPane.setBottomComponent(objectTable);
TreeSearch tSearch = TreeSearch.installForOR(objectTree.getTree());
splitPane.setTopComponent(tSearch);
splitPane.setResizeWeight(.5);
splitPane.setDividerLocation(.5);
add(splitPane);
}
/**
* Initialize the internal components.
*/
private void initComponents() {
undoManager = new UndoManager();
warning = new ImageIcon(CampaignEditor.class.getResource("/hu/openig/gfx/warning.png"));
error = new ImageIcon(CampaignEditor.class.getResource("/hu/openig/gfx/error.png"));
labels = new HashMap<>();
flags = new HashMap<>();
// fetch labels
try {
XElement xlabels = XElement.parseXML(CampaignEditor.class.getResource("ce_labels.xml"));
for (XElement xlang : xlabels.childrenWithName("language")) {
String id = xlang.get("id");
if (id.equals(language)) {
for (XElement xentry : xlang.childrenWithName("entry")) {
String key = xentry.get("key");
if (key != null && !key.isEmpty() && xentry.content != null && !xentry.content.isEmpty()) {
labels.put(key, xentry.content);
}
}
}
flags.put(id, new ImageIcon(CampaignEditor.class.getResource(xlang.get("flag"))));
}
} catch (XMLStreamException | IOException ex) {
Exceptions.add(ex);
}
ToolTipManager.sharedInstance().setDismissDelay(120000);
mainMenu = new JMenuBar();
initMenu();
toolbar = new JToolBar();
initToolbar();
mainSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
tabs = new JTabbedPane();
initTabs();
problemPanel = new JPanel();
mainSplit.setTopComponent(tabs);
mainSplit.setBottomComponent(problemPanel);
mainSplit.setOneTouchExpandable(true);
mainSplit.setResizeWeight(1d);
setJMenuBar(mainMenu);
Container c = getContentPane();
c.add(toolbar, BorderLayout.PAGE_START);
c.add(mainSplit, BorderLayout.CENTER);
// TODO other stuff
updateUndoRedo();
startupDialog = new CEStartupDialog(this);
// FIXME disabled menu and toolbars
mnuFileOpen.setEnabled(false);
mnuFileSave.setEnabled(false);
mnuFileSaveAs.setEnabled(false);
mnuFileImport.setEnabled(false);
mnuFileExport.setEnabled(false);
mnuEditCopy.setEnabled(false);
mnuEditCut.setEnabled(false);
mnuEditPaste.setEnabled(false);
mnuEditDelete.setEnabled(false);
mnuHelpAbout.setEnabled(false);
toolbarOpen.setEnabled(false);
toolbarSave.setEnabled(false);
toolbarImport.setEnabled(false);
toolbarExport.setEnabled(false);
toolbarCut.setEnabled(false);
toolbarCopy.setEnabled(false);
toolbarPaste.setEnabled(false);
toolbarRemove.setEnabled(false);
toolbarSaveAs.setEnabled(false);
}
public MainWindow() {
super("Dummy Droid");
setDefaultCloseOperation(EXIT_ON_CLOSE);
JMenuBar mbar = new JMenuBar();
JMenu fileMenu = new JMenu(new FileMenuAction());
fileMenu.add(new JMenuItem(new QuitAction()));
mbar.add(fileMenu);
setJMenuBar(mbar);
FormData formData = new FormData();
JEditorPane description = new HypertextPane("");
description.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
description.addHyperlinkListener(new BrowseUtil());
JPanel formContainer = new JPanel();
formContainer.setLayout(new CardLayout());
NavigateAction forward = new NavigateAction(description, formContainer, NavigateAction.FORWARD,
formData);
NavigateAction backward = new NavigateAction(description, formContainer, NavigateAction.BACK,
formData);
formContainer.add(new LoadForm(forward, backward), LoadForm.class.getName());
formContainer.add(new HardwareForm(forward, backward), HardwareForm.class.getName());
formContainer.add(new SoftwareForm(forward, backward), SoftwareForm.class.getName());
formContainer.add(new MiscForm(forward, backward), MiscForm.class.getName());
formContainer.add(new NativeForm(forward, backward), NativeForm.class.getName());
formContainer.add(new SharedlibForm(forward, backward), SharedlibForm.class.getName());
formContainer.add(new FeaturesForm(forward, backward), FeaturesForm.class.getName());
formContainer.add(new LocalesForm(forward, backward), LocalesForm.class.getName());
formContainer.add(new CredentialsForm(forward,backward),CredentialsForm.class.getName());
formContainer.add(new CheckinForm(forward, backward), CheckinForm.class.getName());
JButton next = new JButton(forward);
JButton previous = new JButton(backward);
JLabel content = new JLabel("");
JPanel buttonBar = new JPanel(new FlowLayout(FlowLayout.RIGHT));
buttonBar.add(previous);
buttonBar.add(next);
content.setLayout(new BorderLayout());
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
new JScrollPane(description), formContainer);
splitPane.setResizeWeight(1);
content.add(splitPane, BorderLayout.CENTER);
content.add(buttonBar, BorderLayout.SOUTH);
setContentPane(content);
forward.toScreen();
}
private void buildUI() {
LookAndFeelTweaks.setBorderLayout(this);
LookAndFeelTweaks.setBorder(this);
actionPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 2, 0));
actionPanel.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
add("North", actionPanel);
sortButton = new JToggleButton(new ToggleSortingAction());
sortButton.setUI(new BlueishButtonUI());
sortButton.setText(null);
actionPanel.add(sortButton);
asCategoryButton = new JToggleButton(new ToggleModeAction());
asCategoryButton.setUI(new BlueishButtonUI());
asCategoryButton.setText(null);
actionPanel.add(asCategoryButton);
descriptionButton = new JToggleButton(new ToggleDescriptionAction());
descriptionButton.setUI(new BlueishButtonUI());
descriptionButton.setText(null);
actionPanel.add(descriptionButton);
split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
split.setBorder(null);
split.setResizeWeight(1.0);
split.setContinuousLayout(true);
add("Center", split);
tableScroll = new JScrollPane();
split.setTopComponent(tableScroll);
descriptionPanel = new JEditorPane("text/html", "<html>");
descriptionPanel.setBorder(BorderFactory.createEmptyBorder());
descriptionPanel.setEditable(false);
descriptionPanel.setBackground(UIManager.getColor("Panel.background"));
LookAndFeelTweaks.htmlize(descriptionPanel);
selectionListener = new SelectionListener();
descriptionScrollPane = new JScrollPane(descriptionPanel);
descriptionScrollPane.setBorder(LookAndFeelTweaks.addMargin(BorderFactory
.createLineBorder(UIManager.getColor("controlDkShadow"))));
descriptionScrollPane.getViewport().setBackground(
descriptionPanel.getBackground());
descriptionScrollPane.setMinimumSize(new Dimension(50, 50));
split.setBottomComponent(descriptionScrollPane);
// by default description is not visible, toolbar is visible.
setDescriptionVisible(false);
setToolBarVisible(true);
}
public JComponent createVisualisation(VisualisationMethodChangedEvent e) {
JComponent componentToReturn = null;
try {
// Create new visualiser only if needed to keep the settings made in settings panel
if (this.datas != e.getDatas() || this.method != e.getNewMethod()) {
this.datas = e.getDatas();
this.method = e.getNewMethod();
removeVisualiser();
visualiser = method.getVisualiser(this);
}
this.variables = e.getVariables();
// parameter panel has to be first one to make it initialised before the
// data is set (scatterplot)
JPanel parametersPanel = visualiser.getParameterPanel();
logger.debug("parametersPanel for method " + method + " contains: " + parametersPanel);
if (parametersPanel != null) {
paramSplit = new JSplitPane();
parametersPanel.setMinimumSize(new Dimension(0, 0));
paramSplit.setRightComponent(parametersPanel);
// To show the width limit of parameter panel
paramSplit.setContinuousLayout(true);
// To keep the parameter panel size constant
paramSplit.setResizeWeight(1.0);
SplitSizeHandler sizeHandler = new SplitSizeHandler();
paramSplit.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, sizeHandler);
} else {
//Do not keep references to old visualization to avoid memory leak
if (paramSplit != null) {
paramSplit.removeAll();
}
}
JComponent visualisationComponent = null;
if (visualiser.isForMultipleDatas()) {
visualisationComponent = visualiser.getVisualisation(datas);
} else if (visualiser.isForSingleData()) {
DataBean data = datas.size() > 0 ? datas.get(0) : null;
visualisationComponent = visualiser.getVisualisation(data);
}
if (parametersPanel != null) {
paramSplit.setLeftComponent(visualisationComponent);
componentToReturn = paramSplit;
} else {
componentToReturn = visualisationComponent;
}
} catch (Exception e1) {
application.reportException(e1);
componentToReturn = visualiser.getDefaultVisualisation();
}
return componentToReturn;
}
private void buildUI() {
LookAndFeelTweaks.setBorderLayout(this);
LookAndFeelTweaks.setBorder(this);
actionPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 2, 0));
actionPanel.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
actionPanel.setOpaque(false);
add("North", actionPanel);
sortButton = new JToggleButton(new ToggleSortingAction());
sortButton.setUI(new BlueishButtonUI());
sortButton.setText(null);
sortButton.setOpaque(false);
actionPanel.add(sortButton);
asCategoryButton = new JToggleButton(new ToggleModeAction());
asCategoryButton.setUI(new BlueishButtonUI());
asCategoryButton.setText(null);
asCategoryButton.setOpaque(false);
actionPanel.add(asCategoryButton);
descriptionButton = new JToggleButton(new ToggleDescriptionAction());
descriptionButton.setUI(new BlueishButtonUI());
descriptionButton.setText(null);
descriptionButton.setOpaque(false);
actionPanel.add(descriptionButton);
split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
split.setBorder(null);
split.setResizeWeight(1.0);
split.setContinuousLayout(true);
add("Center", split);
tableScroll = new JScrollPane();
tableScroll.setBorder(BorderFactory.createEmptyBorder());
split.setTopComponent(tableScroll);
descriptionPanel = new JEditorPane("text/html", "<html>");
descriptionPanel.setBorder(BorderFactory.createEmptyBorder());
descriptionPanel.setEditable(false);
descriptionPanel.setBackground(UIManager.getColor("Panel.background"));
LookAndFeelTweaks.htmlize(descriptionPanel);
selectionListener = new SelectionListener();
descriptionScrollPane = new JScrollPane(descriptionPanel);
descriptionScrollPane.setBorder(LookAndFeelTweaks.addMargin(BorderFactory
.createLineBorder(UIManager.getColor("controlDkShadow"))));
descriptionScrollPane.getViewport().setBackground(
descriptionPanel.getBackground());
descriptionScrollPane.setMinimumSize(new Dimension(50, 50));
split.setBottomComponent(descriptionScrollPane);
// by default description is not visible, toolbar is visible.
setDescriptionVisible(false);
setToolBarVisible(true);
}
/**
* Displays the game board. This is called after an offer has been accepted
* or after accepting an invitation.
*
* @param gameID
* the game ID.
* @param room
* the chat room to display the game board in.
* @param startingPlayer
* true if this player is the starting player (black).
* @param opponentJID
* the opponent's JID.
*/
private void showReversiBoard(int gameID, ChatRoom room, boolean startingPlayer, Jid opponentJID) {
JSplitPane pane = room.getSplitPane();
pane.setResizeWeight(1.0);
BackgroundPanel reversiBackground = new BackgroundPanel();
reversiBackground.setLayout(new BorderLayout());
reversiBackground.setOpaque(false);
ReversiPanel reversi = new ReversiPanel(SparkManager.getConnection(), gameID, startingPlayer, opponentJID);
reversiBackground.add(reversi, BorderLayout.CENTER);
pane.setRightComponent(reversiBackground);
reversi.setMinimumSize(new Dimension(ReversiPanel.TOTAL_WIDTH, ReversiPanel.TOTAL_HEIGHT));
}