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

The following examples show how to use javax.swing.JComponent#setAlignmentX() . 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: AqlViewer.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
private <X, Y> JScrollPane makeList2(
		Algebra<catdata.aql.exp.Ty, catdata.aql.exp.En, catdata.aql.exp.Sym, catdata.aql.exp.Fk, catdata.aql.exp.Att, catdata.aql.exp.Gen, catdata.aql.exp.Sk, X, Y> algebra,
		boolean b, int l) {
	List<JComponent> list = makeList(algebra, b, l);

	JPanel c = new JPanel();
	c.setLayout(new BoxLayout(c, BoxLayout.PAGE_AXIS));

	for (JComponent x : list) {
		x.setAlignmentX(Component.LEFT_ALIGNMENT);
		x.setMinimumSize(x.getPreferredSize());
		c.add(x);
	}

	JPanel p = new JPanel(new GridLayout(1, 1));
	p.add(c);
	JScrollPane jsp = new JScrollPane(p);

	c.setBorder(BorderFactory.createEmptyBorder());
	p.setBorder(BorderFactory.createEmptyBorder());
	jsp.setBorder(BorderFactory.createEmptyBorder());
	return jsp;
}
 
Example 2
Source File: ContainerPanel.java    From stendhal with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Add a component that should be repainted in the drawing loop. This is
 * not a particularly pretty way to do it, but individual timers for item
 * slots end up being more expensive, and the RepaintManager merges the
 * draw request anyway.
 *
 * @param child component to add
 */
void addRepaintable(JComponent child) {
	int position = panel.getComponentCount();
	if (child instanceof InternalManagedWindow) {
		InternalManagedWindow window = (InternalManagedWindow) child;
		window.addWindowDragListener(this);
		position = findWindowPosition(window.getName());
	}

	if (child instanceof Inspectable) {
		((Inspectable) child).setInspector(this);
	}

	child.setIgnoreRepaint(true);
	child.setAlignmentX(LEFT_ALIGNMENT);
	panel.add(child, position);
	panel.revalidate();
}
 
Example 3
Source File: PropertiesPanel.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Rebuild this panel to show inputs for the given Object Class Definition.
 *
 * @param ocd
 *          The object class definition to present.
 */
void rebuild(ObjectClassDefinition ocd)
{
  removeAll();
  props.clear();

  if (ocd != null) {
    final Dictionary<String, Object> configProps =
      new Hashtable<String, Object>();

    final AttributeDefinition[] reqAttrs =
      ocd.getAttributeDefinitions(ObjectClassDefinition.REQUIRED);
    addAttribs(reqAttrs, configProps, "");
    final AttributeDefinition[] optAttrs =
      ocd.getAttributeDefinitions(ObjectClassDefinition.OPTIONAL);
    addAttribs(optAttrs, configProps, " (optional)");
  }

  // Must use a panel as filler since the component returned by
  // BoxcreateGlue() does not paint the background.
  final JComponent filler = new JPanel();
  filler.setAlignmentX(Component.LEFT_ALIGNMENT);
  add(filler);
}
 
Example 4
Source File: AqlViewer.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
private <e, L> void apgInst0(JTabbedPane pane, ApgInstance<L, e> G) {
	List<JComponent> list = new LinkedList<>();

	Object[][] rowData;
	Object[] colNames;

	rowData = new Object[G.Es.size()][3];
	colNames = new Object[3];
	colNames[0] = "Element";
	colNames[1] = "Label";
	colNames[2] = "Value";
	int j = 0;
	for (Entry<e, Pair<L, ApgTerm<L, e>>> lt : G.Es.entrySet()) {
		rowData[j][0] = lt.getKey();
		rowData[j][1] = lt.getValue().first;
		rowData[j][2] = lt.getValue().second;
		j++;
	}
	list.add(GuiUtil.makeTable(BorderFactory.createEmptyBorder(), "Data", rowData, colNames));

	JPanel c = new JPanel();
	c.setLayout(new BoxLayout(c, BoxLayout.PAGE_AXIS));

	for (JComponent x : list) {
		x.setAlignmentX(Component.LEFT_ALIGNMENT);
		x.setMinimumSize(x.getPreferredSize());
		c.add(x);
	}

	JPanel p = new JPanel(new GridLayout(1, 1));
	p.add(c);
	JScrollPane jsp = new JScrollPane(p);

	c.setBorder(BorderFactory.createEmptyBorder());
	p.setBorder(BorderFactory.createEmptyBorder());
	jsp.setBorder(BorderFactory.createEmptyBorder());
	pane.addTab("Tables", p);
}
 
