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

The following examples show how to use javax.swing.JComponent#setMinimumSize() . 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: 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 3
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 4
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 5
Source File: FGSatelliteUndockedProvider.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public FGSatelliteUndockedProvider(FunctionGraphPlugin plugin, FGController controller,
		JComponent satelliteComponent) {
	super(plugin.getTool(), NAME, plugin.getName());
	this.controller = controller;
	this.satelliteComponent = satelliteComponent;
	satelliteComponent.setMinimumSize(new Dimension(400, 400));

	setHelpLocation(new HelpLocation("FunctionGraphPlugin", "Satellite_View_Dock"));

	setIcon(ICON);
	setDefaultWindowPosition(WindowPosition.WINDOW);
	setWindowMenuGroup(FunctionGraphPlugin.FUNCTION_GRAPH_NAME);

	addToTool();
}
 
Example 6
Source File: TextBlock.java    From pumpernickel with MIT License 5 votes vote down vote up
public JComponent createComponent() {
	JComponent jc = new JComponent() {
		@Override
		protected void paintComponent(Graphics g) {
			super.paintComponent(g);
			TextBlock.this.paint((Graphics2D) g);
		}
	};
	jc.setOpaque(false);
	jc.setMinimumSize(new Dimension(getWidth(), getHeight()));
	jc.setPreferredSize(new Dimension(getWidth(), getHeight()));
	return jc;
}
 
Example 7
Source File: OnePageWindow.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * Add a component for the Text.
 * 
 * @param panel Container.
 * @param constraints Constraints.
 * @param textPane Text pane.
 * @param undo Button undo.
 */
protected void addTextContents(
    JPanel panel, GridBagConstraints constraints,
    MWPane textPane, JButton undo) {
  if (textPane != null) {
    Configuration config = Configuration.getConfiguration();
    textPane.setBackground(Color.WHITE);
    textPane.setEditable(true);
    if (undo != null) {
      textPane.getUndoManager().setUndoLevels(config.getInt(
          null,
          ConfigurationValueInteger.ANALYSIS_UNDO_LVL));
    }
    textPane.addPropertyChangeListener(
        MWPane.PROPERTY_MODIFIED,
        new PropertyChangeListener() {

          /* (non-Javadoc)
           * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
           */
          @Override
          public void propertyChange(@SuppressWarnings("unused") PropertyChangeEvent evt) {
            updateComponentState();
          }
          
        });
    JComponent scrollContents = MWPane.createComplexPane(textPane);
    scrollContents.setMinimumSize(new Dimension(100, 100));
    scrollContents.setPreferredSize(new Dimension(1000, 500));
    panel.add(scrollContents, constraints);
  }
}
 
Example 8
Source File: ErrorDlg.java    From swift-explorer with Apache License 2.0 5 votes vote down vote up
private JComponent setPrefSize (JComponent comp, int minPrefW, int minPrefH)
{
	if (comp == null)
		return null ;
	comp.setMinimumSize(new Dimension(200, 150));
	comp.setPreferredSize(new Dimension(minPrefW, minPrefH));
	comp.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
	return comp ;
}
 
Example 9
Source File: DifferencesManagementPanel.java    From swift-explorer with Apache License 2.0 5 votes vote down vote up
private JComponent setPrefSize (JComponent comp, int minPrefW, int minPrefH)
{
	if (comp == null)
		return null ;
	comp.setMinimumSize(new Dimension(100, 100));
	comp.setPreferredSize(new Dimension(minPrefW, minPrefH));
	comp.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
	return comp ;
}
 
Example 10
Source File: SwiftPanel.java    From swift-explorer with Apache License 2.0 5 votes vote down vote up
private JComponent setMinPrefMaxWidth (JComponent comp, int minPrefW, int maxW, int prefHeight)
{
	if (comp == null)
		return null ;
	comp.setMinimumSize(new Dimension(minPrefW, 0));
	comp.setPreferredSize(new Dimension(minPrefW, prefHeight));
	comp.setMaximumSize(new Dimension(maxW, Integer.MAX_VALUE));
	return comp ;
}
 
