當前位置: 首頁>>代碼示例>>Java>>正文


Java Spring.constant方法代碼示例

本文整理匯總了Java中javax.swing.Spring.constant方法的典型用法代碼示例。如果您正苦於以下問題:Java Spring.constant方法的具體用法?Java Spring.constant怎麽用?Java Spring.constant使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.Spring的用法示例。


在下文中一共展示了Spring.constant方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getBestWidth

import javax.swing.Spring; //導入方法依賴的package包/類
private Spring getBestWidth(Container parent, int rows, int cols) {
	Spring x = Spring.constant(0);
	Spring width = Spring.constant(0);
	for (int c = 0; c < cols; c++) {
		
		for (int r = 0; r < rows; r++) {
			width = Spring.max(width, getConstraintsForCell(r, c, parent, cols).getWidth());
		}
	}
	return width;
}
 
開發者ID:laurent-clouet,項目名稱:sheepit-client,代碼行數:12,代碼來源:Working.java

示例2: makeProgressBars

import javax.swing.Spring; //導入方法依賴的package包/類
private void makeProgressBars(SpringLayout l) {
    JComponent prevLabel = null, prevBar = null;
    bars = new JProgressBar[SummaryItem.STATES.length];
    
    SpringLayout ls = new SpringLayout();
    JPanel appSummary = new JPanel();
    appSummary.setBorder(BorderFactory.createTitledBorder(
        BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "App Summary"));
    add(appSummary);
    l.putConstraint(SpringLayout.WEST, appSummary, 5, SpringLayout.WEST, this);
    l.putConstraint(SpringLayout.EAST, appSummary, -5, SpringLayout.EAST, this);
    l.putConstraint(SpringLayout.NORTH, appSummary, 25, SpringLayout.NORTH, this);
    
    appSummary.setLayout(ls);
    
    
    for (int i = 0; i < SummaryItem.STATES.length; i++) {
        JLabel label = new JLabel(SummaryItem.STATES[i] + ":");
        appSummary.add(label);
        
        JProgressBar lb = new JProgressBar();
        bars[i] = lb;
        lb.setString("0");
        lb.setStringPainted(true);
        appSummary.add(lb);
    
        fixEdges(ls, label, lb, appSummary);
        if (prevLabel == null) {
            ls.putConstraint(SpringLayout.NORTH, label, 5, SpringLayout.NORTH, appSummary);
        }
        else {
            ls.putConstraint(SpringLayout.NORTH, label, 10, SpringLayout.SOUTH, prevLabel);
        }
        prevLabel = label;
        prevBar = lb;
    }
    
    JLabel hl = new JLabel("Heap:");
    memory = makeProgress(l, hl);
    
    l.putConstraint(SpringLayout.SOUTH, appSummary, -25, SpringLayout.NORTH, hl);
    l.putConstraint(SpringLayout.SOUTH, hl, -25, SpringLayout.SOUTH, this);
    
    Spring maxW = Spring.constant(0);
    
    for (int i = 0; i < SummaryItem.STATES.length; i++) {
        maxW = Spring.max(maxW, ls.getConstraints(appSummary.getComponent(i * 2)).getWidth());
    }
    
    for (int i = 0; i < SummaryItem.STATES.length; i++) {
        SpringLayout.Constraints c = ls.getConstraints(appSummary.getComponent(i * 2));
        c.setWidth(maxW);
    }
}
 
開發者ID:swift-lang,項目名稱:swift-k,代碼行數:55,代碼來源:SummaryPanel.java

示例3: ExpanSearchFieldPanel