Example 5
Source File: ButtonDemo.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the horizonal hint box.
 *
 * @param parent the parent
 * @param c the c
 * @param txt the txt
 */
public static void createHorizonalHintBox(JPanel parent,JComponent c, String txt)
{
	parent.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
	parent.setAlignmentX(Component.LEFT_ALIGNMENT);
	c.setBorder(BorderFactory.createEmptyBorder(10, 0, 5, 0));
	c.setAlignmentX(Component.LEFT_ALIGNMENT);

	JLabel l1 = N9ComponentFactory.createLabel_style4(txt);
	l1.setAlignmentX(Component.LEFT_ALIGNMENT);
	parent.add(l1);
	
	parent.add(c);
}
 
Example 6
Source File: SliderDemo.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the vertical hint box.
 *
 * @param c the c
 * @param txt the txt
 * @return the j panel
 */
public static JPanel createVerticalHintBox(JComponent c, String txt)
{
	JPanel p = new JPanel();
	p.setOpaque(false);
	p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
	JLabel l1 = N9ComponentFactory.createLabel_style3(txt);
	l1.setAlignmentX(Component.CENTER_ALIGNMENT);
	p.add(l1);
	c.setAlignmentX(Component.CENTER_ALIGNMENT);
	p.add(c);
	
	p.setBorder(BorderFactory.createEmptyBorder(10, 0, 5, 0));
	return p;
}
 
Example 7
Source File: SliderDemo.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the horizonal hint box.
 *
 * @param parent the parent
 * @param c the c
 * @param txt the txt
 */
public static void createHorizonalHintBox(JPanel parent,JComponent c, String txt)
{
	parent.setAlignmentX(Component.LEFT_ALIGNMENT);
	parent.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 5));
	c.setAlignmentX(Component.LEFT_ALIGNMENT);

	JLabel l1 = N9ComponentFactory.createLabel_style3(txt);
	l1.setAlignmentX(Component.LEFT_ALIGNMENT);
	parent.add(l1);
}
 
Example 8
Source File: MainFrame.java    From FCMFrame with Apache License 2.0 5 votes vote down vote up
public static JPanel createVerticalHintBox(JComponent c, JLabel l1) {
	JPanel p = new JPanel();
	p.setOpaque(false);
	p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
	l1.setAlignmentX(Component.CENTER_ALIGNMENT);
	p.add(l1);
	c.setAlignmentX(Component.CENTER_ALIGNMENT);
	p.add(c);

	p.setBorder(BorderFactory.createEmptyBorder(10, 0, 5, 0));
	return p;
}
 
Example 9
Source File: MainFrame.java    From FCMFrame with Apache License 2.0 5 votes vote down vote up
public static void createHorizonalHintBox(JPanel parent, JComponent c, JLabel l1) {
	parent.setAlignmentX(Component.LEFT_ALIGNMENT);
	parent.setBounds(15, 10, 100, 30);
	c.setAlignmentX(Component.LEFT_ALIGNMENT);
	
	l1.setAlignmentX(Component.LEFT_ALIGNMENT);
	parent.add(l1);
}
 
Example 10
Source File: GuiUtil.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
public static JComponent makeGrid(List<JComponent> list) {

		JPanel ret = new JPanel();
		ret.setLayout(new BoxLayout(ret, BoxLayout.PAGE_AXIS));
		// int i = 0;
		for (JComponent x : list) {
			x.setAlignmentX(Component.LEFT_ALIGNMENT);
			x.setMinimumSize(x.getPreferredSize());
			ret.add(x);
			// ret.add(Box.)
			// ret.add(Box.createHorizontalGlue());
		}
//		ret.add(new JLabel(""), Box.cre);

		JPanel p = new JPanel(new GridLayout(1, 1));

		p.add(ret);

		JScrollPane jsp = new JScrollPane(p);// , JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
												// JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

		ret.setBorder(BorderFactory.createEmptyBorder());
		p.setBorder(BorderFactory.createEmptyBorder());
		// jsp.setBorder(BorderFactory.createEmptyBorder());

		return jsp;
	}
 
