Java Code Examples for javax.swing.Box#setPreferredSize()

The following examples show how to use javax.swing.Box#setPreferredSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReplayInfoBox.java    From sc2gears with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new ReplayInfoBox.
 * @param file replay file to be initially set.
 */
public ReplayInfoBox( final File file ) {
	final Box box = Box.createVerticalBox();
	box.setBorder( BorderFactory.createTitledBorder( Language.getText( "module.repAnalyzer.tab.gameInfo.title" ) ) );
	
	box.add( versionLabel );
	box.add( dateLabel );
	box.add( lengthLabel );
	box.add( speedLabel );
	box.add( typeLabel );
	box.add( formatLabel );
	box.add( gatewayLabel );
	box.add( mapLabel );
	box.add( playersLabel );
	box.add( mapPreviewLabel );
	
	box.setPreferredSize( new Dimension( 300, 440 ) );
	
	setViewportView( box );
	
	if ( file != null )
		setReplayFile( file );
}
 
Example 2
Source File: ConnectionSettingsUI.java    From LoboBrowser with MIT License 6 votes vote down vote up
private Component getProxyBox() {
  final Box radioBox = new Box(BoxLayout.Y_AXIS);
  radioBox.setPreferredSize(new Dimension(600, 200));
  radioBox.add(this.noProxyRadioButton);
  radioBox.add(this.httpProxyRadioButton);
  radioBox.add(this.socksProxyRadioButton);

  final Box radioBoxExpander = new Box(BoxLayout.X_AXIS);
  radioBoxExpander.add(radioBox);
  radioBoxExpander.add(Box.createGlue());

  final Box box = SwingTasks.createGroupBox(BoxLayout.Y_AXIS, "Proxy");
  box.add(radioBoxExpander);
  box.add(this.getProxyHostArea());
  return box;
}
 
Example 3
Source File: ConnectionSettingsUI.java    From LoboBrowser with MIT License 6 votes vote down vote up
private Component getProxyHostArea() {
  final Box checkBoxBox = new Box(BoxLayout.Y_AXIS);
  checkBoxBox.setPreferredSize(new Dimension(600, 200));
  checkBoxBox.add(this.bypassLocalCheckBox);
  checkBoxBox.add(this.authenticatedCheckBox);

  final Box checkBoxBoxExpander = new Box(BoxLayout.X_AXIS);
  checkBoxBoxExpander.add(checkBoxBox);
  checkBoxBoxExpander.add(Box.createHorizontalGlue());

  final Box box = this.proxyHostArea;
  box.setBorder(new EmptyBorder(8, 16, 8, 8));
  box.add(this.hostPortPanel);
  box.add(checkBoxBoxExpander);
  box.add(this.authenticationPanel);
  return box;
}
 
Example 4
Source File: SimpleTextEditDialog.java    From LoboBrowser with MIT License 5 votes vote down vote up
private Component createButtonPanel() {
  final Box panel = new Box(BoxLayout.X_AXIS);
  panel.setPreferredSize(new Dimension(Short.MAX_VALUE, 0));
  panel.setBorder(new EmptyBorder(4, 4, 4, 4));
  panel.add(Box.createGlue());
  panel.add(this.okButton);
  panel.add(Box.createRigidArea(new Dimension(4, 1)));
  panel.add(this.cancelButton);
  panel.add(Box.createGlue());
  return panel;
}
 
Example 5
Source File: StatusPanel.java    From swift-explorer with Apache License 2.0 5 votes vote down vote up
public StatusPanel(SwiftOperations ops, SwiftCallback callback) {
    super(new BorderLayout(0, 0));
    this.ops = ops;
    this.callback = callback;
    Box left = Box.createHorizontalBox();
    Box center = Box.createHorizontalBox();
    Box right = Box.createHorizontalBox();
    left.setBorder(BorderFactory.createEtchedBorder());
    right.setBorder(BorderFactory.createEtchedBorder());
    center.setBorder(BorderFactory.createEtchedBorder());
    center.setPreferredSize(new Dimension(320, 24));
    left.setPreferredSize(new Dimension(256, 24));
    //
    busyLabel = new JLabel();
    busyLabel.setPreferredSize(new Dimension(18, 18));
    right.add(busyLabel);
    //
    callCountLabel = new JLabel();
    callCountLabel.setPreferredSize(new Dimension(64, 18));
    right.add(Box.createHorizontalStrut(4));
    right.add(callCountLabel);
    right.add(Box.createHorizontalStrut(4));
    //
    this.add(left, BorderLayout.WEST);
    this.add(center, BorderLayout.CENTER);
    this.add(right, BorderLayout.EAST);
    //
    leftLabel = new JLabel("");
    left.add(Box.createHorizontalStrut(4));
    left.add(leftLabel);
    left.add(Box.createHorizontalStrut(8));
    //
    rightLabel = new JLabel("");
    center.add(Box.createHorizontalStrut(8));
    center.add(rightLabel);
    center.add(Box.createHorizontalStrut(4));
}
 
