Java Code Examples for javax.swing.JComponent#setLayout()

The following examples show how to use javax.swing.JComponent#setLayout() . 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: SearchDialog.java    From LoboBrowser with MIT License 6 votes vote down vote up
public SearchDialog(final Frame owner, final boolean modal, final String keywordsTooltip) throws HeadlessException {
  super(owner, modal);
  this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  this.tagsField.setToolTip(keywordsTooltip);
  final Container contentPane = this.getContentPane();
  contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
  final FormPanel fieldsPanel = new FormPanel();
  fieldsPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
  fieldsPanel.addField(this.tagsField);
  contentPane.add(fieldsPanel);
  final JComponent buttonsPanel = new JPanel();
  buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));
  final JButton okButton = new JButton();
  okButton.setAction(new OkAction());
  okButton.setText("Search");
  final JButton cancelButton = new JButton();
  cancelButton.setAction(new CancelAction());
  cancelButton.setText("Cancel");
  buttonsPanel.add(Box.createHorizontalGlue());
  buttonsPanel.add(okButton);
  buttonsPanel.add(Box.createRigidArea(new Dimension(4, 1)));
  buttonsPanel.add(cancelButton);
  buttonsPanel.add(Box.createHorizontalGlue());
  contentPane.add(buttonsPanel);
  contentPane.add(Box.createRigidArea(new Dimension(1, 4)));
}
 
Example 2
Source File: ViewModelListener.java    From netbeans with Apache License 2.0 6 votes vote down vote up
ViewModelListener(
    String viewType,
    JComponent view,
    JComponent buttonsPane,
    String propertiesHelpID,
    Image viewIcon
) {
    this.viewType = viewType;
    this.view = view;
    this.buttonsPane = buttonsPane;
    buttonsPane.setLayout(new GridBagLayout());
    this.propertiesHelpID = propertiesHelpID;
    this.viewIcon = viewIcon;
    initView();
    setUp();
}
 
Example 3
Source File: DefaultPlugin.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 */
private static JComponent wrapDialogContent(JComponent comp,
                                            boolean selfResizing) {
    JComponent result;
    
    if ((comp.getBorder() != null) || selfResizing) {
        result = selfResizing ? new SelfResizingPanel() : new JPanel();
        result.setLayout(new GridLayout());
        result.add(comp);
    } else {
        result = comp;
    }
    result.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
    result.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_title_select_generator"));
    return result;
}
 
Example 4
Source File: XPOpenLocationPaneUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
protected void installGUI(JComponent comp) {
	comp.removeAll();
	comp.setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.weightx = 0;
	c.weighty = 0;
	c.anchor = GridBagConstraints.EAST;
	c.insets = new Insets(5, 5, 5, 5);
	comp.add(new JLabel("Look In:"), c);
	c.gridx++;
	c.weightx = 1;
	c.fill = GridBagConstraints.HORIZONTAL;
	comp.add(new XPDirectoryControls(this), c);

	c.gridy++;
	c.gridx = 0;
	c.weightx = 0;
	c.fill = GridBagConstraints.BOTH;
	c.gridheight = GridBagConstraints.REMAINDER;
	JPanel sidebar = new JPanel();
	sidebar.setBackground(Color.lightGray);
	sidebar.setOpaque(true);
	comp.add(sidebar, c);

	c.gridx++;
	c.fill = GridBagConstraints.BOTH;
	c.weighty = 1;
	c.weightx = 1;
	c.gridheight = 1;
	comp.add(browser, c);

	c.gridy++;
	c.weighty = 0;
	comp.add(new FileControls(), c);
}
 
Example 5
Source File: SBoxLayout.java    From stendhal with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A convenience method for creating a container using SBoxLayout.
 *
 * @param direction layout direction
 * @return A component using SBoxLayout
 */
public static JComponent createContainer(boolean direction) {
	JComponent container = new Spring();
	container.setLayout(new SBoxLayout(direction));

	return container;
}
 
Example 6
Source File: ConstantVoltageExample.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public static JComponent createComponent() {
    JComponent container = new JPanel();
    container.setLayout(new BoxLayout(container, BoxLayout.LINE_AXIS));
    
    Chart chart1 = createChart("Voltage", 550, 450, LegendPosition.InsideNE, true);
    Chart chart2 = createChart("Error Covariance", 450, 450, LegendPosition.InsideNE, false);
    
    constantVoltageTest(chart1, chart2);

    container.add(new XChartPanel(chart1));
    container.add(new XChartPanel(chart2));
    
    container.setBorder(BorderFactory.createLineBorder(Color.black, 1));
    return container;
}
 
