javax.swing.Box Java Examples

The following examples show how to use javax.swing.Box. 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: BasePanel.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds the field.
 *
 * @param parentBox the parent box
 * @param field the field
 */
private void addField(Box parentBox, FieldConfigBase field) {

    if (field != null) {
        field.createUI();
        addFieldConfig(field);

        fieldConfigManager.addField(field);

        if (parentBox != null) {
            parentBox.add(field.getPanel());

            // Add any custom panels
            if (field.getCustomPanels() != null) {
                for (Component component : field.getCustomPanels()) {
                    parentBox.add(component);
                }
            }
        }
    }
}
 
Example #2
Source File: ContactListView.java    From desktopclient-java with GNU General Public License v3.0 6 votes vote down vote up
FlyweightContactItem() {
    //this.setPaintFocus(true);
    this.setLayout(new BorderLayout(View.GAP_DEFAULT, 0));
    this.setMargin(View.MARGIN_SMALL);

    mAvatar = new ComponentUtils.AvatarImage(View.AVATAR_LIST_SIZE);
    this.add(mAvatar, BorderLayout.WEST);

    mNameLabel = new WebLabel();
    mNameLabel.setFontSize(View.FONT_SIZE_BIG);
    mNameLabel.setDrawShade(true);

    mStatusLabel = new WebLabel();
    mStatusLabel.setForeground(Color.GRAY);
    mStatusLabel.setFontSize(View.FONT_SIZE_TINY);
    this.add(
            new GroupPanel(View.GAP_SMALL, false,
                    mNameLabel,
                    new GroupPanel(GroupingType.fillFirst,
                            Box.createGlue(), mStatusLabel)
            ), BorderLayout.CENTER);
}
 
Example #3
Source File: MarketDataPanel.java    From shakey with Apache License 2.0 6 votes vote down vote up
ScannerRequestPanel() {
	HtmlButton go = new HtmlButton( "Go") {
		@Override protected void actionPerformed() {
			onGo();
		}
	};
	
	VerticalPanel paramsPanel = new VerticalPanel();
	paramsPanel.add( "Scan code", m_scanCode);
	paramsPanel.add( "Instrument", m_instrument);
	paramsPanel.add( "Location", m_location, Box.createHorizontalStrut(10), go);
	paramsPanel.add( "Stock type", m_stockType);
	paramsPanel.add( "Num rows", m_numRows);
	
	setLayout( new BorderLayout() );
	add( paramsPanel, BorderLayout.NORTH);
}
 
Example #4
Source File: Test4903007.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected JPanel getObject() {
    Box vBox = Box.createVerticalBox();
    vBox.add(new JButton("button"));
    vBox.add(Box.createVerticalStrut(10));
    vBox.add(new JLabel("label"));
    vBox.add(Box.createVerticalGlue());
    vBox.add(new JButton("button"));
    vBox.add(Box.createVerticalStrut(10));
    vBox.add(new JLabel("label"));

    Box hBox = Box.createHorizontalBox();
    hBox.add(new JButton("button"));
    hBox.add(Box.createHorizontalStrut(10));
    hBox.add(new JLabel("label"));
    hBox.add(Box.createHorizontalGlue());
    hBox.add(new JButton("button"));
    hBox.add(Box.createHorizontalStrut(10));
    hBox.add(new JLabel("label"));

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(vBox);
    panel.add(Box.createGlue());
    panel.add(hBox);
    return panel;
}
 
Example #5
Source File: StackTraceReportSwingView.java    From triplea with GNU General Public License v3.0 6 votes vote down vote up
private JPanel buttonPanel() {
  return new JPanelBuilder()
      .border(10)
      .add(
          new JPanelBuilder()
              .borderLayout()
              .addWest(
                  new JPanelBuilder()
                      .boxLayoutHorizontal()
                      .add(submitButton)
                      .add(Box.createHorizontalStrut(30))
                      .add(previewButton)
                      .build())
              .addEast(
                  new JPanelBuilder()
                      .boxLayoutHorizontal()
                      .add(Box.createHorizontalStrut(70))
                      .add(cancelButton)
                      .build())
              .build())
      .build();
}
 