Example 6
Source File: GameInfoDialog.java    From petscii-bbs with Mozilla Public License 2.0 4 votes vote down vote up
private JComponent createInfoPanel(Resources resources) {
  
  StoryMetadata storyinfo = resources.getMetadata().getStoryInfo();
  Box infopanel = Box.createVerticalBox();
  infopanel.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
  JComponent panel = infopanel;
  
  // in case cover art is available, stack it into the info panel
  int coverartnum = getCoverartNum(resources);    
  if (coverartnum > 0 && resources.getImages().getNumResources() > 0) {

    Box wholepanel = Box.createHorizontalBox();
    wholepanel.add(createPicturePanel(resources, coverartnum));
    wholepanel.add(infopanel);
    panel = wholepanel;
  }
  
  infopanel.setAlignmentX(Component.LEFT_ALIGNMENT);
  infopanel.setPreferredSize(new Dimension(STD_WIDTH, 400));
  
  List<JLabel> labels = new ArrayList<JLabel>();
  labels.add(new JLabel(storyinfo.getTitle()));
  
  if (storyinfo.getHeadline() != null) {
    
    labels.add(new JLabel(storyinfo.getHeadline()));
  }
    
  labels.add(new JLabel(storyinfo.getAuthor() + " ("
      + storyinfo.getYear() + ")"));
      
  for (JLabel label : labels) {
    
    infopanel.add(label);
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    
    // Ensure that the label fonts are all bold
    label.setFont(label.getFont().deriveFont(Font.BOLD));
  }
  
  infopanel.add(Box.createVerticalStrut(6));
  
  JTextArea descarea = new JTextArea(storyinfo.getDescription());    
  descarea.setLineWrap(true);
  descarea.setWrapStyleWord(true);
  descarea.setEditable(false);
  Insets margins = new Insets(3, 3, 3, 3);
  descarea.setMargin(margins);
  descarea.setFont(labels.get(0).getFont().deriveFont(Font.PLAIN));
  
  JScrollPane spane = new JScrollPane(descarea);
  spane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  spane.setPreferredSize(new Dimension(STD_WIDTH, 200));
  spane.setAlignmentX(Component.LEFT_ALIGNMENT);
  infopanel.add(spane);
  return panel;
}
 
Example 7
Source File: SimpleBoxFormBuilder.java    From jdal with Apache License 2.0 4 votes vote down vote up
/**
 * Builds the panel form.
 * @return the form component
 */
public JComponent getForm() {
	// set sizes;
	int columnHeight= 0;
	for (int h : rowsHeight)
		columnHeight += h;
	
	// add space into components (fillers)
	columnHeight += (rows -1) * defaultSpace;
	
	for (int i = 0; i < columns.size(); i++) {
		Box box = columns.get(i);
		int maxWidth = columnsWidth.get(i) == 0 ? Short.MAX_VALUE : columnsWidth.get(i);
		box.setMaximumSize(new Dimension(maxWidth, columnHeight));
		
		if (maxWidth < Short.MAX_VALUE && columnHeight < Short.MAX_VALUE) {
			box.setMinimumSize(new Dimension(maxWidth, columnHeight));
			box.setPreferredSize(new Dimension(maxWidth, columnHeight));
		}
	}
	
	container.setFocusTraversalPolicy(focusTransversal);
	container.setFocusTraversalPolicyProvider(true);
	container.setSize(Short.MAX_VALUE, columnHeight);
	
	if (isFixedHeight()) {
		Dimension maxSize = new Dimension(Short.MAX_VALUE, columnHeight);
		
		if (container.isMaximumSizeSet()) {
			maxSize = container.getMaximumSize();
			maxSize.height = columnHeight;
		}
		
		container.setMaximumSize(maxSize);
	}
	
	if (isDebug())
		container.setBorder(BorderFactory.createLineBorder(Color.BLUE));
	
	if (border != null)
		container.setBorder(border);
	
	return container;
}