Example 11
Source File: AqlViewer.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
private <L> void apgSch0(JTabbedPane pane, ApgSchema<L> Ls) {
	List<JComponent> list = new LinkedList<>();

	Object[][] rowData = new Object[Ls.size()][2];
	Object[] colNames = new Object[2];
	colNames[0] = "Label";
	colNames[1] = "Type";
	int j = 0;
	for (Entry<L, ApgTy<L>> lt : Ls.entrySet()) {
		rowData[j][0] = lt.getKey();
		rowData[j][1] = lt.getValue();
		j++;
	}
	list.add(GuiUtil.makeTable(BorderFactory.createEmptyBorder(), "Schema", rowData, colNames));

	JPanel c = new JPanel();
	c.setLayout(new BoxLayout(c, BoxLayout.PAGE_AXIS));

	for (JComponent x : list) {
		x.setAlignmentX(Component.LEFT_ALIGNMENT);
		x.setMinimumSize(x.getPreferredSize());
		c.add(x);
	}

	JPanel p = new JPanel(new GridLayout(1, 1));
	p.add(c);
	JScrollPane jsp = new JScrollPane(p);

	c.setBorder(BorderFactory.createEmptyBorder());
	p.setBorder(BorderFactory.createEmptyBorder());
	jsp.setBorder(BorderFactory.createEmptyBorder());
	pane.addTab("Tables", p);
}
 
Example 12
Source File: SBOLInputDialog.java    From iBioSim with Apache License 2.0 4 votes vote down vote up
private void initGUI() 
{
	JPanel buttonPanel = new JPanel();
	buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
	buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));

	if (registrySelection != null) {
		optionsButton = new JButton("Options");
		optionsButton.addActionListener(actionListener);
		buttonPanel.add(optionsButton);
	}

	buttonPanel.add(Box.createHorizontalStrut(200));
	buttonPanel.add(Box.createHorizontalGlue());
	
	cancelButton = new JButton("Cancel");
	cancelButton.addActionListener(actionListener);
	cancelButton.registerKeyboardAction(actionListener, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
			JComponent.WHEN_IN_FOCUSED_WINDOW);
	buttonPanel.add(cancelButton);
	
	openVPRGenerator = new JButton("Generate Model");
	openVPRGenerator.addActionListener(actionListener);
	openVPRGenerator.setEnabled(true);
	getRootPane().setDefaultButton(openVPRGenerator);
	buttonPanel.add(openVPRGenerator);
	
	openSBOLDesigner = new JButton("Open SBOLDesigner");
	openSBOLDesigner.addActionListener(actionListener);
	openSBOLDesigner.setEnabled(true);
	getRootPane().setDefaultButton(openSBOLDesigner);
	buttonPanel.add(openSBOLDesigner);
	
	initFormPanel(builder);

	JComponent formPanel = builder.build();
	formPanel.setAlignmentX(LEFT_ALIGNMENT);

	Box topPanel = Box.createVerticalBox();
	String message = initMessage();
	if (message != null) {
		JPanel messageArea = new JPanel();
		messageArea.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6),
				BorderFactory.createEtchedBorder()));
		messageArea.setAlignmentX(LEFT_ALIGNMENT);
		messageArea.add(new JLabel("<html>" + message.replace("\n", "<br>") + "</html>"));
		topPanel.add(messageArea);
	}
	topPanel.add(formPanel);

	JComponent mainPanel = initMainPanel();

	JPanel contentPane = new JPanel(new BorderLayout());
	contentPane.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
	contentPane.add(topPanel, BorderLayout.NORTH);
	if (mainPanel != null) {
		contentPane.add(mainPanel, BorderLayout.CENTER);
	}
	contentPane.add(buttonPanel, BorderLayout.SOUTH);

	setContentPane(contentPane);

	initFinished();

	if (registrySelection != null) {
		registryChanged();
	}

	pack();
	setLocationRelativeTo(getOwner());
}
 