Example 7
Source File: CannonballExample.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public static JComponent createComponent() {
    JComponent container = new JPanel();
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));

    Chart chart = createChart("Cannonball", LegendPosition.InsideNE);
    cannonballTest(chart);
    container.add(new XChartPanel(chart));
    
    container.setBorder(BorderFactory.createLineBorder(Color.black, 1));
    return container;
}
 
Example 8
Source File: TileLocationBrowserUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
protected void installGUI(JComponent comp) {
	comp.setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.weightx = 1;
	c.weighty = 1;
	c.fill = GridBagConstraints.NONE;
	c.anchor = GridBagConstraints.CENTER;
	c.fill = GridBagConstraints.BOTH;
	comp.add(scrollPane, c);
}
 
Example 9
Source File: ConstantVoltageExample.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public static JComponent createComponent() {
    JComponent container = new JPanel();
    container.setLayout(new BoxLayout(container, BoxLayout.LINE_AXIS));
    
    Chart chart1 = createChart("Voltage", 550, 450, LegendPosition.InsideNE, true);
    Chart chart2 = createChart("Error Covariance", 450, 450, LegendPosition.InsideNE, false);
    
    constantVoltageTest(chart1, chart2);

    container.add(new XChartPanel(chart1));
    container.add(new XChartPanel(chart2));
    
    container.setBorder(BorderFactory.createLineBorder(Color.black, 1));
    return container;
}
 
Example 10
Source File: CreatureAnimationPreview.java    From stendhal with GNU General Public License v2.0 5 votes vote down vote up
private CreatureAnimationPreview() {
	jFrame.setSize(new Dimension(818, 470));
	JScrollPane scroll = new JScrollPane();
	scroll.setViewportView(createJTree());
	split.setLeftComponent(scroll);

	JPanel rightPanel = new JPanel();
	JComponent row = new JComponent() {};
	row.setLayout(new BoxLayout(row, BoxLayout.X_AXIS));
	rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.Y_AXIS));

	for (int i = 0; i < NUMBER_OF_ROWS; i++) {
		JLabel l = new JLabel();
		animationPanel[i] = l;
		animations[i] = new AnimationRunner(l);
		row.add(l);
	}

	rightPanel.add(row);
	rightPanel.add(mainPanel);

	split.setRightComponent(rightPanel);
	jFrame.setContentPane(split);
	jFrame.setTitle("animated Monsters test");
	jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	jFrame.setVisible(true);
}
 
Example 11
Source File: GroovyJUnitTestWizard.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static JComponent wrapDialogContent(JComponent comp) {
    JComponent result;

    result = new SelfResizingPanel();
    result.setLayout(new GridLayout());
    result.add(comp);
    result.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
    result.getAccessibleContext().setAccessibleDescription(BUNDLE.getString("AD_title_select_generator")); //NOI18N
    return result;
}
 
Example 12
Source File: AbstractViewTabDisplayerUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void installUI(JComponent c) {
    super.installUI(c);
    ToolTipManager.sharedInstance().registerComponent(displayer);
    controller = createController();
    dataModel = displayer.getModel();
    dataModel.addChangeListener (controller);
    dataModel.addComplexListDataListener(controller);
    layoutModel = createLayoutModel();
    if( !Boolean.getBoolean("winsys.non_stretching_view_tabs") && !isUseStretchingTabs() ) {
        btnMinimizeMode = TabControlButtonFactory.createSlideGroupButton( displayer );
        c.setLayout( new PinButtonLayout() );
    }
    displayer.addPropertyChangeListener (controller);
    selectionModel.addChangeListener (controller);
    displayer.addMouseListener(controller);
    displayer.addMouseMotionListener(controller);
    installControlButtons();
    dataModel.addChangeListener( new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            showHideControlButtons();
            if( null != dataModel )
                dataModel.removeChangeListener( this );
        }
    });
    showHideControlButtons();
}
 