Example #6
Source File: VerticalLayout.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public Dimension minimumLayoutSize(final Container parent) {
    final Insets insets = parent.getInsets();
    final Dimension d = new Dimension(insets.left + insets.right,
                                      insets.top + insets.bottom);
    int maxWidth = 0;
    int visibleCount = 0;

    for (Component comp : parent.getComponents()) {
        if (comp.isVisible() && !(comp instanceof Box.Filler)) {
            final Dimension size = comp.getPreferredSize();
            maxWidth = Math.max(maxWidth, size.width);
            d.height += size.height;
            visibleCount++;
        }
    }

    d.height += (visibleCount - 1) * vGap;
    d.width += maxWidth;

    return d;
}
 
Example #7
Source File: KitSelectionDialog.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void initComponents()
{
	Container pane = getContentPane();
	pane.setLayout(new BorderLayout());

	pane.add(kitPanel, BorderLayout.CENTER);

	Button closeButton = new Button(LanguageBundle.getString("in_close"));
	closeButton.setOnAction(this::onClose);

	Box buttons = Box.createHorizontalBox();
	buttons.add(GuiUtility.wrapParentAsJFXPanel(closeButton));
	pane.add(buttons, BorderLayout.PAGE_END);

	Utility.installEscapeCloseOperation(this);
}
 
Example #8
Source File: InstallerGUI.java    From EasyMPermission with MIT License 6 votes vote down vote up
void addLocation(final IdeLocation location) {
	if (locations.contains(location)) return;
	Box box = Box.createHorizontalBox();
	box.setBackground(Color.WHITE);
	final JCheckBox checkbox = new JCheckBox(location.getName());
	checkbox.setBackground(Color.WHITE);
	box.add(new JLabel(new ImageIcon(location.getIdeIcon())));
	box.add(checkbox);
	checkbox.setSelected(true);
	checkbox.addActionListener(new ActionListener() {
		@Override public void actionPerformed(ActionEvent e) {
			location.selected = checkbox.isSelected();
			fireSelectionChange();
		}
	});
	
	if (location.hasLombok()) {
		box.add(new JLabel(new ImageIcon(Installer.class.getResource("lombokIcon.png"))));
	}
	box.add(Box.createHorizontalGlue());
	locations.add(location);
	add(box);
	getParent().doLayout();
	fireSelectionChange();
}
 
Example #9
Source File: Test4903007.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected JPanel getObject() {
    Box vBox = Box.createVerticalBox();
    vBox.add(new JButton("button"));
    vBox.add(Box.createVerticalStrut(10));
    vBox.add(new JLabel("label"));
    vBox.add(Box.createVerticalGlue());
    vBox.add(new JButton("button"));
    vBox.add(Box.createVerticalStrut(10));
    vBox.add(new JLabel("label"));

    Box hBox = Box.createHorizontalBox();
    hBox.add(new JButton("button"));
    hBox.add(Box.createHorizontalStrut(10));
    hBox.add(new JLabel("label"));
    hBox.add(Box.createHorizontalGlue());
    hBox.add(new JButton("button"));
    hBox.add(Box.createHorizontalStrut(10));
    hBox.add(new JLabel("label"));

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(vBox);
    panel.add(Box.createGlue());
    panel.add(hBox);
    return panel;
}
 
Example #10
Source File: AboutDialog.java    From settlers-remake with MIT License 6 votes vote down vote up
/**
 * Constructor
 * 
 * @param parent
 *            Parent JFrame to center on
 */
public AboutDialog(JFrame parent) {
	super(parent);
	setTitle(EditorLabels.getLabel("about.header"));
	setDefaultCloseOperation(DISPOSE_ON_CLOSE);

	setLayout(new BorderLayout(0, 0));
	add(new JLabel(new ImageIcon(AboutDialog.class.getResource("about.png"))), BorderLayout.NORTH);

	Box info = Box.createVerticalBox();
	info.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
	add(info, BorderLayout.CENTER);

	info.add(createHeaderLabel("about.version"));
	info.add(new JLabel(CommitInfo.COMMIT_HASH_SHORT));
	info.add(createSpacer());
	info.add(createHeaderLabel("about.developer"));
	info.add(createListLabelLabel("developer.txt"));
	info.add(createSpacer());
	info.add(createHeaderLabel("about.translator"));
	info.add(createListLabelLabel("translator.txt"));

	pack();
	setLocationRelativeTo(parent);
	setModal(true);
}
 