import javax.swing.Spring; //導入方法依賴的package包/類
public ExpanSearchFieldPanel(String name, int columns) {
  super();
  this.name = name;
  if (columns < MIN_COLUMNS) throw new IllegalArgumentException(this.getClass().getName() +" requires at least "+ MIN_COLUMNS +" columns");

  //this.setBorder(BorderFactory.createEtchedBorder(1));

  SpringLayout layout = new SpringLayout();
  this.setLayout(layout);

  JTextField dummyField = new JTextField(10);
  String[] fullSetNames = Prefs.textDat.getTextSetNames();
  String[] choices = new String[fullSetNames.length+1];
    choices[0] = "";
    for (int i=0; i < fullSetNames.length; i++) {
      String tmpFullName = fullSetNames[fullSetNames.length-1-i];
      choices[i+1] = Prefs.textDat.getSetAbbrevFromName(tmpFullName) +"-"+ tmpFullName;
    }

  componentsByColumn = new Component[columns];
  int currentCol = 0;
  nameLbl = new JLabel(this.name);
    componentsByColumn[currentCol++] = nameLbl;
    this.add(nameLbl);
  JPanel comboHolder = new JPanel(new GridBagLayout());
    GridBagConstraints gridC = new GridBagConstraints();
      gridC.fill = GridBagConstraints.HORIZONTAL;
      gridC.weightx = 1.0;
    expanCombo = new WideComboBox(choices);
      expanCombo.setEditable(true);
      expanCombo.setEditor(new ExpanSearchFieldEditor());
      expanCombo.setFont(dummyField.getFont());
      expanCombo.recachePopupWidth();
      expanCombo.setPreferredSize(dummyField.getPreferredSize());
      comboHolder.add(expanCombo, gridC);
    componentsByColumn[currentCol++] = comboHolder;
    this.add(comboHolder);
  JPanel typeHolder = new JPanel(new GridBagLayout());
    typeBtn = new RegexToggleButton();
      typeHolder.add(typeBtn);
    componentsByColumn[currentCol++] = typeHolder;
    this.add(typeHolder);
  for (int i=currentCol; i < columns; i++) {
    Component tmpComp = Box.createHorizontalStrut(0);
    componentsByColumn[i] = tmpComp;
    this.add(tmpComp);
  }

  // Find the tallest component and use that as a fixed value
  Spring height = Spring.constant(0);
  for (int i=0; i < componentsByColumn.length; i++) {
    height = Spring.max(height, layout.getConstraints(componentsByColumn[i]).getHeight());
  }
  height = Spring.constant(height.getValue());

  // Standardize the heights, base X pos on prev's East edge
  for (int i=0; i < componentsByColumn.length; i++) {
    SpringLayout.Constraints cons = layout.getConstraints(componentsByColumn[i]);
    cons.setHeight(height);
    cons.setY(SearchFieldPanel.PadY_Spring);
    if (i == 0) {
      cons.setX(SearchFieldPanel.PadX_Spring);
    } else {
      cons.setX(Spring.sum(Spring.constant(5), layout.getConstraint("East", componentsByColumn[i-1])));
    }
  }

  // Make this panel's preferred size depend on its contents
  SpringLayout.Constraints thisCons = layout.getConstraints(this);
    thisCons.setConstraint("East", Spring.sum(layout.getConstraint("East", componentsByColumn[componentsByColumn.length-1]), SearchFieldPanel.PadX_Spring));
    thisCons.setConstraint("South", Spring.sum(height, Spring.sum(SearchFieldPanel.PadY_Spring, SearchFieldPanel.PadY_Spring)));
}
 
開發者ID:Vhati,項目名稱:ArcanistCCG,代碼行數:73,代碼來源:ExpanSearchFieldPanel.java

示例4: populateFieldComponents

import javax.swing.Spring; //導入方法依賴的package包/類
private void populateFieldComponents() {
  filterLFields.removeAll();
  filterRFields.removeAll();

  DatParser textDat = Prefs.textDat;
  synchronized (textDat) {
    fieldPanels = Prefs.textDat.getSearchFieldPanels();
  }

  // Calc the left half's count
  int leftCount = (fieldPanels.length+1)/2;

  // Find the max column count among nested components
  int cols = 0;
  for (int i=0; i < fieldPanels.length; i++) {
    int n = fieldPanels[i].getMinColumnCount();
    if (n > cols) cols = n;
  }

  // For each half, standardize widths for each column
  int[] minRanges = new int[] {0, leftCount};
  int[] maxRanges = new int[] {leftCount, fieldPanels.length};
  for (int r=0; r < minRanges.length; r++) {
    for (int c=0; c < cols; c++) {
      Spring width = Spring.constant(0);
      for (int i=minRanges[r]; i < maxRanges[r]; i++) {
        width = Spring.max(width, fieldPanels[i].getSpringConstraintsForColumn(c).getWidth());
      }
      width = Spring.constant(width.getValue());
      for (int i=minRanges[r]; i < maxRanges[r]; i++) {
        fieldPanels[i].getSpringConstraintsForColumn(c).setWidth(width);
      }
    }
  }

  for (int i=0; i < fieldPanels.length; i++) {
    if (i < leftCount) {
      filterLFields.add(fieldPanels[i]);
    } else {
      filterRFields.add(fieldPanels[i]);
    }
  }

  if (leftCount > 0 && fieldPanels.length % 2 != 0) {
    filterRFields.add(Box.createVerticalStrut(fieldPanels[leftCount-1].getPreferredSize().height));
  }

  revalidate();
}
 
開發者ID:Vhati,項目名稱:ArcanistCCG,代碼行數:50,代碼來源:SearchPanel.java

示例5: ColorBarSearchFieldPanel

