下面列出了javax.swing.JSplitPane#getUI ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Constructs a new SplitPane containing the two components given as arguments
*
* @param orientation - the orientation (HORIZONTAL_SPLIT or VERTICAL_SPLIT)
* @param first - the left component (if horizontal) or top component (if
* vertical)
* @param second - the right component (if horizontal) or bottom component (if
* vertical)
* @param initialDividerLocation - the initial divider location (in pixels)
*/
public static JSplitPane splitpane(int orientation, Component first, Component second, int initialDividerLocation) {
JSplitPane x = make(new JSplitPane(orientation, first, second), new EmptyBorder(0, 0, 0, 0));
x.setContinuousLayout(true);
x.setDividerLocation(initialDividerLocation);
x.setOneTouchExpandable(false);
x.setResizeWeight(0.5);
if (Util.onMac() && (x.getUI() instanceof BasicSplitPaneUI)) {
boolean h = (orientation != JSplitPane.HORIZONTAL_SPLIT);
((BasicSplitPaneUI) (x.getUI())).getDivider().setBorder(new OurBorder(h, h, h, h)); // Makes
// the
// border
// look
// nicer
// on
// Mac
// OS
// X
}
return x;
}
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 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 static 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);
}
}
protected BasicSplitPaneDivider createInstanceImpl() {
final JSplitPane split = new JSplitPane(orientation);
BasicSplitPaneUI ui = split.getUI() instanceof BasicSplitPaneUI ?
(BasicSplitPaneUI)split.getUI() : new BasicSplitPaneUI() {
{ installUI(split); }
};
return new BasicSplitPaneDivider(ui);
}
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 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 static 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);
}
}
protected BasicSplitPaneDivider createInstanceImpl() {
final JSplitPane split = new JSplitPane(orientation);
BasicSplitPaneUI ui = split.getUI() instanceof BasicSplitPaneUI ?
(BasicSplitPaneUI)split.getUI() : new BasicSplitPaneUI() {
{ installUI(split); }
};
return new BasicSplitPaneDivider(ui);
}
private JSplitPane splitPane(
int orientation,
boolean redraw,
JComponent c1,
JComponent c2
) {
JSplitPane sp = new JSplitPane(orientation, redraw, c1, c2);
sp.setBorder(null);
javax.swing.plaf.SplitPaneUI ui = sp.getUI();
if(ui instanceof javax.swing.plaf.basic.BasicSplitPaneUI) {
((javax.swing.plaf.basic.BasicSplitPaneUI)ui).getDivider()
.setBorder(null);
}
return sp;
}
private void buildBottomPanel(JPanel parent, String layout, JPanel bottomPanel) {
//parent.add(bottomPanel, layout);
////bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS));
bottomPanel.setLayout(new BorderLayout(3, 3));
bottomPanel.setPreferredSize(new Dimension(800, 250));
/*
JPanel audioOpts = new JPanel();
bottomPanel.add(audioOpts, BorderLayout.NORTH);
rdbtnShowFFT = new JCheckBox("Show FFT");
rdbtnShowFFT.addItemListener(this);
rdbtnShowFFT.setSelected(true);
audioOpts.add(rdbtnShowFFT);
*/
audioGraph = new AudioGraphPanel();
audioGraph.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
bottomPanel.add(audioGraph, BorderLayout.CENTER);
audioGraph.setBackground(Color.LIGHT_GRAY);
//audioGraph.setPreferredSize(new Dimension(800, 250));
if (audioGraphThread != null) { audioGraph.stopProcessing(); }
audioGraphThread = new Thread(audioGraph);
audioGraphThread.setUncaughtExceptionHandler(Log.uncaughtExHandler);
audioGraphThread.start();
JPanel eyePhasorPanel = new JPanel();
eyePhasorPanel.setLayout(new BorderLayout());
eyePanel = new EyePanel();
eyePanel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
bottomPanel.add(eyePhasorPanel, BorderLayout.EAST);
eyePhasorPanel.add(eyePanel, BorderLayout.WEST);
eyePanel.setBackground(Color.LIGHT_GRAY);
eyePanel.setPreferredSize(new Dimension(200, 100));
eyePanel.setMaximumSize(new Dimension(200, 100));
eyePanel.setVisible(true);
phasorPanel = new PhasorPanel();
phasorPanel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
eyePhasorPanel.add(phasorPanel, BorderLayout.EAST);
phasorPanel.setBackground(Color.LIGHT_GRAY);
phasorPanel.setPreferredSize(new Dimension(200, 100));
phasorPanel.setMaximumSize(new Dimension(200, 100));
phasorPanel.setVisible(false);
fftPanel = new FFTPanel();
fftPanel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
fftPanel.setBackground(Color.LIGHT_GRAY);
//bottomPanel.add(fftPanel, BorderLayout.SOUTH);
showFFT(false);
fftPanel.setPreferredSize(new Dimension(100, 150));
fftPanel.setMaximumSize(new Dimension(100, 150));
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
bottomPanel, fftPanel);
splitPane.setOneTouchExpandable(true);
splitPane.setContinuousLayout(true); // repaint as we resize, otherwise we can not see the moved line against the dark background
if (Config.splitPaneHeight != 0)
splitPane.setDividerLocation(Config.splitPaneHeight);
else
splitPane.setDividerLocation(200);
SplitPaneUI spui = splitPane.getUI();
if (spui instanceof BasicSplitPaneUI) {
// Setting a mouse listener directly on split pane does not work, because no events are being received.
((BasicSplitPaneUI) spui).getDivider().addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
if (Config.iq == true) {
splitPaneHeight = splitPane.getDividerLocation();
//Log.println("SplitPane: " + splitPaneHeight);
Config.splitPaneHeight = splitPaneHeight;
}
}
});
}
;
parent.add(splitPane, layout);
}
public UwExperimentTab(FoxSpacecraft sat, int displayType) {
super();
fox = sat;
foxId = fox.foxId;
NAME = fox.toString() + " CAN PACKETS";
int j = 0;
layout = new BitArrayLayout[ids.length];
for (int canid : ids)
layout[j++] = Config.satManager.getLayoutByCanId(6, canid);
splitPaneHeight = Config.loadGraphIntValue(fox.getIdString(), GraphFrame.SAVED_PLOT, FoxFramePart.TYPE_REAL_TIME, UWTAB, "splitPaneHeight");
lblName = new JLabel(NAME);
lblName.setMaximumSize(new Dimension(1600, 20));
lblName.setMinimumSize(new Dimension(1600, 20));
lblName.setFont(new Font("SansSerif", Font.BOLD, 14));
topPanel.add(lblName);
lblFramesDecoded = new JLabel(DECODED + CAN_DECODED);
lblFramesDecoded.setFont(new Font("SansSerif", Font.BOLD, 14));
lblFramesDecoded.setBorder(new EmptyBorder(5, 2, 5, 5) );
topPanel.add(lblFramesDecoded);
healthPanel = new JPanel();
healthPanel.setLayout(new BoxLayout(healthPanel, BoxLayout.Y_AXIS));
healthPanel.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
healthPanel.setBackground(Color.DARK_GRAY);
topHalfPackets = new JPanel();
topHalfPackets.setBackground(Color.DARK_GRAY);
bottomHalfPackets = new JPanel(); //new ImagePanel("C:/Users/chris.e.thompson/Desktop/workspace/SALVAGE/data/stars5.png");
bottomHalfPackets.setBackground(Color.DARK_GRAY);
healthPanel.add(topHalfPackets);
healthPanel.add(bottomHalfPackets);
initDisplayHalves(healthPanel);
centerPanel = new JPanel();
centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.X_AXIS));
addModules();
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
healthPanel, centerPanel);
splitPane.setOneTouchExpandable(true);
splitPane.setContinuousLayout(true); // repaint as we resize, otherwise we can not see the moved line against the dark background
if (splitPaneHeight != 0)
splitPane.setDividerLocation(splitPaneHeight);
else
splitPane.setDividerLocation(DEFAULT_DIVIDER_LOCATION);
SplitPaneUI spui = splitPane.getUI();
if (spui instanceof BasicSplitPaneUI) {
// Setting a mouse listener directly on split pane does not work, because no events are being received.
((BasicSplitPaneUI) spui).getDivider().addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
splitPaneHeight = splitPane.getDividerLocation();
Log.println("SplitPane: " + splitPaneHeight);
Config.saveGraphIntParam(fox.getIdString(), GraphFrame.SAVED_PLOT, FoxFramePart.TYPE_REAL_TIME, UWTAB, "splitPaneHeight", splitPaneHeight);
}
});
}
//Provide minimum sizes for the two components in the split pane
Dimension minimumSize = new Dimension(100, 50);
healthPanel.setMinimumSize(minimumSize);
centerPanel.setMinimumSize(minimumSize);
add(splitPane, BorderLayout.CENTER);
showRawBytes = new JCheckBox("Show Raw Bytes", Config.displayRawRadData);
bottomPanel.add(showRawBytes );
showRawBytes.addItemListener(this);
addBottomFilter();
radTableModel = new CanPacketRawTableModel();
radPacketTableModel = new CanPacketTableModel();
addTables(radTableModel,radPacketTableModel);
addPacketModules();
topHalfPackets.setVisible(false);
bottomHalfPackets.setVisible(false);
// initial populate
parseRadiationFrames();
}
private void setupUI() {
Color borderColor = Colors.scale(UIManager.getColor("Panel.background"), .8f);
setTitle(TITLE);
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new EditorWindowListener());
setIconImages(Lists.newArrayList("512","256","128","64","48","32","24","20","16").stream()
.map(size -> Images.loadFromClasspath("images/icon-" + size + ".png").getImage())
.collect(Collectors.toList()));
translationTree = new TranslationTree();
translationTree.setBorder(BorderFactory.createEmptyBorder(0,5,0,5));
translationTree.addTreeSelectionListener(new TranslationTreeNodeSelectionListener());
translationTree.addMouseListener(new TranslationTreeMouseListener());
translationField = new TranslationKeyField();
translationField.addKeyListener(new TranslationFieldKeyListener());
translationField.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createMatteBorder(1,0,0,1,borderColor),
((CompoundBorder)translationField.getBorder()).getInsideBorder()));
JScrollPane translationsScrollPane = new JScrollPane(translationTree);
translationsScrollPane.getViewport().setOpaque(false);
translationsScrollPane.setOpaque(false);
translationsScrollPane.setBorder(BorderFactory.createMatteBorder(0,0,0,1,borderColor));
translationsPanel = new JPanel(new BorderLayout());
translationsPanel.add(translationsScrollPane);
translationsPanel.add(translationField, BorderLayout.SOUTH);
resourcesPanel = new JScrollablePanel(true, false);
resourcesPanel.setLayout(new BoxLayout(resourcesPanel, BoxLayout.Y_AXIS));
resourcesPanel.setBorder(BorderFactory.createEmptyBorder(10,20,10,20));
resourcesPanel.setOpaque(false);
resourcesPanel.addMouseListener(new ResourcesPaneMouseListener());
resourcesScrollPane = new JScrollPane(resourcesPanel);
resourcesScrollPane.getViewport().setOpaque(false);
resourcesScrollPane.setOpaque(false);
resourcesScrollPane.setBorder(null);
resourcesScrollPane.addMouseListener(new ResourcesPaneMouseListener());
contentPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, translationsPanel, resourcesScrollPane);
contentPane.setBorder(null);
contentPane.setDividerSize(10);
// Style the split pane divider if possible
SplitPaneUI splitPaneUI = contentPane.getUI();
if (splitPaneUI instanceof BasicSplitPaneUI) {
BasicSplitPaneDivider divider = ((BasicSplitPaneUI)splitPaneUI).getDivider();
divider.setBorder(null);
resourcesPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,20));
}
introText = new JLabel("<html><body style=\"text-align:center; padding:30px;\">" +
MessageBundle.get("core.intro.text") + "</body></html>");
introText.setOpaque(true);
introText.setFont(introText.getFont().deriveFont(28f));
introText.setHorizontalTextPosition(JLabel.CENTER);
introText.setVerticalTextPosition(JLabel.BOTTOM);
introText.setHorizontalAlignment(JLabel.CENTER);
introText.setVerticalAlignment(JLabel.CENTER);
introText.setForeground(getBackground().darker());
introText.setIcon(Images.loadFromClasspath("images/icon-intro.png"));
Container container = getContentPane();
container.add(introText);
editorMenu = new EditorMenuBar(this, translationTree);
setJMenuBar(editorMenu);
}
/**
* Create the split pane, restore the divider's location and register the needed listeners.
* There will be a {@link PropertyChangeListener} for switching the layout horizontal/vertical
* and a {@link MouseListener}, to restore the divider's location to the default values.
* @see #calculateDividerLocation(int, boolean)
*/
private void createSplitPane()
{
final int spOrientation = getSession().getProperties().getSqlPanelOrientation();
_splitPane = new JSplitPane(spOrientation);
int dividerLoc = calculateDividerLocation(spOrientation, false);
_splitPane.setDividerLocation(dividerLoc);
/*
* Add a PropertyChangeListener for the SessionProperties for changing the orientation
* of the split pane, if the user change the settings.
*/
getSession().getProperties().addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if(SessionProperties.IPropertyNames.SQL_PANEL_ORIENTATION.equals(evt.getPropertyName())){
saveOrientationDependingDividerLocation();
_splitPane.setOrientation((Integer) evt.getNewValue());
_splitPane.setDividerLocation(calculateDividerLocation(_splitPane.getOrientation(), false));
_splitPane.repaint();
}
}
});
/*
* Add a mouse event listener to the divider, so that we can reset the divider location when a double click
* occurs on the divider.
*/
SplitPaneUI spUI = _splitPane.getUI();
if (spUI instanceof BasicSplitPaneUI) {
BasicSplitPaneUI bspUI = (BasicSplitPaneUI) spUI;
bspUI.getDivider().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) {
_splitPane.setDividerLocation(calculateDividerLocation(_splitPane.getOrientation(), true));
}
}
});
}
}