Example #11
Source File: MockActionsDialog.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
private void initContents(Map<String,List<MockAction>> actions) {
   JPanel panel = new JPanel();
   panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
   
   tabbedPane = new JTabbedPane();
   for (String cap : actions.keySet()) {
      Component component = createActions(actions.get(cap));
      tabbedPane.addTab(cap, component);
      tabs.put(cap, component);
   }
   
   JPanel buttonBar = new JPanel(new BorderLayout());
   JButton closeButton = new JButton(close);
   buttonBar.add(closeButton, BorderLayout.PAGE_END);
   
   panel.add(tabbedPane);
   panel.add(Box.createVerticalStrut(10));
   panel.add(buttonBar);
   
   getContentPane().add(panel);
   this.pack();
}
 
Example #12
Source File: PCGenStatusBar.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
PCGenStatusBar(PCGenFrame frame)
{
	this.frame = frame;
	this.messageLabel = new JLabel();
	this.progressBar = new JProgressBar();
	this.loadStatusButton = new Button();

	setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
	add(messageLabel);
	add(Box.createHorizontalGlue());
	progressBar.setStringPainted(true);
	progressBar.setVisible(false);
	add(progressBar);
	add(Box.createHorizontalGlue());
	JFXPanel wrappedButton = GuiUtility.wrapParentAsJFXPanel(loadStatusButton);
	//todo: calculate this rather than hard code
	wrappedButton.setMaximumSize(new Dimension(750, 20000000));
	add(wrappedButton);
	loadStatusButton.setOnAction(this::loadStatusLabelAction);
}
 
Example #13
Source File: TypesConfigFrame.java    From ontopia with Apache License 2.0 6 votes vote down vote up
private Box createWeightPanel(String title, int min, int max) {
  Box weightPanel = new Box(BoxLayout.X_AXIS);

  weightPanel.add(Box.createHorizontalStrut(10));
  weightPanel.add(new JLabel(title));
  weightPanel.add(Box.createHorizontalStrut(10));

  weight = new JSlider(JSlider.HORIZONTAL, min, max, 1);
  weight.addChangeListener(new ChangeListener() {

    @Override
    public void stateChanged(ChangeEvent e) {
      setWeight(((JSlider) e.getSource()).getValue());
    }
  });

  weightPanel.add(weight);
  weightPanel.add(Box.createHorizontalStrut(10));
  return weightPanel;
}
 
Example #14
Source File: KitSelectionDialog.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void initComponents()
{
	Container pane = getContentPane();
	pane.setLayout(new BorderLayout());

	pane.add(kitPanel, BorderLayout.CENTER);

	Button closeButton = new Button(LanguageBundle.getString("in_close"));
	closeButton.setOnAction(this::onClose);

	Box buttons = Box.createHorizontalBox();
	buttons.add(GuiUtility.wrapParentAsJFXPanel(closeButton));
	pane.add(buttons, BorderLayout.PAGE_END);

	Utility.installEscapeCloseOperation(this);
}
 
Example #15
Source File: AjaxSpiderExplorer.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public JPanel getPanel() {
    if (panel == null) {
        panel = new QuickStartBackgroundPanel();
        panel.add(
                getSelectCheckBox(),
                LayoutHelper.getGBC(0, 0, 1, 0.0D, DisplayUtils.getScaledInsets(5, 5, 5, 5)));
        panel.add(
                new JLabel(Constant.messages.getString("quickstart.label.withbrowser")),
                LayoutHelper.getGBC(1, 0, 1, 0.0D, DisplayUtils.getScaledInsets(5, 5, 5, 5)));
        panel.add(
                getBrowserComboBox(),
                LayoutHelper.getGBC(2, 0, 1, 0.0D, DisplayUtils.getScaledInsets(5, 5, 5, 5)));
        panel.add(
                new JLabel(""),
                LayoutHelper.getGBC(3, 0, 1, 1.0D, DisplayUtils.getScaledInsets(5, 5, 5, 5)));
        panel.add(Box.createHorizontalGlue());
    }
    return panel;
}
 
Example #16
Source File: PostCustomizationDialog.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
@Override
protected Component createContents() {
	JPanel panel = new JPanel(new VerticalLayout());
	panel.add(new HyperLink(Actions.build("Pair Another Device", () -> submit(Action.PAIR_ANOTHER))).getComponent());
	int remainingDevices = ((Collection<?>) input.getPairingSubsystem().get(PairingSubsystem.ATTR_PAIRINGDEVICES)).size();
	if(remainingDevices > 0) {
		panel.add(new HyperLink(Actions.build(String.format("Customize %d Remaining Devices", remainingDevices), () -> submit(Action.CUSTOMIZE_ANOTHER))).getComponent());
	}
	panel.add(new JSeparator(JSeparator.HORIZONTAL));
	
	JButton dismissAll = new JButton(Actions.build("Dismiss All", () -> submit(Action.DISMISS_ALL)));
	JPanel buttons = new JPanel();
	buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
	buttons.add(Box.createGlue());
	buttons.add(dismissAll);
	panel.add(buttons);
	
	return panel;
}
 
