本文整理汇总了Java中javax.swing.SwingConstants.HORIZONTAL属性的典型用法代码示例。如果您正苦于以下问题:Java SwingConstants.HORIZONTAL属性的具体用法?Java SwingConstants.HORIZONTAL怎么用?Java SwingConstants.HORIZONTAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.swing.SwingConstants
的用法示例。
在下文中一共展示了SwingConstants.HORIZONTAL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mousePressed
@Override
public void mousePressed(MouseEvent e) {
super.mousePressed(e);
if (!this.toolBar.isEnabled()) {
return;
}
this.pressedToolbarHandler = false;
Rectangle bumpRect = new Rectangle();
if (this.toolBar.getOrientation() == SwingConstants.HORIZONTAL) {
int x = RapidLookTools.isLeftToRight(this.toolBar) ? 0 : this.toolBar.getSize().width - 14;
bumpRect.setBounds(x, 0, 14, this.toolBar.getSize().height);
} else { // vertical
bumpRect.setBounds(0, 0, this.toolBar.getSize().width, 14);
}
if (bumpRect.contains(e.getPoint())) {
this.pressedToolbarHandler = true;
Point dragOffset = e.getPoint();
if (!RapidLookTools.isLeftToRight(this.toolBar)) {
dragOffset.x -= (this.toolBar.getSize().width - this.toolBar.getPreferredSize().width);
}
setDragOffset(dragOffset);
}
}
示例2: addSeperatorToPanel
protected void addSeperatorToPanel(JPanel addTarget) {
if (!(addTarget.getLayout() instanceof GridBagLayout)) {
throw new RuntimeException("JPanel with GridBagLayout is mandatory!");
}
JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL);
GridBagConstraints itemConstraint = new GridBagConstraints();
itemConstraint.gridx = GridBagConstraints.RELATIVE;
itemConstraint.weightx = 1.0;
itemConstraint.gridwidth = GridBagConstraints.REMAINDER; // end row
itemConstraint.fill = GridBagConstraints.HORIZONTAL;
itemConstraint.insets = new Insets(0, 5, 5, 5);
addTarget.add(separator, itemConstraint);
}
示例3: paint
/**
* Override default paint method to draw separating line
* @param g Graphics object to be painted
*/
@Override
public void paint(Graphics g) {
try {
JToolBar parent = (JToolBar) this.getParent();
Dimension d = this.getSize();
g.setColor(Color.GRAY);
if (parent.getOrientation() == SwingConstants.HORIZONTAL) {
if (orientation != SwingConstants.HORIZONTAL) {
setMaximumSize(Horizontal);
orientation = SwingConstants.HORIZONTAL;
parent.revalidate();
}
g.drawLine(d.width / 2, 0, d.width / 2, d.height);
} else {
if (orientation != SwingConstants.VERTICAL) {
setMaximumSize(Vertical);
orientation = SwingConstants.VERTICAL;
parent.revalidate();
}
g.drawLine(0, d.height / 2, d.width, d.height / 2);
}
} catch (ClassCastException ex) {
super.paint(g);
}
}
示例4: paint
/**
* Override default paint method to draw separating line
* @param g Graphics object to be painted
*/
@Override
public void paint(Graphics g) {
try {
JToolBar parent = (JToolBar) this.getParent();
Dimension d = this.getSize();
g.setColor(Color.gray);
if (parent.getOrientation() == SwingConstants.HORIZONTAL) {
if (orientation != SwingConstants.HORIZONTAL) {
setMaximumSize(Horizontal);
orientation = SwingConstants.HORIZONTAL;
parent.revalidate();
}
g.drawLine(d.width / 2, 0, d.width / 2, d.height);
} else {
if (orientation != SwingConstants.VERTICAL) {
setMaximumSize(Vertical);
orientation = SwingConstants.VERTICAL;
parent.revalidate();
}
g.drawLine(0, d.height / 2, d.width, d.height / 2);
}
} catch (ClassCastException ex) {
super.paint(g);
}
}
示例5: getScrollableUnitIncrement
@Override
public int getScrollableUnitIncrement(
Rectangle visible, int orientation, int direction) {
switch (orientation) {
case SwingConstants.HORIZONTAL:
return visible.width * 10 / 100;
case SwingConstants.VERTICAL:
return visible.height * 10 / 100;
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation); //NOI18N
}
}
示例6: getScrollableBlockIncrement
@Override
public int getScrollableBlockIncrement(
Rectangle visible, int orientation, int direction) {
switch (orientation) {
case SwingConstants.HORIZONTAL:
return visible.width * 100 / 100;
case SwingConstants.VERTICAL:
return visible.height * 100 / 100;
default:
throw new IllegalArgumentException("Invalid orientation: " + orientation); //NOI18N
}
}
示例7: GUISliderComponent
public GUISliderComponent(JFrame owner, int x, int y, int w, int h, int min, int max, int value, String label)
{
super(owner);
this.text = new JLabel(label);
this.slider = new JSlider(SwingConstants.HORIZONTAL, min, max, value);
this.slider.setSize(new Dimension(w, h));
this.slider.setLocation(new Point(x, y));
this.slider.setVisible(true);
this.text.setLocation(new Point(x + w, y));
this.text.setSize(new Dimension(w, h));
this.owner.add(text);
this.owner.add(slider);
}
示例8: calculateThumbLocation
@Override
protected void calculateThumbLocation() {
super.calculateThumbLocation();
if (this.slider.getOrientation() == SwingConstants.HORIZONTAL) {
thumbRect.y -= 4;
} else {
thumbRect.x -= 4;
}
}
示例9: getScrollableBlockIncrement
public int getScrollableBlockIncrement(Rectangle visibleRect,
int orientation,
int direction) {
Insets ins = axes.getInsets();
if( orientation==SwingConstants.HORIZONTAL ) {
return (visibleRect.width-ins.left-ins.right) / 2;
} else {
return (visibleRect.height-ins.top-ins.bottom) / 2;
}
}
示例10: getScrollableUnitIncrement
/**
* Try to keep the viewport aligned on column boundaries in the direction of interest
*/
@Override
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
if (orientation == SwingConstants.HORIZONTAL) {
return 80;
}
return getRowHeight();
}
示例11: getScrollableBlockIncrement
@Override
public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
/* borrowed from JTable */
if (orientation == SwingConstants.HORIZONTAL) {
return 5 * getScrollableUnitIncrement(visibleRect, orientation, direction);
}
return super.getScrollableBlockIncrement(visibleRect, orientation, direction);
}
示例12: SliderFrame
public SliderFrame()
{
super("Slider Demo");
myPanel = new OvalPanel(); // create panel to draw circle
myPanel.setBackground(Color.YELLOW);
// set up JSlider to control diameter value
diameterJSlider =
new JSlider(SwingConstants.HORIZONTAL, 0, 200, 10);
diameterJSlider.setMajorTickSpacing(10); // create tick every 10
diameterJSlider.setPaintTicks(true); // paint ticks on slider
// register JSlider event listener
diameterJSlider.addChangeListener(
new ChangeListener() // anonymous inner class
{
// handle change in slider value
@Override
public void stateChanged(ChangeEvent e)
{
myPanel.setDiameter(diameterJSlider.getValue());
}
}
);
add(diameterJSlider, BorderLayout.SOUTH);
add(myPanel, BorderLayout.CENTER);
}
示例13: MyJSlider
MyJSlider(Method methodToCall, int min, int max, int init, JGraphLayout layout,
LayouterItem item) {
super(SwingConstants.HORIZONTAL, min, max, init);
this.methodToCall = methodToCall;
this.layout = layout;
this.item = item;
// Turn on labels at major tick marks.
this.setMajorTickSpacing((max - min) / 5);
this.setMinorTickSpacing((max - min) / 50);
this.setPaintTicks(true);
this.setPaintLabels(true);
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
Font font = new Font("Serif", Font.ITALIC, 10);
this.setFont(font);
}
示例14: NbiSeparator
public NbiSeparator() {
super(SwingConstants.HORIZONTAL);
}
示例15: RadioButtonPanel
public RadioButtonPanel() {
this(SwingConstants.HORIZONTAL, false);
}