项目:RequestTool
文件:APIPanel.java
public void resize(){
layout.removeLayoutComponent(this);
layout.removeLayoutComponent(this.apiSelectLabel);
layout.removeLayoutComponent(this.apiSelectDropdown);
layout.putConstraint(SpringLayout.EAST,this,ViewUtils.WINDOW_WIDTH-30,SpringLayout.WEST,this);
layout.putConstraint(SpringLayout.soUTH,40,SpringLayout.norTH,this);
layout.putConstraint(SpringLayout.WEST,apiSelectLabel,Spring.constant(5,5,20),this);
layout.putConstraint(SpringLayout.norTH,Spring.constant(10,10,10),this);
layout.putConstraint(SpringLayout.EAST,apiSelectDropdown,ViewUtils.WINDOW_WIDTH - 350,apiSelectDropdown);
layout.putConstraint(SpringLayout.soUTH,30,apiSelectDropdown);
layout.putConstraint(SpringLayout.WEST,Spring.constant(20,20,SpringLayout.EAST,apiSelectLabel);
layout.putConstraint(SpringLayout.norTH,help,apiSelectDropdown);
layout.putConstraint(SpringLayout.norTH,this);
this.revalidate();
this.repaint();
}
项目:loni-dps-installer
文件:IntroductionPanel.java
private void initLayout() {
SpringLayout layout = new SpringLayout();
setLayout(layout);
add(introLabel);
layout.putConstraint(north,introLabel,panelMargin,north,this);
layout.putConstraint(west,west,this);
add(checkingLabel2);
layout.putConstraint(north,checkingLabel2,8 * panelMargin,introLabel);
layout.putConstraint(west,6 * panelMargin,this);
add(checkingLabel);
layout.putConstraint(north,checkingLabel,9 * panelMargin,this);
add(introScrollPane);
layout.getConstraints(introScrollPane).setConstraint(east,Spring.sum(Spring.constant(-panelMargin),layout.getConstraint(east,this)));
layout.getConstraints(introScrollPane).setConstraint(south,layout.getConstraint(south,this)));
layout.putConstraint(north,introScrollPane,vdist,south,introLabel);
}
项目:loni-dps-installer
文件:LicensePanel.java
private void initLayout() {
SpringLayout layout = new SpringLayout();
setLayout(layout);
add(licenseTitleLabel);
layout.putConstraint(north,licenseTitleLabel,this);
add(licenseScrollPane);
layout.getConstraints(licenseScrollPane).setConstraint(east,this)));
layout.getConstraints(licenseScrollPane).setConstraint(south,Spring.sum(Spring.constant(-vdist*2),layout.getConstraint(north,agreeButton)));
layout.putConstraint(north,licenseScrollPane,licenseTitleLabel);
layout.putConstraint(west,licenseTitleLabel);
add(agreeButton);
layout.putConstraint(south,agreeButton,-panelMargin,this);
layout.putConstraint(east,-panelMargin*6,east,this);
add(disagreeButton);
layout.putConstraint(south,disagreeButton,agreeButton);
layout.putConstraint(east,-panelMargin*2,agreeButton);
}
项目:RequestTool
文件:LoginPanel.java
public void resize(){
layout.removeLayoutComponent(this);
layout.removeLayoutComponent(this.loggedInButton);
layout.removeLayoutComponent(this.loginButton);
layout.removeLayoutComponent(this.loginNameLabel);
layout.removeLayoutComponent(this.loginNameTextfield);
layout.removeLayoutComponent(this.loginPasswordField);
layout.removeLayoutComponent(this.loginPasswordLabel);
layout.putConstraint(SpringLayout.EAST,loginNameLabel,loginNameTextfield,loginNameLabel);
layout.putConstraint(SpringLayout.norTH,loginPasswordLabel,loginNameTextfield);
layout.putConstraint(SpringLayout.norTH,loginPasswordField,loginPasswordLabel);
layout.putConstraint(SpringLayout.norTH,loginButton,loginPasswordField);
layout.putConstraint(SpringLayout.norTH,loggedInButton,loginButton);
layout.putConstraint(SpringLayout.norTH,this);
this.revalidate();
this.repaint();
}
项目:sheepit-client
文件:Working.java
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;
}
项目:loni-dps-installer
文件:SummaryPanel.java
private void initLayout() {
SpringLayout layout = new SpringLayout();
setLayout(layout);
add(titleLabel);
layout.putConstraint(north,titleLabel,this);
add(additionalActionsLabel);
layout.putConstraint(north,additionalActionsLabel,vdist * 3,titleLabel);
layout.putConstraint(west,this);
add(startPLConfigButton);
layout.putConstraint(north,startPLConfigButton,additionalActionsLabel);
layout.putConstraint(west,panelMargin * 3,this);
add(startPLServerCheckBox);
layout.putConstraint(north,startPLServerCheckBox,startPLConfigButton);
layout.putConstraint(west,this);
add(startPLClientCheckBox);
layout.putConstraint(north,startPLClientCheckBox,startPLServerCheckBox);
layout.putConstraint(west,startPLServerCheckBox);
add(testWorkflowsLabel);
layout.putConstraint(north,testWorkflowsLabel,startPLClientCheckBox);
layout.putConstraint(west,5 * dist,startPLClientCheckBox);
add(workflowsTableScrollPane);
//layout.getConstraints(workflowsTableScrollPane).setConstraint(east,Spring.sum(Spring.constant( -panelMargin ),this)));
layout.getConstraints(workflowsTableScrollPane).setConstraint(south,Spring.sum(Spring.constant( -vdist ),bottomNoteLabel)));
layout.putConstraint(north,workflowsTableScrollPane,testWorkflowsLabel);
layout.putConstraint(west,testWorkflowsLabel);
add(bottomNoteLabel);
layout.putConstraint(north,bottomNoteLabel,this);
}
项目:RequestTool
文件:View.java
public void resize(){
basicLayout.removeLayoutComponent(basic);
basicLayout.removeLayoutComponent(loginPanel);
basicLayout.removeLayoutComponent(sep1);
basicLayout.removeLayoutComponent(apiPanel);
basicLayout.removeLayoutComponent(sep2);
basicLayout.removeLayoutComponent(centralPanel);
basicLayout.removeLayoutComponent(sep3);
basicLayout.removeLayoutComponent(goPanel);
basicLayout.removeLayoutComponent(sep4);
basicLayout.removeLayoutComponent(progresspanel);
basicLayout.putConstraint(SpringLayout.EAST,basic,Spring.constant(0,ViewUtils.WINDOW_WIDTH,1200),basic);
basicLayout.putConstraint(SpringLayout.soUTH,ViewUtils.WINDOW_HEIGHT,basic);
basicLayout.putConstraint(SpringLayout.WEST,loginPanel,basic);
basicLayout.putConstraint(SpringLayout.norTH,basic);
// basicLayout.putConstraint(SpringLayout.WEST,sep1,basic);
// basicLayout.putConstraint(SpringLayout.norTH,50,basic);
// basicLayout.putConstraint(SpringLayout.EAST,apiPanel,65,sep2,100,centralPanel,120,sep3,SpringLayout.soUTH,centralPanel);
// basicLayout.putConstraint(SpringLayout.EAST,goPanel,centralPanel);
// basicLayout.putConstraint(SpringLayout.WEST,sep4,goPanel);
// basicLayout.putConstraint(SpringLayout.EAST,progresspanel,goPanel);
// basic.revalidate();
// this.repaint();
}
项目:swift-k
文件:SummaryPanel.java
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,this);
l.putConstraint(SpringLayout.EAST,-5,this);
l.putConstraint(SpringLayout.norTH,25,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,appSummary);
}
else {
ls.putConstraint(SpringLayout.norTH,prevLabel);
}
prevLabel = label;
prevBar = lb;
}
JLabel hl = new JLabel("Heap:");
memory = makeProgress(l,hl);
l.putConstraint(SpringLayout.soUTH,-25,hl);
l.putConstraint(SpringLayout.soUTH,hl,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);
}
}
项目:TailPlot
文件:LegendDragListener.java
/**
* Called when the mouse is dragged and the shift key is down.
* @param event the event
*/
private void mouseDragged(MouseEvent event) {
// How much we've moved from the original location
int deltaX = event.getXOnScreen() - screenX;
int deltaY = event.getYOnScreen() - screenY;
Container parent = legend.getParent();
SpringLayout layout = (SpringLayout) parent.getLayout();
layout.removeLayoutComponent(legend);
// The new location,in parent coordinates
int x = myX + deltaX;
int y = myY + deltaY;
// See if we snap to anything.
boolean snapLeft = false;
boolean snapRight = false;
boolean snapTop = false;
boolean snapBottom = false;
int legendWidth = legend.getWidth();
int legendHeight = legend.getHeight();
for(Component snapTo : this.snapTo) {
// Current location of the top left corner of the legend,in snapTo coordinates.
Point p = SwingUtilities.convertPoint(parent,x,y,snapTo);
if(!snapLeft && !snapRight) {
if(Math.abs(p.x) <= snapdist) {
snapLeft = true;
layout.putConstraint(SpringLayout.WEST,legend,snapTo);
x = SwingUtilities.convertPoint(snapTo,parent).x;
} else if(Math.abs(p.x + legendWidth - snapTo.getWidth()) <= snapdist) {
snapRight = true;
layout.putConstraint(SpringLayout.EAST,snapTo.getWidth() - legendWidth,parent).x;
}
}
if(!snapTop && !snapBottom) {
if(Math.abs(p.y) <= snapdist) {
snapTop = true;
layout.putConstraint(SpringLayout.norTH,snapTo);
y = SwingUtilities.convertPoint(snapTo,parent).y;
} else if(Math.abs(p.y + legendHeight - snapTo.getHeight()) <= snapdist) {
snapBottom = true;
layout.putConstraint(SpringLayout.soUTH,snapTo.getHeight() - legendHeight,parent).y;
}
}
}
// Set the location directly for immediate effect
legend.setLocation(x,y);
// Set the location in the layout so it stays where it was,percentagewise.
// In other words,if the center of the legend was 33% of the way from the left to the right of the parent,// it will remain 33% of the way from the left to the right of the parent even if the parent is resized.
Constraints constraints = layout.getConstraints(legend);
if(!snapTop && !snapBottom) {
float py = (y + legendHeight * .5f) / (float) parent.getHeight();
constraints.setConstraint(SpringLayout.VERTICAL_CENTER,Spring.scale(new HeightSpring(parent),py));
}
if(!snapLeft && !snapRight) {
float px = (x + legendWidth * .5f) / (float) parent.getWidth();
constraints.setConstraint(SpringLayout.HORIZONTAL_CENTER,Spring.scale(new WidthSpring(parent),px));
}
// Hide borders on the sides that have been snapped to.
Border outsideBorder = BorderFactory.createMatteBorder(snapTop ? 0 : 1,snapLeft ? 0 : 1,snapBottom ? 0 : 1,snapRight ? 0 : 1,Color.darkGray);
Border insideBorder = ((CompoundBorder) legend.getBorder()).getInsideBorder();
legend.setBorder(BorderFactory.createCompoundBorder(outsideBorder,insideBorder));
}
项目:loni-dps-installer
文件:ServerInstallerFrame.java
private void displaySteps() {
setNextEnabled(false);
StringBuilder sb = new StringBuilder("<html><br><br>");
int counter = 1;
for(String s : stepsList) {
sb.append("<font color=\"");
if(counter < currentStepIndex) {
if (stepsPanelList.get(counter - 1) instanceof ServerConfigurationPanel) {
if (!Boolean.parseBoolean(Configuration.getConfig(Configuration.CONfig_INSTALL_PIPELINE)) )
sb.append("gray");
} else if (stepsPanelList.get(counter - 1) instanceof SGEConfigurationPanel ) {
if (!Boolean.parseBoolean(Configuration.getConfig(Configuration.CONfig_INSTALL_SGE)) )
sb.append("gray");
} else if (stepsPanelList.get(counter - 1) instanceof NIToolsConfigurationPanel ) {
if (!Boolean.parseBoolean(Configuration.getConfig(Configuration.CONfig_INSTALL_NI_TOOLS)) )
sb.append("gray");
} else if (stepsPanelList.get(counter - 1) instanceof Bio@R_479_4045@icsToolsConfigurationPanel ) {
if (!Boolean.parseBoolean(Configuration.getConfig(Configuration.CONfig_INSTALL_BI_TOOLS)) )
sb.append("gray");
} else sb.append("darkGray");
} else if ( counter == currentStepIndex ) {
sb.append("#273791");
} else {
sb.append("gray");
}
sb.append("\">");
if ( counter == currentStepIndex )
sb.append("<b>");
sb.append(counter);
sb.append(". ");
sb.append(s);
if ( counter == currentStepIndex )
sb.append("</b>");
sb.append("</font><br><br>");
counter++;
}
sb.append("</html>");
stepsLabel.setText(sb.toString());
if(currentPanel!=null)
remove(currentPanel);
AbstractStepPanel panel = stepsPanelList.get(currentStepIndex-1);
add(panel);
layout.getConstraints(panel).setConstraint(south,Spring.sum(Spring.constant(-vdist),helpButton)));
layout.getConstraints(panel).setConstraint(east,getContentPane())));
layout.putConstraint(north,panel,topSeparator);
layout.putConstraint(west,dist,sideSeparator);
currentPanel = panel;
panel.panelActivated();
validate();
repaint();
}
项目:loni-dps-installer
文件:ServerInstallerFrame.java
private void initLayout() {
layout = new SpringLayout();
this.setLayout(layout);
Container pane = this.getContentPane();
add(titleIconLabel);
layout.putConstraint(north,titleIconLabel,pane);
layout.putConstraint(west,panelMargin*2,pane);
add(titleLabel);
layout.putConstraint(south,-2 * vdist,titleIconLabel);
layout.putConstraint(west,topSeparator);
add(subTitleLabel);
layout.putConstraint(south,subTitleLabel,versionLabel);
layout.putConstraint(east,-dist * 2,versionLabel);
add(versionLabel);
layout.putConstraint(south,versionLabel,-dist,topSeparator);
layout.putConstraint(east,pane);
add(topSeparator);
layout.getConstraints(topSeparator).setConstraint(east,pane)));
layout.putConstraint(north,topSeparator,sideSeparator);
add(stepsLabel);
layout.putConstraint(north,stepsLabel,pane);
add(sideSeparator);
layout.getConstraints(sideSeparator).setConstraint(south,helpButton)));
layout.putConstraint(north,sideSeparator,stepsLabel);
add(copyrightLabel);
layout.putConstraint(south,copyrightLabel,pane);
add(helpButton);
layout.putConstraint(south,helpButton,copyrightLabel);
layout.putConstraint(west,pane);
add(cancelButton);
layout.putConstraint(south,cancelButton,helpButton);
layout.putConstraint(east,backButton);
add(finishButton);
layout.putConstraint(south,finishButton,pane);
add(nextButton);
layout.putConstraint(south,nextButton,-dist*2,finishButton);
add(backButton);
layout.putConstraint(south,backButton,nextButton);
}
private void initLayout() {
SpringLayout layout = new SpringLayout();
setLayout(layout);
add(titleLabel);
layout.putConstraint(north,this);
add(topSeparator);
layout.getConstraints(topSeparator).setConstraint(east,this);
add(sideSeparator);
layout.getConstraints(sideSeparator).setConstraint(south,this));
layout.putConstraint(north,2 * vdist,15 * dist,titleLabel);
add(sgeLocationLabel);
layout.putConstraint(north,sgeLocationLabel,sideSeparator);
layout.putConstraint(west,4 * dist,titleLabel);
add(sgeLocationField);
layout.putConstraint(north,sgeLocationField,sgeLocationLabel);
layout.putConstraint(west,sgeLocationLabel);
add(sgeClusterLabel);
layout.putConstraint(north,sgeClusterLabel,sgeLocationField);
layout.putConstraint(west,sgeLocationLabel);
add(sgeClusterField);
layout.putConstraint(north,sgeClusterField,sgeClusterLabel);
layout.putConstraint(west,sgeLocationLabel);
add(sgeSpoolDirLabel);
layout.putConstraint(north,sgeSpoolDirLabel,sgeClusterField);
layout.putConstraint(west,sgeLocationLabel);
add(sgeSpoolDirField);
layout.putConstraint(north,sgeSpoolDirField,sgeSpoolDirLabel);
layout.putConstraint(west,sgeLocationLabel);
add(sgeAdminCheckBox);
layout.putConstraint(north,sgeAdminCheckBox,sgeSpoolDirField);
layout.putConstraint(west,sgeLocationLabel);
add(sgeAdminLabel);
layout.putConstraint(north,sgeAdminLabel,sgeAdminCheckBox);
layout.putConstraint(west,sgeLocationLabel);
add(sgeAdminField);
layout.putConstraint(north,sgeAdminField,sgeAdminLabel);
layout.putConstraint(west,sgeLocationLabel);
add(sgeAdminWarningArea);
layout.putConstraint(north,sgeAdminWarningArea,vdist / 2,sgeAdminField);
layout.getConstraints(sgeAdminWarningArea).setConstraint(east,Spring.sum(Spring.constant(-dist),layout.getConstraint(west,sideSeparator)));
layout.putConstraint(west,sgeLocationLabel);
add(sgeExecHostsLabel);
layout.putConstraint(north,sgeExecHostsLabel,sideSeparator);
add(sgeExecHostsScrollPane);
layout.getConstraints(sgeExecHostsScrollPane).setConstraint(east,this)));
layout.getConstraints(sgeExecHostsScrollPane).setConstraint(south,sgeExecHostsExampleScrollPane)));
layout.putConstraint(north,sgeExecHostsScrollPane,sgeExecHostsLabel);
layout.putConstraint(west,sgeExecHostsLabel);
add(sgeExecHostsExampleScrollPane);
layout.getConstraints(sgeExecHostsExampleScrollPane).setConstraint(east,this)));
layout.getConstraints(sgeExecHostsExampleScrollPane).setConstraint(south,this)));
layout.putConstraint(west,sgeExecHostsExampleScrollPane,sgeExecHostsLabel);
add(validatingHostsLabel);
layout.putConstraint(north,validatingHostsLabel,sgeExecHostsScrollPane);
layout.putConstraint(west,sgeExecHostsScrollPane);
}
private void initLayout() {
SpringLayout layout = new SpringLayout();
setLayout(layout);
add(titleLabel);
layout.putConstraint(north,this);
add(fsPathLabel);
layout.putConstraint(north,fsPathLabel,dist * 4,titleLabel);
add(fsPathField);
layout.putConstraint(north,fsPathField,fsPathLabel);
layout.putConstraint(west,fsPathLabel);
add(fsPathbrowseButton);
layout.putConstraint(north,fsPathbrowseButton,fsPathLabel);
layout.getConstraints(fsPathbrowseButton).setConstraint(east,fsPathField);
add(middleSeparator);
layout.getConstraints(middleSeparator).setConstraint(east,middleSeparator,fsPathbrowseButton);
layout.putConstraint(west,this);
add(selectComponentsLabel);
layout.putConstraint(north,selectComponentsLabel,vdist * 2,middleSeparator);
layout.putConstraint(west,this);
add(pipelineCheckBox);
layout.putConstraint(north,pipelineCheckBox,selectComponentsLabel);
layout.putConstraint(west,fsPathLabel);
add(pipelineDescription);
layout.putConstraint(north,pipelineDescription,pipelineCheckBox);
layout.putConstraint(west,dist * 5,pipelineCheckBox);
add(sgeCheckBox);
layout.putConstraint(north,sgeCheckBox,pipelineDescription);
layout.putConstraint(west,pipelineCheckBox);
add(sgeDescription);
layout.putConstraint(north,sgeDescription,sgeCheckBox);
layout.putConstraint(west,pipelineCheckBox);
add(niToolsCheckBox);
layout.putConstraint(north,niToolsCheckBox,sgeDescription);
layout.putConstraint(west,pipelineCheckBox);
add(niToolsDescription);
layout.putConstraint(north,niToolsDescription,niToolsCheckBox);
layout.putConstraint(west,pipelineCheckBox);
add(biToolsCheckBox);
layout.putConstraint(north,biToolsCheckBox,niToolsDescription);
layout.putConstraint(west,pipelineCheckBox);
add(biToolsDescription);
layout.putConstraint(north,biToolsDescription,biToolsCheckBox);
layout.putConstraint(west,pipelineCheckBox);
add(bottomSeparator);
layout.getConstraints(bottomSeparator).setConstraint(east,this)));
layout.putConstraint(south,bottomSeparator,this);
}
private void initLayout() {
SpringLayout layout = new SpringLayout();
setLayout(layout);
add(titleLabel);
layout.putConstraint(north,this);
add(executablesCheckBox);
layout.putConstraint(north,executablesCheckBox,this);
add(serverLibCheckBox);
layout.putConstraint(north,serverLibCheckBox,executablesCheckBox);
layout.putConstraint(west,this);
add(serverPrefsLabel);
layout.putConstraint(north,serverPrefsLabel,serverLibCheckBox);
layout.putConstraint(west,serverLibCheckBox);
add(serverPrefsField);
layout.putConstraint(north,serverPrefsField,serverPrefsLabel);
add(serverPrefsbrowseButton);
layout.putConstraint(north,serverPrefsbrowseButton,serverPrefsField);
add(toolsDescLabel);
layout.putConstraint(north,toolsDescLabel,serverPrefsbrowseButton);
layout.putConstraint(west,this);
add(toolsTableScrollPane);
layout.getConstraints(toolsTableScrollPane).setConstraint(east,this)));
layout.getConstraints(toolsTableScrollPane).setConstraint(south,totalSizeLabel)));
layout.putConstraint(north,toolsTableScrollPane,toolsDescLabel);
layout.putConstraint(west,toolsDescLabel);
add(totalSizeLabel);
layout.putConstraint(south,totalSizeLabel,-vdist,descriptionTextArea);
layout.putConstraint(east,toolsTableScrollPane);
add(descriptionTextArea);
layout.getConstraints(descriptionTextArea).setConstraint(east,descriptionTextArea,toolLocationLabel);
layout.putConstraint(west,toolsTableScrollPane);
add(toolLocationLabel);
layout.putConstraint(south,toolLocationLabel,this);
}
项目:ArcanistCCG
文件:ExpanSearchFieldPanel.java
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)));
}
项目:ArcanistCCG
文件:SearchPanel.java
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();
}
项目:ArcanistCCG
文件:ColorBarSearchFieldPanel.java
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,SearchFieldPanel.PadY_Spring)));
}
项目:ArcanistCCG
文件:TextSearchFieldPanel.java
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,SearchFieldPanel.PadY_Spring)));
}
项目:RequestTool
文件:GoPanel.java
public void resize(){
settingsWindow.setLocationRelativeto(settings);
layout.removeLayoutComponent(this);
layout.removeLayoutComponent(this.go);
layout.putConstraint(SpringLayout.EAST,this.currentFile,5),this.currentFileTextField,this.currentFile);
layout.putConstraint(SpringLayout.norTH,this.browse,this.currentFileTextField);
layout.putConstraint(SpringLayout.norTH,this.settings,this.browse);
layout.putConstraint(SpringLayout.norTH,this.go,Spring.constant(-10,-10,-10),this);
this.revalidate();
this.repaint();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。