Example #17
Source File: LogAxisPlotDemo2.java    From jtk with Apache License 2.0 6 votes vote down vote up
public static JPanel makeScaleOptionPanel(){
  
  // create the side panel with scale change options
  JPanel optionPanel = new JPanel();
  optionPanel.add(Box.createVerticalStrut(20));
  optionPanel.setLayout(new BoxLayout(optionPanel,BoxLayout.Y_AXIS));
  optionPanel.add(makeScalePanel(pv1,"View (0,0)"));
  optionPanel.add(Box.createVerticalStrut(20));
  optionPanel.add(new Separator());
  optionPanel.add(makeScalePanel(pv2,"View (0,1)"));
  optionPanel.add(Box.createVerticalStrut(20));
  optionPanel.add(new Separator());
  optionPanel.add(makeScalePanel(pv3,"View (1,0)"));
  optionPanel.add(Box.createVerticalStrut(20));
  optionPanel.add(new Separator());
  optionPanel.add(makeScalePanel(pv4,"View (1,1)"));
  optionPanel.add(Box.createVerticalStrut(20));
  return optionPanel;
}
 
Example #18
Source File: ProgramEditor.java    From FancyBing with GNU General Public License v3.0 5 votes vote down vote up
private JComponent createEntryLabel(String text)
{
    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    JLabel label = new JLabel(i18n(text));
    label.setAlignmentY(Component.CENTER_ALIGNMENT);
    box.add(label);
    return box;
}
 
Example #19
Source File: WebMapsView.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds fill components to empty cells in the first row and first column of the grid.
 * This ensures that the grid spacing will be the same as shown in the designer.
 * @param cols an array of column indices in the first row where fill components should be added.
 * @param rows an array of row indices in the first column where fill components should be added.
 */
void addFillComponents( Container panel, int[] cols, int[] rows )
{
   Dimension filler = new Dimension(10,10);

   boolean filled_cell_11 = false;
   CellConstraints cc = new CellConstraints();
   if ( cols.length > 0 && rows.length > 0 )
   {
      if ( cols[0] == 1 && rows[0] == 1 )
      {
         /** add a rigid area  */
         panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
         filled_cell_11 = true;
      }
   }

   for( int index = 0; index < cols.length; index++ )
   {
      if ( cols[index] == 1 && filled_cell_11 )
      {
         continue;
      }
      panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
   }

   for( int index = 0; index < rows.length; index++ )
   {
      if ( rows[index] == 1 && filled_cell_11 )
      {
         continue;
      }
      panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
   }

}
 
Example #20
Source File: InterpolateFilter.java    From GpsPrune with GNU General Public License v2.0 5 votes vote down vote up
/** Make the panel contents */
protected void makePanelContents()
{
	setLayout(new BorderLayout());
	JPanel boxPanel = new JPanel();
	boxPanel.setLayout(new BoxLayout(boxPanel, BoxLayout.Y_AXIS));
	add(boxPanel, BorderLayout.NORTH);
	JLabel topLabel = new JLabel(I18nManager.getText("dialog.gpsbabel.filter.interpolate.intro"));
	topLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
	boxPanel.add(topLabel);
	boxPanel.add(Box.createVerticalStrut(18)); // spacer
	// Main three-column grid
	JPanel gridPanel = new JPanel();
	gridPanel.setLayout(new GridLayout(0, 3, 4, 4));
	gridPanel.add(new JLabel(I18nManager.getText("dialog.gpsbabel.filter.interpolate.distance")));
	_distField = new DecimalNumberField();
	_distField.addKeyListener(_paramChangeListener);
	gridPanel.add(_distField);
	_distUnitsCombo = new JComboBox<String>(new String[] {I18nManager.getText("units.kilometres"), I18nManager.getText("units.miles")});
	gridPanel.add(_distUnitsCombo);
	gridPanel.add(new JLabel(I18nManager.getText("dialog.gpsbabel.filter.interpolate.time")));
	_secondsField = new WholeNumberField(4);
	_secondsField.addKeyListener(_paramChangeListener);
	gridPanel.add(_secondsField);
	gridPanel.add(new JLabel(I18nManager.getText("units.seconds")));
	gridPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
	boxPanel.add(gridPanel);
}
 
