javax.swing.JSlider.setBorder()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(11.6k)|赞(0)|评价(0)|浏览(94)

本文整理了Java中javax.swing.JSlider.setBorder()方法的一些代码示例,展示了JSlider.setBorder()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSlider.setBorder()方法的具体详情如下:
包路径:javax.swing.JSlider
类名称:JSlider
方法名:setBorder

JSlider.setBorder介绍

暂无

代码示例

代码示例来源:origin: 4thline/cling

volumeSlider.setBorder(BorderFactory.createTitledBorder("Volume"));
volumeSlider.setMajorTickSpacing(maxVolume / 5);
volumeSlider.setMinorTickSpacing(5);

代码示例来源:origin: magefree/mage

sliderFontSize.setSnapToTicks(true);
sliderFontSize.setToolTipText("<HTML>The size of the font used to display table text.");
sliderFontSize.setBorder(javax.swing.BorderFactory.createEtchedBorder());
sliderFontSize.setMinimumSize(new java.awt.Dimension(150, 40));
gridBagConstraints = new java.awt.GridBagConstraints();
sliderChatFontSize.setSnapToTicks(true);
sliderChatFontSize.setToolTipText("<HTML>The size of the font used to display the chat text");
sliderChatFontSize.setBorder(javax.swing.BorderFactory.createEtchedBorder());
sliderChatFontSize.setMinimumSize(new java.awt.Dimension(150, 40));
gridBagConstraints = new java.awt.GridBagConstraints();
sliderDialogFont.setSnapToTicks(true);
sliderDialogFont.setToolTipText("<HTML>The size of the font of messages and menues");
sliderDialogFont.setBorder(javax.swing.BorderFactory.createEtchedBorder());
sliderDialogFont.setMinimumSize(new java.awt.Dimension(150, 40));
gridBagConstraints = new java.awt.GridBagConstraints();
sliderEditorCardSize.setSnapToTicks(true);
sliderEditorCardSize.setToolTipText("<HTML>The size of the card in editor and the picked zone of the draft panel");
sliderEditorCardSize.setBorder(javax.swing.BorderFactory.createEtchedBorder());
sliderEditorCardSize.setMinimumSize(new java.awt.Dimension(150, 40));
gridBagConstraints = new java.awt.GridBagConstraints();
sliderEditorCardOffset.setSnapToTicks(true);
sliderEditorCardOffset.setToolTipText("<HTML>The size of the card in editor and the picked zone of the draft panel");
sliderEditorCardOffset.setBorder(javax.swing.BorderFactory.createEtchedBorder());
sliderEditorCardOffset.setMinimumSize(new java.awt.Dimension(150, 40));
gridBagConstraints = new java.awt.GridBagConstraints();

代码示例来源:origin: sc.fiji/Interactive_3D_Surface_Plot

private void setSliderTitle(JSlider slider, Color color, String str) {
  Border empty = BorderFactory.createTitledBorder( 
          BorderFactory.createEmptyBorder() );
  
  Font sliderFont = new Font("Sans", Font.PLAIN, 11);
  
  slider.setBorder(new TitledBorder(
      empty, str, TitledBorder.CENTER, 
      TitledBorder.BELOW_TOP,    sliderFont));         
  //TitledBorder tb = new TitledBorder(empty,
  //		"", TitledBorder.CENTER, TitledBorder.TOP,
  //		new Font("Sans", Font.PLAIN, 12));
  //tb.setTitleJustification(TitledBorder.LEFT);
  //tb.setTitle(str);
  //tb.setTitleColor(color);
  //slider.setBorder(tb);
}

代码示例来源:origin: sc.fiji/Interactive_3D_Surface_Plot

private JSlider createSliderHorizontal(String borderTitle, int min, int max, int value) {
    
    // create nested border
    Border empty = BorderFactory.createTitledBorder( 
            BorderFactory.createEmptyBorder());
        
    // create font for sliders
    Font sliderFont = new Font("Sans", Font.PLAIN, 11);
    
    // create slider
    JSlider slider = createSliderSafe(JSlider.HORIZONTAL, min, max, value);
    slider.setBorder(new TitledBorder(
        empty, borderTitle, TitledBorder.CENTER, 
        TitledBorder.BELOW_TOP,    sliderFont));         

    slider.addChangeListener(new ChangeListener(){
      public void stateChanged(ChangeEvent event) {
        sliderChange((JSlider)event.getSource());
      }    
    });        
    
    return slider;
  }

代码示例来源:origin: sc.fiji/Interactive_3D_Surface_Plot

private JSlider createSliderVertical(String borderTitle, int min, int max, int value) {
  
  // create nested border
  Border empty = BorderFactory.createTitledBorder( 
          BorderFactory.createEmptyBorder());
      
  // create font for sliders
  Font sliderFont = new Font("Sans", Font.PLAIN, 11);
  
  // create slider
  JSlider slider = createSliderSafe(JSlider.VERTICAL, min, max, value);
  slider.setBorder(new TitledBorder(
      empty, borderTitle, TitledBorder.CENTER, 
      TitledBorder.BELOW_TOP,    sliderFont));         

  slider.addChangeListener(new ChangeListener(){
    public void stateChanged(ChangeEvent event) {
      sliderChange((JSlider)event.getSource());
    }    
  });        
  
  return slider;
}