Example 11
Source File: ProxyPanel.java    From swift-explorer with Apache License 2.0 5 votes vote down vote up
private JComponent setMinPrefMaxWidth (JComponent comp, int minPrefW, int maxW)
{
	if (comp == null)
		return null ;
	comp.setMinimumSize(new Dimension(minPrefW, 0));
	comp.setPreferredSize(new Dimension(minPrefW, 25));
	comp.setMaximumSize(new Dimension(maxW, Integer.MAX_VALUE));
	return comp ;
}
 
Example 12
Source File: UI.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static void setSize(JComponent component, Dimension dimension) {
    component.setMinimumSize(dimension);
    component.setPreferredSize(dimension);
}
 
Example 13
Source File: MSMSLibrarySubmissionWindow.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
private void createSubmitParamPanel() {
  // Main panel which holds all the components in a grid
  pnSubmitParam = new GridBagPanel();
  pnSideMenu.add(pnSubmitParam, BorderLayout.NORTH);

  int rowCounter = 0;
  // Create labels and components for each parameter
  for (Parameter p : paramSubmit.getParameters()) {
    if (!(p instanceof UserParameter))
      continue;
    UserParameter up = (UserParameter) p;

    JComponent comp = up.createEditingComponent();
    comp.setToolTipText(up.getDescription());

    // Set the initial value
    Object value = up.getValue();
    if (value != null)
      up.setValueToComponent(comp, value);

    // By calling this we make sure the components will never be resized
    // smaller than their optimal size
    comp.setMinimumSize(comp.getPreferredSize());

    comp.setToolTipText(up.getDescription());


    // add separator
    if (p.getName().equals(LibrarySubmitParameters.LOCALFILE.getName())) {
      pnSubmitParam.addSeparator(0, rowCounter, 2);
      rowCounter++;
    }

    JLabel label = new JLabel(p.getName());
    pnSubmitParam.add(label, 0, rowCounter);
    label.setLabelFor(comp);

    parametersAndComponents.put(p.getName(), comp);

    JComboBox t = new JComboBox();
    int comboh = t.getPreferredSize().height;
    int comph = comp.getPreferredSize().height;


    int verticalWeight = comph > 2 * comboh ? 1 : 0;
    pnSubmitParam.add(comp, 1, rowCounter, 1, 1, 1, verticalWeight, GridBagConstraints.VERTICAL);
    rowCounter++;
  }
}
 
Example 14
Source File: MSMSLibrarySubmissionWindow.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
private void createMetaDataPanel() {
  // Main panel which holds all the components in a grid
  pnMetaData = new GridBagPanel();
  scrollMeta = new JScrollPane(pnMetaData);
  scrollMeta.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  scrollMeta.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  pnSideMenu.add(scrollMeta, BorderLayout.CENTER);

  int rowCounter = 0;
  int vertWeightSum = 0;

  // Create labels and components for each parameter
  for (Parameter p : paramMeta.getParameters()) {
    if (!(p instanceof UserParameter))
      continue;
    UserParameter up = (UserParameter) p;

    JComponent comp = up.createEditingComponent();
    comp.setToolTipText(up.getDescription());

    // Set the initial value
    Object value = up.getValue();
    if (value != null)
      up.setValueToComponent(comp, value);

    // By calling this we make sure the components will never be resized
    // smaller than their optimal size
    comp.setMinimumSize(comp.getPreferredSize());

    comp.setToolTipText(up.getDescription());

    JLabel label = new JLabel(p.getName());
    pnMetaData.add(label, 0, rowCounter);
    label.setLabelFor(comp);

    parametersAndComponents.put(p.getName(), comp);

    JComboBox t = new JComboBox();
    int comboh = t.getPreferredSize().height;
    int comph = comp.getPreferredSize().height;

    // Multiple selection will be expandable, other components not
    int verticalWeight = comph > 2 * comboh ? 1 : 0;
    vertWeightSum += verticalWeight;

    pnMetaData.add(comp, 1, rowCounter, 1, 1, 1, verticalWeight, GridBagConstraints.VERTICAL);
    rowCounter++;
  }
}
 
Example 15
Source File: TimeRangeFilter.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private void setJComponentSize(Dimension comboBoxDimension, JComponent comboBox) {
    comboBox.setPreferredSize(comboBoxDimension);
    comboBox.setMinimumSize(comboBoxDimension);
}