Example 13
Source File: EmptyTestStepLocation.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Component createVisualComp() {
    JCheckBox[] chkBoxes;
    
    JComponent optCode = GuiUtils.createChkBoxGroup(
            NbBundle.getMessage(
                    GuiUtils.class,
                    "CommonTestsCfgOfCreate.groupOptCode"),               //NOI18N
            chkBoxes = GuiUtils.createCheckBoxes(new String[] {
                    GuiUtils.CHK_SETUP,
                    GuiUtils.CHK_TEARDOWN,
                    GuiUtils.CHK_BEFORE_CLASS,
                    GuiUtils.CHK_AFTER_CLASS}));
    chkSetUp = chkBoxes[0];
    chkTearDown = chkBoxes[1];
    chkBeforeClass = chkBoxes[2];
    chkAfterClass = chkBoxes[3];
    
    JComponent optComments = GuiUtils.createChkBoxGroup(
            NbBundle.getMessage(
                    GuiUtils.class,
                    "CommonTestsCfgOfCreate.groupOptComments"),           //NOI18N
            chkBoxes = GuiUtils.createCheckBoxes(new String[] {
                    GuiUtils.CHK_HINTS}));
    chkCodeHints = chkBoxes[0];

    JComponent box = new SelfResizingPanel();
    box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
    box.add(optCode);
    box.add(Box.createHorizontalStrut(18));
    box.add(optComments);

    /* tune layout of the components within the box: */
    optCode.setAlignmentY(0.0f);
    optComments.setAlignmentY(0.0f);

    return box;
}
 