Example #21
Source File: Wizard.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
protected Wizard(WizardStep<I, ?> first, WizardStep<?, O> last) {
   this.first = first;
   this.current = first;
   this.last = last;

   GridBagConstraints gbc = new GridBagConstraints();
   
   gbc.gridx = 0;
   gbc.gridy = 0;
   gbc.fill = GridBagConstraints.BOTH;
   gbc.weightx = 1.0;
   gbc.weighty = 1.0;
   contents.add(new JLabel(), gbc.clone());
   
   gbc.fill = GridBagConstraints.HORIZONTAL;
   gbc.weightx = 1.0;
   gbc.weighty = 0.0;
   gbc.gridy++;
   contents.add(new JSeparator(JSeparator.HORIZONTAL), gbc.clone());
   
   JPanel buttons = new JPanel();
   buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
   buttons.add(back);
   buttons.add(Box.createHorizontalGlue());
   buttons.add(next);
   
   gbc.gridy++;
   contents.add(buttons, gbc.clone());
}
 
Example #22
Source File: MainPanel.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
private JPanel createWelcomePanel() {
    JPanel welcomePanel = new JPanel();
    welcomePanel.setLayout(new BoxLayout(welcomePanel, BoxLayout.Y_AXIS));
    JLabel welcomeToLabel = new JLabel(translate("startup.welcometo"));
    welcomeToLabel.setFont(welcomeToLabel.getFont().deriveFont(40));
    welcomeToLabel.setAlignmentX(0.5f);
    JPanel appNamePanel = new JPanel(new FlowLayout());
    JLabel jpLabel = new JLabel("JPEXS ");
    jpLabel.setAlignmentX(0.5f);
    jpLabel.setForeground(new Color(0, 0, 160));
    jpLabel.setFont(new Font("Tahoma", Font.BOLD, 50));
    jpLabel.setHorizontalAlignment(SwingConstants.CENTER);
    appNamePanel.add(jpLabel);

    JLabel ffLabel = new JLabel("Free Flash ");
    ffLabel.setAlignmentX(0.5f);
    ffLabel.setFont(new Font("Tahoma", Font.BOLD, 50));
    ffLabel.setHorizontalAlignment(SwingConstants.CENTER);
    appNamePanel.add(ffLabel);

    JLabel decLabel = new JLabel("Decompiler");
    decLabel.setAlignmentX(0.5f);
    decLabel.setForeground(Color.red);
    decLabel.setFont(new Font("Tahoma", Font.BOLD, 50));
    decLabel.setHorizontalAlignment(SwingConstants.CENTER);
    appNamePanel.add(decLabel);
    appNamePanel.setAlignmentX(0.5f);
    welcomePanel.add(Box.createGlue());
    welcomePanel.add(welcomeToLabel);
    welcomePanel.add(appNamePanel);
    JLabel startLabel = new JLabel(translate("startup.selectopen"));
    startLabel.setAlignmentX(0.5f);
    startLabel.setFont(startLabel.getFont().deriveFont(30));
    welcomePanel.add(startLabel);
    welcomePanel.add(Box.createGlue());
    return welcomePanel;
}
 
Example #23
Source File: BasicForm.java    From PyramidShader with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds fill components to empty cells in the first row and first column of the grid.
 * This ensures that the grid spacing will be the same as shown in the designer.
 * @param cols an array of column indices in the first row where fill components should be added.
 * @param rows an array of row indices in the first column where fill components should be added.
 */
void addFillComponents( Container panel, int[] cols, int[] rows )
{
   Dimension filler = new Dimension(10,10);

   boolean filled_cell_11 = false;
   CellConstraints cc = new CellConstraints();
   if ( cols.length > 0 && rows.length > 0 )
   {
      if ( cols[0] == 1 && rows[0] == 1 )
      {
         /** add a rigid area  */
         panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
         filled_cell_11 = true;
      }
   }

   for( int index = 0; index < cols.length; index++ )
   {
      if ( cols[index] == 1 && filled_cell_11 )
      {
         continue;
      }
      panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
   }

   for( int index = 0; index < rows.length; index++ )
   {
      if ( rows[index] == 1 && filled_cell_11 )
      {
         continue;
      }
      panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
   }

}
 