import javax.swing.Spring; //導入方法依賴的package包/類
public ColorBarSearchFieldPanel(String name, int columns) {
  super();
  this.name = name;
  if (columns < MIN_COLUMNS) throw new IllegalArgumentException(this.getClass().getName() +" requires at least "+ MIN_COLUMNS +" columns");

  //this.setBorder(BorderFactory.createEtchedBorder(1));

  SpringLayout layout = new SpringLayout();
  this.setLayout(layout);

  componentsByColumn = new Component[columns];
  int currentCol = 0;
  nameLbl = new JLabel(this.name);
    componentsByColumn[currentCol++] = nameLbl;
    this.add(nameLbl);
  JPanel colorHolder = new JPanel(new GridBagLayout());
    colorBar = new ColorBar();
      colorHolder.add(colorBar);
    componentsByColumn[currentCol++] = colorHolder;
    this.add(colorHolder);
  for (int i=currentCol; i < columns; i++) {
    Component tmpComp = Box.createHorizontalStrut(0);
    componentsByColumn[i] = tmpComp;
    this.add(tmpComp);
  }

  // Find the tallest component and use that as a fixed value
  Spring height = Spring.constant(0);
  for (int i=0; i < componentsByColumn.length; i++) {
    height = Spring.max(height, layout.getConstraints(componentsByColumn[i]).getHeight());
  }
  height = Spring.constant(height.getValue());

  // Standardize the heights, base X pos on prev's East edge
  for (int i=0; i < componentsByColumn.length; i++) {
    SpringLayout.Constraints cons = layout.getConstraints(componentsByColumn[i]);
    cons.setHeight(height);
    cons.setY(SearchFieldPanel.PadY_Spring);
    if (i == 0) {
      cons.setX(SearchFieldPanel.PadX_Spring);
    } else {
      cons.setX(Spring.sum(Spring.constant(5), layout.getConstraint("East", componentsByColumn[i-1])));
    }
  }

  // Make this panel's preferred size depend on its contents
  SpringLayout.Constraints thisCons = layout.getConstraints(this);
    thisCons.setConstraint("East", Spring.sum(layout.getConstraint("East", componentsByColumn[componentsByColumn.length-1]), SearchFieldPanel.PadX_Spring));
    thisCons.setConstraint("South", Spring.sum(height, Spring.sum(SearchFieldPanel.PadY_Spring, SearchFieldPanel.PadY_Spring)));
}
 
開發者ID:Vhati,項目名稱:ArcanistCCG,代碼行數:51,代碼來源:ColorBarSearchFieldPanel.java

示例6: TextSearchFieldPanel

import javax.swing.Spring; //導入方法依賴的package包/類
public TextSearchFieldPanel(String name, int columns) {
  super();
  this.name = name;
  if (columns < MIN_COLUMNS) throw new IllegalArgumentException(this.getClass().getName() +" requires at least "+ MIN_COLUMNS +" columns");

  //this.setBorder(BorderFactory.createEtchedBorder(1));

  SpringLayout layout = new SpringLayout();
  this.setLayout(layout);

  componentsByColumn = new Component[columns];
  int currentCol = 0;
  nameLbl = new JLabel(this.name);
    componentsByColumn[currentCol++] = nameLbl;
    this.add(nameLbl);
  JPanel textHolder = new JPanel(new GridBagLayout());
    GridBagConstraints gridC = new GridBagConstraints();
      gridC.fill = GridBagConstraints.HORIZONTAL;
      gridC.weightx = 1.0;
    textField = new JTextField(10);
      textHolder.add(textField, gridC);
    componentsByColumn[currentCol++] = textHolder;
    this.add(textHolder);
  JPanel typeHolder = new JPanel(new GridBagLayout());
    typeBtn = new RegexToggleButton();
      typeHolder.add(typeBtn);
    componentsByColumn[currentCol++] = typeHolder;
    this.add(typeHolder);
  for (int i=currentCol; i < columns; i++) {
    Component tmpComp = Box.createHorizontalStrut(0);
    componentsByColumn[i] = tmpComp;
    this.add(tmpComp);
  }

  // Find the tallest component and use that as a fixed value
  Spring height = Spring.constant(0);
  for (int i=0; i < componentsByColumn.length; i++) {
    height = Spring.max(height, layout.getConstraints(componentsByColumn[i]).getHeight());
  }
  height = Spring.constant(height.getValue());

  // Standardize the heights, base X pos on prev's East edge
  for (int i=0; i < componentsByColumn.length; i++) {
    SpringLayout.Constraints cons = layout.getConstraints(componentsByColumn[i]);
    cons.setHeight(height);
    cons.setY(SearchFieldPanel.PadY_Spring);
    if (i == 0) {
      cons.setX(SearchFieldPanel.PadX_Spring);
    } else {
      cons.setX(Spring.sum(Spring.constant(5), layout.getConstraint("East", componentsByColumn[i-1])));
    }
  }

  // Make this panel's preferred size depend on its contents
  SpringLayout.Constraints thisCons = layout.getConstraints(this);
    thisCons.setConstraint("East", Spring.sum(layout.getConstraint("East", componentsByColumn[componentsByColumn.length-1]), SearchFieldPanel.PadX_Spring));
    thisCons.setConstraint("South", Spring.sum(height, Spring.sum(SearchFieldPanel.PadY_Spring, SearchFieldPanel.PadY_Spring)));
}
 
開發者ID:Vhati,項目名稱:ArcanistCCG,代碼行數:59,代碼來源:TextSearchFieldPanel.java


注:本文中的javax.swing.Spring.constant方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。