Example 14
Source File: PreviewDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void init() {
  setDefaultCloseOperation( JDialog.DISPOSE_ON_CLOSE );

  addComponentListener( new RequestFocusHandler() );
  messages =
      new Messages( getLocale(), SwingPreviewModule.BUNDLE_NAME, ObjectUtilities
          .getClassLoader( SwingPreviewModule.class ) );

  previewPane = new PreviewPane();
  previewPane.setDeferredRepagination( true );
  addComponentListener( new TriggerPaginationListener( previewPane ) );

  statusBar = new JStatusBar( previewPane.getIconTheme() );

  pageLabel = new JLabel();

  final Configuration configuration = ClassicEngineBoot.getInstance().getGlobalConfig();
  final boolean progressBarEnabled = "true".equals( configuration //$NON-NLS-1$
      .getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.gui.base.ProgressBarEnabled" ) ); //$NON-NLS-1$
  final boolean progressDialogEnabled = "true".equals( configuration //$NON-NLS-1$
      .getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.gui.base.ProgressDialogEnabled" ) ); //$NON-NLS-1$

  if ( progressBarEnabled ) {
    progressBar = new ReportProgressBar();
    progressBar.setVisible( false );
    previewPane.addReportProgressListener( progressBar );
    previewPane.addPropertyChangeListener( new PreviewPanePropertyChangeHandler() );
  } else {
    progressBar = null;
  }

  if ( progressDialogEnabled ) {
    progressDialog = new ReportProgressDialog( this );
    final MasterReport reportJob = previewPane.getReportJob();
    if ( reportJob == null || reportJob.getTitle() == null ) {
      progressDialog.setTitle( messages.getString( "ProgressDialog.EMPTY_TITLE" ) );
      progressDialog.setMessage( messages.getString( "ProgressDialog.EMPTY_TITLE" ) );
    } else {
      progressDialog.setTitle( messages.getString( "ProgressDialog.TITLE", reportJob.getTitle() ) );
      progressDialog.setMessage( messages.getString( "ProgressDialog.TITLE", reportJob.getTitle() ) );
    }
    progressDialog.pack();
  } else {
    progressDialog = null;
  }

  final JComponent extensionArea = statusBar.getExtensionArea();
  extensionArea.setLayout( new BoxLayout( extensionArea, BoxLayout.X_AXIS ) );
  if ( progressBar != null ) {
    extensionArea.add( progressBar );
  }
  extensionArea.add( pageLabel );

  final JComponent contentPane = new JPanel();
  contentPane.setLayout( new BorderLayout() );
  contentPane.add( previewPane, BorderLayout.CENTER );
  contentPane.add( statusBar, BorderLayout.SOUTH );
  setContentPane( contentPane );

  updateMenu( previewPane.getMenu() );
  setTitle( previewPane.getTitle() );
  statusBar.setIconTheme( previewPane.getIconTheme() );
  statusBar.setStatus( previewPane.getStatusType(), previewPane.getStatusText() );
}
 
Example 15
Source File: PreviewFrame.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void init() {
  addComponentListener( new RequestFocusHandler() );

  messages =
      new Messages( getLocale(), SwingPreviewModule.BUNDLE_NAME, ObjectUtilities
          .getClassLoader( SwingPreviewModule.class ) );
  previewPane = new PreviewPane();
  previewPane.setDeferredRepagination( true );
  addComponentListener( new TriggerPaginationListener( previewPane ) );
  statusBar = new JStatusBar( previewPane.getIconTheme() );

  pageLabel = new JLabel();
  previewPane.addPropertyChangeListener( new PreviewPanePropertyChangeHandler() );

  final Configuration configuration = ClassicEngineBoot.getInstance().getGlobalConfig();
  final boolean progressBarEnabled = "true".equals( configuration //$NON-NLS-1$
      .getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.gui.base.ProgressBarEnabled" ) ); //$NON-NLS-1$
  final boolean progressDialogEnabled = "true".equals( configuration //$NON-NLS-1$
      .getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.gui.base.ProgressDialogEnabled" ) ); //$NON-NLS-1$

  if ( progressBarEnabled ) {
    progressBar = new ReportProgressBar();
    progressBar.setVisible( false );
    previewPane.addReportProgressListener( progressBar );
    previewPane.addPropertyChangeListener( new PreviewPanePropertyChangeHandler() );
  } else {
    progressBar = null;
  }

  if ( progressDialogEnabled ) {
    progressDialog = new ReportProgressDialog( this );
    final MasterReport reportJob = previewPane.getReportJob();
    if ( reportJob == null || reportJob.getTitle() == null ) {
      progressDialog.setTitle( messages.getString( "ProgressDialog.EMPTY_TITLE" ) );
      progressDialog.setMessage( messages.getString( "ProgressDialog.EMPTY_TITLE" ) );
    } else {
      progressDialog.setTitle( messages.getString( "ProgressDialog.TITLE", reportJob.getTitle() ) );
      progressDialog.setMessage( messages.getString( "ProgressDialog.TITLE", reportJob.getTitle() ) );
    }
    progressDialog.pack();
  } else {
    progressDialog = null;
  }

  final JComponent extensionArea = statusBar.getExtensionArea();
  extensionArea.setLayout( new BoxLayout( extensionArea, BoxLayout.X_AXIS ) );
  if ( progressBar != null ) {
    extensionArea.add( progressBar );
  }
  extensionArea.add( pageLabel );

  final JComponent contentPane = new JPanel();
  contentPane.setLayout( new BorderLayout() );
  contentPane.add( previewPane, BorderLayout.CENTER );
  contentPane.add( statusBar, BorderLayout.SOUTH );
  setContentPane( contentPane );

  updateMenu( previewPane.getMenu() );
  setTitle( previewPane.getTitle() );
  statusBar.setIconTheme( previewPane.getIconTheme() );
  statusBar.setStatus( previewPane.getStatusType(), previewPane.getStatusText() );
}
 
Example 16
Source File: AquaOpenLocationPaneUI.java    From pumpernickel with MIT License 4 votes vote down vote up
@Override
protected void installGUI(JComponent panel) {
	panel.addPropertyChangeListener(KEY_INCLUDE_SIDEBAR,
			propertyChangeListener);

	if (sourceList.isEmpty()) {
		File[] array1 = CommonFiles.getUserDirectories(true);
		IOLocation[] array2 = new FileLocation[array1.length];
		for (int a = 0; a < array1.length; a++) {
			array2[a] = LocationFactory.get().create(array1[a]);
		}
		sourceList.add(array2);
	}

	boolean includeSidebar = getBoolean(locationPane, KEY_INCLUDE_SIDEBAR,
			true);
	boolean includeFooter = getBoolean(locationPane, KEY_INCLUDE_FOOTER,
			true);

	panel.removeAll();
	panel.setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.weightx = 1;
	c.weighty = 0;
	c.fill = GridBagConstraints.HORIZONTAL;
	c.insets = new Insets(4, 0, 4, 0);
	panel.add(controls, c);
	c.gridy++;
	c.weighty = 1;
	c.fill = GridBagConstraints.BOTH;

	if (includeSidebar) {
		splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
				sourceListScrollPane, browser);
		panel.add(splitPane, c);
	} else {
		panel.add(browser, c);
	}

	if (includeFooter) {
		c.weighty = 0;
		c.gridy++;
		panel.add(footer, c);
	}
	sourceListScrollPane.setMinimumSize(new Dimension(100, 40));
	sourceListScrollPane.setPreferredSize(new Dimension(150, 40));
}
 
Example 17
Source File: JTextDrawingObjectDialog.java    From openchemlib-js with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void init(Component owner) {
      mComboBoxTextSize = new JComboBox(TEXT_SIZE_LIST);
mComboBoxTextSize.setEditable(true);
mComboBoxTextSize.setSelectedItem(""+(int)mTextObject.getSize());

      mComboBoxStyle = new JComboBox(TEXT_STYLE_LIST);
int styleIndex = 0;
for (int i=0; i<TEXT_STYLE.length; i++) {
	if (mTextObject.getStyle() == TEXT_STYLE[i]) {
		styleIndex = i;
		break;
		}
	}
mComboBoxStyle.setSelectedIndex(styleIndex);

JComponent menuPanel = new JPanel();
double[][] size = { { 8, TableLayout.PREFERRED, 4, TableLayout.PREFERRED, 8 },
					{ 8, TableLayout.PREFERRED, 4, TableLayout.PREFERRED, 8 } };
menuPanel.setLayout(new TableLayout(size));

menuPanel.add(new JLabel("Text size:"), "1,1");
menuPanel.add(mComboBoxTextSize, "3,1");
menuPanel.add(new JLabel("Text style:"), "1,3");
menuPanel.add(mComboBoxStyle, "3,3");

mTextArea = new JTextArea(mTextObject.getText(), 3, 20);
      mTextArea.setBorder(BorderFactory.createEtchedBorder());
JPanel textPanel = new JPanel();
      textPanel.setBorder(BorderFactory.createEmptyBorder(0,4,0,4));
textPanel.add(mTextArea);

JButton buttonOK = new JButton("OK");
buttonOK.addActionListener(this);
JButton buttonCancel = new JButton("Cancel");
buttonCancel.addActionListener(this);
JPanel innerButtonPanel = new JPanel();
      innerButtonPanel.setLayout(new GridLayout(1,2,8,0));
      innerButtonPanel.add(buttonCancel);
      innerButtonPanel.add(buttonOK);
      innerButtonPanel.setBorder(BorderFactory.createEmptyBorder(8,8,8,8));
JPanel buttonPanel = new JPanel();
      buttonPanel.setLayout(new BorderLayout());
      buttonPanel.add(innerButtonPanel, BorderLayout.EAST);

getContentPane().setLayout(new BorderLayout());
getContentPane().add(menuPanel,  BorderLayout.NORTH);
getContentPane().add(textPanel,  BorderLayout.CENTER);
getContentPane().add(buttonPanel,  BorderLayout.SOUTH);

getRootPane().setDefaultButton(buttonOK);

pack();
setLocationRelativeTo(owner);

mTextArea.requestFocus();
setVisible(true);
}
 
Example 18
Source File: TestSuiteStepLocation.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private Component createVisualComp() {
    JCheckBox[] chkBoxes;
    
    JComponent infoLabel = GuiUtils.createMultilineLabel(
            NbBundle.getMessage(TestSuiteStepLocation.class,
                                "TXT_ClassesInSuite"));             //NOI18N
    JComponent optCode = GuiUtils.createChkBoxGroup(
            NbBundle.getMessage(
                    GuiUtils.class,
                    "CommonTestsCfgOfCreate.groupOptCode"),               //NOI18N
            chkBoxes = GuiUtils.createCheckBoxes(new String[] {
                    GuiUtils.CHK_SETUP,
                    GuiUtils.CHK_TEARDOWN,
                    GuiUtils.CHK_BEFORE_CLASS,
                    GuiUtils.CHK_AFTER_CLASS}));
    chkSetUp = chkBoxes[0];
    chkTearDown = chkBoxes[1];
    chkBeforeClass = chkBoxes[2];
    chkAfterClass = chkBoxes[3];
    
    JComponent optComments = GuiUtils.createChkBoxGroup(
            NbBundle.getMessage(
                    GuiUtils.class,
                    "CommonTestsCfgOfCreate.groupOptComments"),           //NOI18N
            chkBoxes = GuiUtils.createCheckBoxes(new String[] {
                    GuiUtils.CHK_HINTS}));
    chkCodeHints = chkBoxes[0];

    JComponent bottomPanel = new SelfResizingPanel();
    bottomPanel.setLayout(new BorderLayout(0, 24));
    bottomPanel.add(infoLabel, BorderLayout.NORTH);
    JComponent box = new JPanel();
    box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
    box.add(optCode);
    box.add(Box.createHorizontalStrut(18));
    box.add(optComments);
    bottomPanel.add(box, BorderLayout.CENTER);
    
    /* tune layout of the components within the box: */
    infoLabel.setAlignmentX(0.0f);
    optCode.setAlignmentY(0.0f);
    optComments.setAlignmentY(0.0f);
 
    return bottomPanel;
}
 
Example 19
Source File: SwingClientGUI.java    From stendhal with GNU General Public License v2.0 4 votes vote down vote up
private void setupOverallLayout() {
	Dimension displaySize = stendhal.getDisplaySize();
	Container windowContent = SBoxLayout.createContainer(SBoxLayout.HORIZONTAL);
	frame.setContentPane(windowContent);

	// Set maximum size to prevent the entry requesting massive widths, but
	// force expand if there's extra space anyway
	chatText.getPlayerChatText().setMaximumSize(new Dimension(displaySize.width, Integer.MAX_VALUE));
	JComponent chatEntryBox = SBoxLayout.createContainer(SBoxLayout.HORIZONTAL);
	chatEntryBox.add(chatText.getPlayerChatText(), SLayout.EXPAND_X);

	if (Testing.CHAT) {
		chatEntryBox.add(new CharacterMap(chatText.getPlayerChatText()));
	}
	final JComponent chatBox = new JPanel();
	chatBox.setBorder(null);
	chatBox.setLayout(new SBoxLayout(SBoxLayout.VERTICAL));
	chatBox.add(chatEntryBox, SLayout.EXPAND_X);
	chatBox.add(chatLogArea, SBoxLayout.constraint(SLayout.EXPAND_X, SLayout.EXPAND_Y));

	verticalSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pane, chatBox);
	verticalSplit.setBorder(null);

	/*
	 * Fix the container panel size, so that it is always visible
	 */
	containerPanel.setMinimumSize(containerPanel.getPreferredSize());

	leftColumn.setMinimumSize(new Dimension());
	// Splitter between the left column and game screen
	JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftColumn, verticalSplit);
	// Ensure that the limits are obeyed even when the component is resized
	split.addComponentListener(new HorizontalSplitListener(displaySize, split));

	horizontalSplit = split;
	int divWidth = verticalSplit.getDividerSize();
	pane.setPreferredSize(new Dimension(displaySize.width + divWidth, displaySize.height));
	horizontalSplit.setBorder(null);
	windowContent.add(horizontalSplit, SBoxLayout.constraint(SLayout.EXPAND_Y, SLayout.EXPAND_X));

	JComponent rightSidePanel = SBoxLayout.createContainer(SBoxLayout.VERTICAL);
	JComponent settings = new SettingsPanel();
	rightSidePanel.add(settings, SLayout.EXPAND_X);
	rightSidePanel.add(containerPanel, SBoxLayout.constraint(SLayout.EXPAND_Y, SLayout.EXPAND_X));
	windowContent.add(rightSidePanel, SLayout.EXPAND_Y);

	frame.pack();
	horizontalSplit.setDividerLocation(leftColumn.getPreferredSize().width);

	smallScreenHacks();
}
 
Example 20
Source File: SBoxLayout.java    From stendhal with GNU General Public License v2.0 3 votes vote down vote up
/**
 * A convenience method for creating a container using SBoxLayout with
 * padding between the components.
 *
 * @param direction layout direction
 * @param padding padding in pixels between the components
 * @return A component using SBoxLayout
 */
public static JComponent createContainer(boolean direction, int padding) {
	JComponent container = new Spring();
	container.setLayout(new SBoxLayout(direction, padding));

	return container;
}