代码示例来源:origin: sc.fiji/Color_Inspector_3D

private void setSliderTitle(JSlider slider, Color color, String str) {
  //Border empty = BorderFactory.createTitledBorder( BorderFactory.createEmptyBorder() );
  TitledBorder tb = new TitledBorder(BorderFactory.createEtchedBorder(), //empty,
      "", TitledBorder.CENTER, TitledBorder.ABOVE_BOTTOM,
      new Font("Sans", Font.PLAIN, 11));
  tb.setTitleJustification(TitledBorder.LEFT);
  tb.setTitle(str);
  tb.setTitleColor(color);
  slider.setBorder(tb);
}

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
protected void installDefaults(JSlider slider) {
  super.installDefaults(slider);
  focusInsets = new Insets(0, 0, 0, 0);
  slider.setOpaque(false);
  if (slider.getOrientation() == JSlider.HORIZONTAL) {
    slider.setBorder(new EmptyBorder(0, 1, -1, 1));
  } else {
    slider.setBorder(new EmptyBorder(0, 0, 0, 1));
  }
  //slider.setRequestFocusEnabled(QuaquaManager.getBoolean("Slider.requestFocusEnabled"));
  slider.setRequestFocusEnabled(true);
}

代码示例来源:origin: sc.fiji/Color_Inspector_3D

private JSlider makeTitledVerticalSilder(String string, Color color, int minVal, int maxVal, int val) {
  //Border empty = BorderFactory.createTitledBorder( BorderFactory.createEmptyBorder() );
  JSlider slider = new JSlider(JSlider.VERTICAL, minVal, maxVal, val );
  TitledBorder tb = new TitledBorder(BorderFactory.createEtchedBorder(), //empty,
      "", TitledBorder.CENTER, TitledBorder.ABOVE_BOTTOM,
      new Font("Sans", Font.PLAIN, 11));
  tb.setTitle(string);
  //tb.setTitleJustification(TitledBorder.LEFT);
  tb.setTitleColor(color);
  slider.setBorder(tb);
  slider.setMajorTickSpacing((maxVal - minVal)/6 );
  slider.setPaintTicks(true);
  slider.addChangeListener( this );
  slider.addChangeListener( this );
  slider.addMouseListener(this);
  return slider;
}

代码示例来源:origin: org.java.net.substance/substance

@Override
protected void installDefaults(JSlider slider) {
  super.installDefaults(slider);
  focusInsets = new Insets(0, 0, 0, 0);
  slider.setOpaque(false);
  if (slider.getOrientation() == JSlider.HORIZONTAL) {
    slider.setBorder(new VisualMargin(0, 1, -1, 1));
  } else {
    slider.setBorder(new VisualMargin(0, 0, 0, 1));
  }
  // slider.setRequestFocusEnabled(QuaquaManager.getBoolean("Slider.requestFocusEnabled"));
  slider.setRequestFocusEnabled(true);
}

代码示例来源:origin: atarw/material-ui-swing

@Override
public void installUI (JComponent c) {
  super.installUI (c);
  JSlider slider = (JSlider) c;
  slider.setFont (UIManager.getFont ("Slider.font"));
  slider.setBackground (UIManager.getColor ("Slider.background"));
  slider.setForeground (UIManager.getColor ("Slider.foreground"));
  slider.setBorder (UIManager.getBorder ("Slider.border"));
}

代码示例来源:origin: com.github.insubstantial/substance

@Override
protected void installDefaults(JSlider slider) {
  super.installDefaults(slider);
  focusInsets = new Insets(0, 0, 0, 0);
  slider.setOpaque(false);
  if (slider.getOrientation() == JSlider.HORIZONTAL) {
    slider.setBorder(new VisualMargin(0, 1, -1, 1));
  } else {
    slider.setBorder(new VisualMargin(0, 0, 0, 1));
  }
  // slider.setRequestFocusEnabled(QuaquaManager.getBoolean("Slider.requestFocusEnabled"));
  slider.setRequestFocusEnabled(true);
}

代码示例来源:origin: sc.fiji/Color_Inspector_3D

private JSlider makeTitledSilder(String string, Color color, int minVal, int maxVal, int val) {
  //Border empty = BorderFactory.createTitledBorder( BorderFactory.createEmptyBorder() );
  JSlider slider = new JSlider(JSlider.HORIZONTAL, minVal, maxVal, val );
  TitledBorder tb = new TitledBorder(BorderFactory.createEtchedBorder(), 
      //empty,
      "", TitledBorder.CENTER, TitledBorder.ABOVE_BOTTOM,
      new Font("Sans", Font.PLAIN, 11));
  tb.setTitle(string);
  tb.setTitleJustification(TitledBorder.LEFT);
  tb.setTitleColor(color);
  slider.setBorder(tb);
  slider.setMajorTickSpacing((maxVal - minVal)/6 );
  //slider.setMajorTickSpacing((maxVal - minVal)/10 );
  slider.setPaintTicks(true);
  slider.addChangeListener( this );
  slider.addChangeListener( this );
  slider.addMouseListener(this);
  return slider;
}