Example 13
Source File: CollapsiblePanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public FilesPanel(VCSCommitPanel master, Map<String, VCSCommitFilter> filters, int preferedHeight)  {
    super(master, master.getModifier().getMessage(VCSCommitPanelModifier.BundleMessage.FILE_PANEL_TITLE), DEFAULT_DISPLAY_FILES);
    this.filters = filters;
    
    master.getCommitTable().labelFor(filesLabel);
    
    JComponent table = master.getCommitTable().getComponent();
    
    Mnemonics.setLocalizedText(filesLabel, getMessage("CTL_CommitForm_FilesToCommit"));         // NOI18N
    filesLabel.setMaximumSize(new Dimension(Integer.MAX_VALUE, filesLabel.getMaximumSize().height));
    
    table.setPreferredSize(new Dimension(0, preferedHeight));
    
    ButtonGroup bg = new ButtonGroup();
    toolbar = new JToolBar();
    toolbar.setFloatable(false);
    
    for (VCSCommitFilter filter : filters.values()) {
        
        JToggleButton tgb = new JToggleButton();
        tgb.setIcon(filter.getIcon()); 
        tgb.setToolTipText(filter.getTooltip()); 
        tgb.setFocusable(false);
        tgb.setSelected(filter.isSelected());
        tgb.addActionListener(this);                
        tgb.putClientProperty(TOOLBAR_FILTER, filter);
        bg.add(tgb);
        toolbar.add(tgb);
        
    }
    toolbar.setAlignmentX(LEFT_ALIGNMENT);        
    
    sectionPanel.add(toolbar);
    sectionPanel.add(table);
    sectionPanel.add(VCSCommitPanel.makeVerticalStrut(filesLabel, table, RELATED, sectionPanel));
    sectionPanel.add(filesLabel);
    
    sectionPanel.setAlignmentX(LEFT_ALIGNMENT);
    filesLabel.setAlignmentX(LEFT_ALIGNMENT);
    table.setAlignmentX(LEFT_ALIGNMENT);
}
 
Example 14
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 15
Source File: LayoutPanel.java    From cstc with GNU General Public License v3.0 4 votes vote down vote up
public void addActionComponent(JComponent comp) {
	comp.setAlignmentX(Component.RIGHT_ALIGNMENT);
	this.headerBox.add(comp);
	this.headerBox.add(Box.createHorizontalStrut(10));
}
 
Example 16
Source File: ProgressLog.java    From stendhal with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a new page.
 */
Page() {
	this.setLayout(new SBoxLayout(SBoxLayout.VERTICAL));
	JComponent panels = SBoxLayout.createContainer(SBoxLayout.HORIZONTAL, SBoxLayout.COMMON_PADDING);
	add(panels, SBoxLayout.constraint(SLayout.EXPAND_X,
			SLayout.EXPAND_Y));

	indexArea = new PrettyEditorPane();
	indexArea.addHyperlinkListener(this);

	indexScrollPane = new JScrollPane(indexArea);
	// Fixed width
	indexScrollPane.setMaximumSize(new Dimension(INDEX_WIDTH, Integer.MAX_VALUE));
	indexScrollPane.setMinimumSize(new Dimension(INDEX_WIDTH, 0));
	// Turn off caret following
	Caret caret = indexArea.getCaret();
	if (caret instanceof DefaultCaret) {
		((DefaultCaret) caret).setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
	}

	panels.add(indexScrollPane, SLayout.EXPAND_Y);

	contentArea = new PrettyEditorPane();
	// Does not need a listener. There should be no links

	contentScrollPane = new JScrollPane(contentArea);
	panels.add(contentScrollPane, SBoxLayout.constraint(SLayout.EXPAND_X,
			SLayout.EXPAND_Y));

	JComponent buttonBox = SBoxLayout.createContainer(SBoxLayout.HORIZONTAL, SBoxLayout.COMMON_PADDING);
	buttonBox.setAlignmentX(RIGHT_ALIGNMENT);
	buttonBox.setBorder(BorderFactory.createEmptyBorder(SBoxLayout.COMMON_PADDING,
			0, SBoxLayout.COMMON_PADDING, SBoxLayout.COMMON_PADDING));
	add(buttonBox);
	// A button for reloading the page contents
	JButton refresh = new JButton("Update");
	refresh.setMnemonic(KeyEvent.VK_U);
	refresh.setAlignmentX(Component.RIGHT_ALIGNMENT);
	refresh.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent event) {
			update();
		}
	});
	buttonBox.add(refresh);
	JButton closeButton = new JButton("Close");
	closeButton.setMnemonic(KeyEvent.VK_C);
	closeButton.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			getWindow().dispose();
		}
	});
	buttonBox.add(closeButton);
}
 
Example 17
Source File: VerticalPanel.java    From shakey with Apache License 2.0 4 votes vote down vote up
public void add(JComponent comp) {
	comp.setAlignmentX( 0);
	super.add( comp);
}