本文整理汇总了Java中edu.mit.blocks.codeblockutil.CScrollPane.ScrollPolicy类的典型用法代码示例。如果您正苦于以下问题:Java ScrollPolicy类的具体用法?Java ScrollPolicy怎么用?Java ScrollPolicy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ScrollPolicy类属于edu.mit.blocks.codeblockutil.CScrollPane包,在下文中一共展示了ScrollPolicy类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: repositionComponents
import edu.mit.blocks.codeblockutil.CScrollPane.ScrollPolicy; //导入依赖的package包/类
public void repositionComponents() {
scrollviewport.setBounds(0, 0, this.getWidth(), this.getHeight());
if (this.vpolicy.equals(ScrollPolicy.VERTICAL_BAR_ALWAYS) || this.vpolicy.equals(ScrollPolicy.VERTICAL_BAR_AS_NEEDED)) {
verticalbar.setBounds(this.getWidth() - this.thumbWidth, 7,
this.thumbWidth, this.getHeight() - this.thumbWidth - 7);
} else {
verticalbar.setBounds(this.getWidth() - this.thumbWidth, 7,
0, 0);
}
if (this.hpolicy.equals(ScrollPolicy.HORIZONTAL_BAR_ALWAYS)) {
horizontalbar.setBounds(7, this.getHeight() - this.thumbWidth,
this.getWidth() - this.thumbWidth - 7, this.thumbWidth);
} else if (this.hpolicy.equals(ScrollPolicy.HORIZONTAL_BAR_AS_NEEDED)) {
if (this.getWidth() < this.scrollviewport.getViewport().getView().getWidth() - 2) {
horizontalbar.setBounds(7, this.getHeight() - this.thumbWidth,
this.getWidth() - this.thumbWidth - 7, this.thumbWidth);
} else {
horizontalbar.setBounds(7, this.getHeight() - this.thumbWidth,
0, 0);
}
}
this.revalidate();
}
示例2: GlassCard
import edu.mit.blocks.codeblockutil.CScrollPane.ScrollPolicy; //导入依赖的package包/类
/**
* constructor
* @param i
* @param canvas
* @param ex
*/
GlassCard(int i, Canvas canvas, GlassExplorer ex) {
this.index = i;
this.explorer = ex;
this.canvas = canvas;
this.button = new GlassButton(canvas.getColor(), canvas.getColor().brighter().brighter().brighter(), canvas.getName());
//this.button.setMaximumSize(new Dimension(0,10));
//this.button.setPreferredSize(new Dimension(0,10));
this.scroll = new CGlassScrollPane(
canvas.getJComponent(),
ScrollPolicy.VERTICAL_BAR_AS_NEEDED,
ScrollPolicy.HORIZONTAL_BAR_NEVER,
SCROLLBAR_WIDTH, canvas.getColor(),
new Color(100, 100, 100, 100));
canvas.getJComponent().setOpaque(false);
button.addActionListener(this);
canvas.getJComponent().addPropertyChangeListener(this);
this.scroll.setPreferredSize(
new Dimension(canvas.getJComponent().getPreferredSize().width + SCROLLBAR_WIDTH,
canvas.getJComponent().getPreferredSize().height));
}
示例3: setDrawersCard
import edu.mit.blocks.codeblockutil.CScrollPane.ScrollPolicy; //导入依赖的package包/类
/**
* Reassigns the set of canvases that this explorer controls.
* Though the collection of canvas mnay be empty, it may not be null.
* @param items
*
* @requires items != null &&
* for each element in item, element!= null
*/
public void setDrawersCard(List<? extends Canvas> items) {
canvases.clear();
buttonPane.removeAll();
for (int i = 0; i < items.size(); i++) {
final int index = i;
Canvas item = items.get(i);
//final CButton button = new CButton(item.getColor(), item.getColor().brighter().brighter().brighter(),item.getName());
CButton button = new CBorderlessButton(item.getName());
JComponent scroll = new CHoverScrollPane(
item.getJComponent(),
ScrollPolicy.VERTICAL_BAR_AS_NEEDED,
ScrollPolicy.HORIZONTAL_BAR_AS_NEEDED,
18, item.getColor(), Color.darkGray);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
selectCanvas(index);
}
});
canvases.add(scroll);
buttonPane.add(button);
}
}
示例4: PopupExplorer
import edu.mit.blocks.codeblockutil.CScrollPane.ScrollPolicy; //导入依赖的package包/类
/**
* Constructor
*/
public PopupExplorer() {
super();
this.components = new ArrayList<Canvas>();
this.setLayout(null);
this.setOpaque(true);
this.setBackground(Color.GRAY);
this.viewport = new JPanel(new BorderLayout());
scroll = new CHoverScrollPane(
viewport,
ScrollPolicy.VERTICAL_BAR_ALWAYS,
ScrollPolicy.HORIZONTAL_BAR_NEVER,
20, Color.blue, new Color(0, 0, 50));
add(scroll, JLayeredPane.DEFAULT_LAYER);
setLayer(scroll, JLayeredPane.DEFAULT_LAYER, 0);
buttonPane = new ButtonPanel();
add(buttonPane, JLayeredPane.PALETTE_LAYER);
setLayer(buttonPane, JLayeredPane.PALETTE_LAYER, 0);
this.addComponentListener(this);
}
示例5: CardPane
import edu.mit.blocks.codeblockutil.CScrollPane.ScrollPolicy; //导入依赖的package包/类
/** Constructor */
private CardPane() {
super(new BorderLayout());
this.setOpaque(false);
this.scroll = new CHoverScrollPane(
canvas.getJComponent(),
ScrollPolicy.VERTICAL_BAR_AS_NEEDED,
ScrollPolicy.HORIZONTAL_BAR_AS_NEEDED,
18, canvas.getColor(), new Color(100, 100, 100, 100));
this.label = new CardLabel();
this.add(label, BorderLayout.NORTH);
this.add(scroll, BorderLayout.CENTER);
}
示例6: setDrawersCard
import edu.mit.blocks.codeblockutil.CScrollPane.ScrollPolicy; //导入依赖的package包/类
/**
* Reassigns the set of canvases that this explorer controls.
* Though the collection of canvas mnay be empty, it may not be null.
* @param items
*
* @requires items != null &&
* for each element in item, element!= null
*/
public void setDrawersCard(List<? extends Canvas> items) {
canvases.clear();
buttonPane.removeAll();
int size = items.size();
if (size % 2 == 1) {
size++;
}
size = buttonHeight * size;
buttonPane.setPreferredSize(new Dimension(6, size));
for (int i = 0; i < items.size(); i++) {
final int index = i;
Canvas item = items.get(i);
//final CButton button = new CButton(item.getColor(), item.getColor().brighter().brighter().brighter(),item.getName());
CButton button = new CBorderlessButton(item.getName());
JComponent scroll = new CHoverScrollPane(
item.getJComponent(),
ScrollPolicy.VERTICAL_BAR_AS_NEEDED,
ScrollPolicy.HORIZONTAL_BAR_AS_NEEDED,
18, item.getColor(), Color.darkGray);
canvases.add(scroll);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
selectCanvas(index);
}
});
buttonPane.add(button);
}
if (!canvases.isEmpty()) {
canvasPane.add(canvases.get(0));
}
this.revalidate();
}
示例7: HoverVerticalBar
import edu.mit.blocks.codeblockutil.CScrollPane.ScrollPolicy; //导入依赖的package包/类
/**
*
* @param barwidth - the final HEIGHT on the thumb
* @param thumbColor - the final color of the thumb's interior
* @param trackColor - the final color of trh track
* @param modelrange - the mutating view ranges to control
* and be controlled by this HorizontalBar
*
* @requires barwidth != null && thumbColor != null && modelrange != null
* @effects Constructs this to have a thumb of barwidth in size
* with a thumb color set to thummbColor.
*/
public HoverVerticalBar(int barwidth, Color thumbColor, Color trackColor, BoundedRangeModel modelrange, ScrollPolicy verticalPolicy) {
this.vpolicy = verticalPolicy;
this.trackColor = trackColor;
this.modelrange = modelrange;
this.thumbColor = thumbColor;
this.renderingHints = new RenderingHints(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
this.pressLocation = 0;
this.setOpaque(false);
this.addMouseMotionListener(this);
this.addMouseListener(this);
this.addMouseWheelListener(this);
}
示例8: paint
import edu.mit.blocks.codeblockutil.CScrollPane.ScrollPolicy; //导入依赖的package包/类
/**
* paints scrollbar
*/
@Override
public void paint(Graphics g) {
//paint super
super.paint(g);
//set up values
double viewValue = modelToView(modelrange.getValue());
double viewExtent = modelToView(modelrange.getExtent());
int vWidth;
if (!vpolicy.equals(ScrollPolicy.VERTICAL_BAR_AS_NEEDED) || (modelrange.getMaximum() > this.getHeight() + 7 + this.getWidth())) {
vWidth = this.getWidth() / 2;
Graphics2D g2 = (Graphics2D) g;
g2.addRenderingHints(renderingHints);
g2.translate(vWidth / 2, 0);
g2.setColor(trackColor);
g2.fillRoundRect(0, 0, vWidth, this.getHeight(), vWidth, vWidth);
g2.setColor(new Color(150, 150, 150));
g2.drawRoundRect(0, 0, vWidth, this.getHeight() - 1, vWidth, vWidth);
if (viewValue < this.getHeight() - 0.5f * this.getWidth()) {
g2.translate(0, viewValue);
} else {
g2.translate(0, this.getHeight() - 0.5f * this.getWidth());
}
g2.setPaint(new GradientPaint(
0, 0, this.thumbColor,
this.getWidth() + 10, 0, Color.black, true));
g2.fillRoundRect(0, 0, vWidth, (int) viewExtent, vWidth, vWidth);
g2.setColor(new Color(250, 250, 250, 100));
g2.drawRoundRect(0, 0, vWidth, (int) viewExtent, vWidth, vWidth);
}
}
示例9: CPopupMenu
import edu.mit.blocks.codeblockutil.CScrollPane.ScrollPolicy; //导入依赖的package包/类
CPopupMenu() {
super();
this.setLayout(new BorderLayout());
this.setBackground(background);
this.setOpaque(false);
this.removeAll();
this.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, CGraphite.blue));
view = new JPanel(new GridLayout(0, 1));
view.setBackground(background);
scroll = new CTracklessScrollPane(view,
ScrollPolicy.VERTICAL_BAR_AS_NEEDED,
ScrollPolicy.HORIZONTAL_BAR_NEVER,
9, CGraphite.blue, background);
this.add(scroll);
}
示例10: CTable
import edu.mit.blocks.codeblockutil.CScrollPane.ScrollPolicy; //导入依赖的package包/类
/**
* Create a new Table instance with an empty domain
* @param i - thumb width
*/
public CTable(int i) {
super(new BorderLayout());
this.columns = new String[]{};
this.columnLabels = new JLabel[]{};
this.data = new ArrayList<double[]>();
view = new JPanel();
view.setBackground(foreground);
scroll = new CTracklessScrollPane(
view,
ScrollPolicy.VERTICAL_BAR_AS_NEEDED,
ScrollPolicy.HORIZONTAL_BAR_AS_NEEDED,
i, CGraphite.blue, new Color(100, 100, 100));
this.add(scroll, BorderLayout.CENTER);
}
示例11: BlockCanvas
import edu.mit.blocks.codeblockutil.CScrollPane.ScrollPolicy; //导入依赖的package包/类
/**
* Constructs BlockCanvas and subscribes
* this BlockCanvas to PageChange events
*/
public BlockCanvas(Workspace workspace) {
this.workspace = workspace;
this.canvas = new Canvas();
this.scrollPane = new CHoverScrollPane(canvas,
ScrollPolicy.VERTICAL_BAR_ALWAYS,
ScrollPolicy.HORIZONTAL_BAR_ALWAYS,
18, CGraphite.blue, null);
scrollPane.setScrollingUnit(5);
canvas.setLayout(null);
canvas.setBackground(Color.gray);
canvas.setOpaque(true);
PageChangeEventManager.addPageChangeListener(this);
}
示例12: CWheeler
import edu.mit.blocks.codeblockutil.CScrollPane.ScrollPolicy; //导入依赖的package包/类
public CWheeler(Collection<JComponent> items, boolean includeScrollbar, Color backgroundColor) {
super(new BorderLayout());
this.setBackground(backgroundColor);
this.elements = items;
if (includeScrollbar) {
CArrowButton left = new CArrowButton(CArrowButton.Direction.WEST) {
private static final long serialVersionUID = 328149080242L;
@Override
public void triggerAction() {
scrollLeft();
}
};
left.addActionListener(left);
left.setPreferredSize(new Dimension(15, 15));
CArrowButton right = new CArrowButton(CArrowButton.Direction.EAST) {
private static final long serialVersionUID = 328149080243L;
@Override
public void triggerAction() {
scrollRight();
}
};
right.addActionListener(right);
right.setPreferredSize(new Dimension(15, 15));
this.view = new JPanel(null);
this.view.setBackground(backgroundColor);
this.scroll = new CHoverScrollPane(view,
ScrollPolicy.VERTICAL_BAR_NEVER,
ScrollPolicy.HORIZONTAL_BAR_ALWAYS,
20, CGraphite.blue, new Color(0, 0, 50));
JPanel leftPane = new JPanel(new BorderLayout());
leftPane.setBackground(backgroundColor);
leftPane.add(left, BorderLayout.SOUTH);
this.add(leftPane, BorderLayout.WEST);
JPanel rightPane = new JPanel(new BorderLayout());
rightPane.setBackground(backgroundColor);
rightPane.add(right, BorderLayout.SOUTH);
this.add(rightPane, BorderLayout.EAST);
} else {
this.view = new JPanel(null);
this.view.setBackground(backgroundColor);
this.scroll = new CTracklessScrollPane(view,
ScrollPolicy.VERTICAL_BAR_NEVER,
ScrollPolicy.HORIZONTAL_BAR_NEVER,
20, Color.blue, new Color(0, 0, 50));
}
for (JComponent element : elements) {
view.add(element);
}
this.add(scroll, BorderLayout.CENTER);
reformItems();
}
示例13: CHoverScrollPane
import edu.mit.blocks.codeblockutil.CScrollPane.ScrollPolicy; //导入依赖的package包/类
/**
* Constructs a custom CHoverScrollPane with the view port set to "view",
* with both scroll bar policies set to "ALWAYS" (see
* javax.swing.JScrollPane for a description on the use of
* scroll bar policies). Thumb will have girth of 10 and an interior
* color of black, hovering above a grayed-out transparant background.
*
* @param view
*
* @requires view != null
* @effects constructs a CScrollPane as described in method overview
*/
public CHoverScrollPane(JComponent view) {
this(view, ScrollPolicy.VERTICAL_BAR_ALWAYS,
ScrollPolicy.HORIZONTAL_BAR_ALWAYS);
}