代码示例来源:origin: edu.stanford.protege/org.coode.owlviz

component.add(panel, gbc);
edgeBrightness = new JSlider(0, 100);
edgeBrightness.setBorder(BorderFactory.createTitledBorder("Edge brightness"));
edgeBrightness.setMajorTickSpacing(50);
edgeBrightness.setMinorTickSpacing(10);

代码示例来源:origin: com.github.insubstantial/substance

@Override
  public void propertyChange(PropertyChangeEvent e) {
    String propertyName = e.getPropertyName();
    if (propertyName.equals("Frame.active")) {
      // calculateGeometry();
      slider.repaint();
    } else if (propertyName.equals("ColorSliderModel")) {
      colorSliderModel = (ColorSliderModel) e.getNewValue();
      slider.repaint();
    } else if (propertyName.equals("snapToTicks")) {
      slider.repaint();
    } else if (propertyName.equals("ColorComponentIndex")) {
      componentIndex = (Integer) e.getNewValue();
      slider.repaint();
    } else if (propertyName.equals("ColorComponentChange")) {
      Integer value = (Integer) e.getNewValue();
      slider.repaint();
    } else if (propertyName.equals("ColorComponentValue")) {
      slider.repaint();
    } else if (propertyName.equals("Orientation")) {
      if (slider.getOrientation() == JSlider.HORIZONTAL) {
        slider.setBorder(new VisualMargin(0, 1, -1, 1));
      } else {
        slider.setBorder(new VisualMargin(0, 0, 0, 1));
      }
    }
    super.propertyChange(e);
  }
}

代码示例来源:origin: ribomation/DroidAtScreen1

scaleSlider.setPaintLabels(true);
scaleSlider.setLabelTable(labels);
scaleSlider.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(vMarg, hMarg, vMarg, 2 * hMarg), BorderFactory.createTitledBorder("Scale")));

代码示例来源:origin: nroduit/Weasis

JSlider createSlider(final FloatControl c) {
  if (c == null) {
    return null;
  }
  final JSlider s = new JSlider(0, 1000);
  final float min = c.getMinimum();
  final float max = c.getMaximum();
  final float width = max - min;
  float fval = c.getValue();
  s.setValue((int) ((fval - min) / width * 1000));
  java.util.Hashtable<Integer, JLabel> labels = new java.util.Hashtable<>(3);
  labels.put(0, new JLabel(c.getMinLabel()));
  labels.put(500, new JLabel(c.getMidLabel()));
  labels.put(1000, new JLabel(c.getMaxLabel()));
  s.setLabelTable(labels);
  s.setPaintLabels(true);
  s.setBorder(new TitledBorder(c.getType().toString() + " " + c.getUnits())); //$NON-NLS-1$
  s.addChangeListener(e -> {
    int i = s.getValue();
    float f = min + (i * width / 1000.0f);
    c.setValue(f);
  });
  return s;
}

代码示例来源:origin: MegaMek/megamek

private JSlider buildSlider(String minMsgProperty, String maxMsgProperty, String toolTip, String title) {
  JSlider thisSlider = new JSlider(SwingConstants.HORIZONTAL, 0, 10, 5);
  Hashtable<Integer, JLabel> sliderLabels = new Hashtable<Integer, JLabel>(3);
  sliderLabels.put(0, buildSliderLabel("0 - " + minMsgProperty));
  sliderLabels.put(10, buildSliderLabel("10 - " + maxMsgProperty));
  sliderLabels.put(5, buildSliderLabel("5"));
  thisSlider.setToolTipText(toolTip);
  thisSlider.setLabelTable(sliderLabels);
  thisSlider.setPaintLabels(true);
  thisSlider.setMinorTickSpacing(1);
  thisSlider.setMajorTickSpacing(2);
  thisSlider.setSnapToTicks(true);
  thisSlider.setBorder(new TitledBorder(new LineBorder(Color.black), title));
  thisSlider.setEnabled(true);
  return thisSlider;
}

代码示例来源:origin: apache/batik

quality.setPaintTicks(true);
quality.setPaintLabels(true);
quality.setBorder(BorderFactory.createEmptyBorder(0,0,10,0));
Hashtable labels = new Hashtable();
for (int i=0; i < 100; i+=10) {

代码示例来源:origin: matsim-org/matsim

timestepSlider.setBorder(BorderFactory.createEmptyBorder(0,0,0,10));
add(timestepSlider);

代码示例来源:origin: nroduit/Weasis

public AbstractSliderComponent(AbstractAcquireActionPanel panel, String title) {
  super(panel, title);
  this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
  slider = new JSlider(getMin(), getMax(), getDefaultValue());
  slider.setMajorTickSpacing(getMax());
  slider.setPaintTicks(true);
  slider.setLabelTable(getLabels());
  slider.setPaintLabels(true);
  SliderChangeListener.setFont(slider, FontTools.getFont10());
  slider.setBorder(borderTitle);
  add(slider);
}

相关文章

JSlider类方法