Example #24
Source File: SynthToolBarUI.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private boolean isGlue(Component c) {
    if (c.isVisible() && c instanceof Box.Filler) {
        Box.Filler f = (Box.Filler)c;
        Dimension min = f.getMinimumSize();
        Dimension pref = f.getPreferredSize();
        return min.width == 0 &&  min.height == 0 &&
                pref.width == 0 && pref.height == 0;
    }
    return false;
}
 
Example #25
Source File: ContentArea.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
public ContentArea() {
    super(new BorderLayout());
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
    panel.add(left);
    panel.add(Box.createHorizontalGlue());
    panel.add(right);
    this.add(panel, BorderLayout.NORTH);
}
 
Example #26
Source File: DisplayAFP.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void showAlignmentPanel(AFPChain afpChain, Atom[] ca1, Atom[] ca2, AbstractAlignmentJmol jmol) throws StructureException {

		AligPanel me = new AligPanel();
		me.setAlignmentJmol(jmol);
		me.setAFPChain(afpChain);
		me.setCa1(ca1);
		me.setCa2(ca2);

		JFrame frame = new JFrame();

		frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		frame.setTitle(afpChain.getName1() + " vs. " + afpChain.getName2() + " | " + afpChain.getAlgorithmName() + " V. " + afpChain.getVersion());
		me.setPreferredSize(new Dimension(me.getCoordManager().getPreferredWidth() , me.getCoordManager().getPreferredHeight()));

		JMenuBar menu = MenuCreator.getAlignmentPanelMenu(frame,me,afpChain,null);
		frame.setJMenuBar(menu);

		JScrollPane scroll = new JScrollPane(me);
		scroll.setAutoscrolls(true);

		StatusDisplay status = new StatusDisplay();
		status.setAfpChain(afpChain);
		status.setCa1(ca1);
		status.setCa2(ca2);
		me.addAlignmentPositionListener(status);

		Box vBox = Box.createVerticalBox();
		vBox.add(scroll);
		vBox.add(status);

		frame.getContentPane().add(vBox);

		frame.pack();
		frame.setVisible(true);
		// make sure they get cleaned up correctly:
		frame.addWindowListener(me);
		frame.addWindowListener(status);
	}
 
Example #27
Source File: ArrayInspector.java    From osp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates the GUI.
 */
protected void createGUI() {
  setSize(400, 300);
  setContentPane(new JPanel(new BorderLayout()));
  scrollpane = new JScrollPane(tables[0]);
  if(tables.length>1) {
    // create spinner
    SpinnerModel model = new SpinnerNumberModel(0, 0, tables.length-1, 1);
    spinner = new JSpinner(model);
    JSpinner.NumberEditor editor = new JSpinner.NumberEditor(spinner);
    editor.getTextField().setFont(tables[0].getFont());
    spinner.setEditor(editor);
    spinner.addChangeListener(new ChangeListener() {
      public void stateChanged(ChangeEvent e) {
        int i = ((Integer) spinner.getValue()).intValue();
        scrollpane.setViewportView(tables[i]);
      }

    });
    Dimension dim = spinner.getMinimumSize();
    spinner.setMaximumSize(dim);
    getContentPane().add(scrollpane, BorderLayout.CENTER);
    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);
    toolbar.add(new JLabel(" index ")); //$NON-NLS-1$
    toolbar.add(spinner);
    toolbar.add(Box.createHorizontalGlue());
    getContentPane().add(toolbar, BorderLayout.NORTH);
  } else {
    scrollpane.createHorizontalScrollBar();
    getContentPane().add(scrollpane, BorderLayout.CENTER);
  }
}
 
Example #28
Source File: SplineControlPanel.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void addEmptySpace(JPanel panel, int size) {
    panel.add(Box.createVerticalStrut(size),
            new GridBagConstraints(0, linesCount++,
            2, 1,
            1.0, 0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL,
            new Insets(6, 0, 0, 0),
            0, 0));
}
 
Example #29
Source File: TablePanel.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Create the control button Box from action list.
 * @return Box with buttons from actions
 */
protected Box createControlBox() {
	controlBox = Box.createHorizontalBox();
	populateControlBox();
	
	return controlBox;
}
 
Example #30
Source File: MultiOptionGroup.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Find option panel.
 *
 * @param box the box
 * @param panel the panel
 * @return the int
 */
private int findOptionPanel(Box box, FieldPanel panel) {
    int index;
    for (index = 0; index < box.getComponentCount(); index++) {
        if (box.getComponent(index) == panel) {
            return index;
        }
    }
    return -1;
}