Java Code Examples for javax.swing.JPanel#validate()

The following examples show how to use javax.swing.JPanel#validate() . 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: SelectHandlerPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void initComponents() {
    panel = new JPanel();
    setLayout(new BorderLayout());
    BorderLayout bl = new BorderLayout();
    panel.setLayout(bl);
    bl.setVgap(10);
    add(panel, BorderLayout.CENTER);
    
    BeanTreeView btv = new BeanTreeView();
    btv.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
    btv.getAccessibleContext().
            setAccessibleName(NbBundle.getMessage(SelectHandlerPanel.class,"LBL_Class_Tree"));
    btv.getAccessibleContext().setAccessibleDescription
            (NbBundle.getMessage(SelectHandlerPanel.class,"ACSD_SelectHandler"));
    String projectName = project.getProjectDirectory().getName();
    String classesLabel = projectName + " " +
            NbBundle.getMessage(SelectHandlerPanel.class, "LBL_PROJECT_CLASSES") + ":";
    JLabel label = new JLabel();
    org.openide.awt.Mnemonics.setLocalizedText(label, classesLabel);
    label.setLabelFor(btv.getViewport().getView());
    panel.add(label, BorderLayout.NORTH);
    panel.add(btv, BorderLayout.CENTER);   //NOI18N
    panel.validate();
    validate();
}
 
Example 2
Source File: AbstractObjectRenderer.java    From meka with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Exports the object.
 *
 * @param obj		the object to render
 * @param panel	the panel to render into
 * @return		null if successful, otherwise error message
 */
public String render(Object obj, JPanel panel) {
	String result;

	if (obj == null) {
		result = "No object provided!";
	}
	else {
		result = doRender(obj, panel);
		if (result == null) {
			panel.invalidate();
			panel.validate();
			panel.repaint();
		}
	}

	return result;
}
 
Example 3
Source File: SelectClassPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void initComponents() {
    panel = new JPanel();
    setLayout(new BorderLayout());
    panel.setLayout(new BorderLayout());
    add(panel, BorderLayout.CENTER);
    
    BeanTreeView btv = new BeanTreeView();
    btv.getAccessibleContext().
    setAccessibleName(NbBundle.getMessage(SelectClassPanel.class,"LBL_Class_Tree"));    //NOI18N
    btv.getAccessibleContext().setAccessibleDescription
    (NbBundle.getMessage(SelectClassPanel.class,"TTL_SelectClass"));    //NOI18N
    panel.add(btv, "Center");   //NOI18N
    panel.validate();
    validate();
}
 
Example 4
Source File: RubyConsole.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
public JComponent createComponent() {
    JPanel panel = new JPanel();
    JPanel console = new JPanel();
    panel.setLayout(new BorderLayout());

    final JEditorPane text = new JTextPane();

    text.setMargin(new Insets(8, 8, 8, 8));
    text.setCaretColor(new Color(0xa4, 0x00, 0x00));
    text.setBackground(new Color(0xf2, 0xf2, 0xf2));
    text.setForeground(new Color(0xa4, 0x00, 0x00));
    Font font = findFont("Monospaced", Font.PLAIN, 14, new String[]{
            "Monaco", "Andale Mono"});

    text.setFont(font);
    JScrollPane pane = new JScrollPane();
    pane.setViewportView(text);
    pane.setBorder(BorderFactory.createLineBorder(Color.darkGray));
    panel.add(pane, BorderLayout.CENTER);
    console.validate();

    final TextAreaReadline tar = new TextAreaReadline(text,
            getString("Wellcom") + " \n\n");

    RubyInstanceConfig config = new RubyInstanceConfig() {
        {
            //setInput(tar.getInputStream());
            //setOutput(new PrintStream(tar.getOutputStream()));
            //setError(new PrintStream(tar.getOutputStream()));
            setObjectSpaceEnabled(false);
        }
    };
    Ruby runtime = Ruby.newInstance(config);
    tar.hookIntoRuntimeWithStreams(runtime);

    run(runtime);
    return panel;
}
 
Example 5
Source File: ChooseFoundingFatherDialog.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The constructor that will add the items to this panel.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 * @param frame The owner frame.
 * @param possibleFoundingFathers The {@code FoundingFather}s
 *     which can be selected. The length of the array is the same
 *     as the number of {@code FoundingFather} categories and the
 *     values identifies a {@code FoundingFather} to be picked in
 *     each of those categories.
 */
public ChooseFoundingFatherDialog(FreeColClient freeColClient, JFrame frame,
        List<FoundingFather> possibleFoundingFathers) {
    super(freeColClient, frame);

    this.possibleFathers = possibleFoundingFathers;
    this.tb = new JTabbedPane(JTabbedPane.TOP);

    JButton helpButton = new JButton(freeColClient.getActionManager()
        .getFreeColAction("colopediaAction.fathers"));
    helpButton.setText(Messages.message("help"));

    FatherDetailPanel details = new FatherDetailPanel(freeColClient,
        new ColopediaPanel(freeColClient));
    for (FoundingFather father : possibleFoundingFathers) {
        JPanel jp = new MigPanel(new MigLayout());
        details.buildDetail(father, jp);
        jp.validate();
        tb.addTab(Messages.message(father.getTypeKey()), jp);
    }
    tb.setSelectedIndex(0);

    JPanel panel = new MigPanel(new MigLayout("wrap 1", "align center"));
    panel.add(Utility.localizedHeader("chooseFoundingFatherDialog.title", false));
    panel.add(helpButton, "tag help");
    panel.add(tb, "width 100%");

    List<ChoiceItem<FoundingFather>> c = choices();
    c.add(new ChoiceItem<>(Messages.message("ok"), (FoundingFather)null)
        .okOption().defaultOption());
    initializeDialog(frame, DialogType.QUESTION, false, panel, null, c);
}
 
Example 6
Source File: ParametersPanelListJPanel.java    From clearvolume with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void addPanel(JPanel pPanel)
{
	pPanel.setBorder(BorderFactory.createMatteBorder(	1,
														5,
														1,
														1,
														Color.black));
	pPanel.validate();
	add(pPanel);

}
 
Example 7
Source File: SeeOscillators.java    From jsyn with Apache License 2.0 5 votes vote down vote up
private void setupGUI() {
    setLayout(new BorderLayout());

    add(BorderLayout.NORTH, new JLabel("Show Oscillators in an AudioScope"));

    scope = new AudioScope(synth);
    AudioScopeProbe probe = scope.addProbe(oscGain.output);
    probe.setAutoScaleEnabled(false);
    probe.setVerticalScale(1.1);
    scope.setTriggerMode(AudioScope.TriggerMode.NORMAL);
    // scope.getModel().getTriggerModel().getLevelModel().setDoubleValue( 0.0001 );
    // Turn off the gain and trigger control GUI.
    scope.getView().setControlsVisible(false);
    scope.start();
    add(BorderLayout.CENTER, scope.getView());

    JPanel southPanel = new JPanel();
    southPanel.setLayout(new GridLayout(0, 1));
    add(BorderLayout.SOUTH, southPanel);

    oscPanel = new JPanel();
    oscPanel.setLayout(new GridLayout(2, 5));
    southPanel.add(oscPanel);

    southPanel.add(PortControllerFactory.createExponentialPortSlider(freqRamp.input));
    southPanel.add(PortControllerFactory.createExponentialPortSlider(oscGain.inputB));
    southPanel.add(widthSlider = PortControllerFactory.createPortSlider(widthRamp.input));
    widthSlider.setEnabled(false);
    southPanel.add(shapeSlider = PortControllerFactory.createPortSlider(shapeRamp.input));
    shapeSlider.setEnabled(false);

    oscPanel.validate();
    validate();
}
 
Example 8
Source File: SeeOscillators.java    From jsyn with Apache License 2.0 5 votes vote down vote up
private void setupGUI() {
    setLayout(new BorderLayout());

    add(BorderLayout.NORTH, new JLabel("Show Oscillators in an AudioScope"));

    scope = new AudioScope(synth);
    AudioScopeProbe probe = scope.addProbe(oscGain.output);
    probe.setAutoScaleEnabled(false);
    probe.setVerticalScale(1.1);
    scope.setTriggerMode(AudioScope.TriggerMode.NORMAL);
    // scope.getModel().getTriggerModel().getLevelModel().setDoubleValue( 0.0001 );
    // Turn off the gain and trigger control GUI.
    scope.getView().setControlsVisible(false);
    scope.start();
    add(BorderLayout.CENTER, scope.getView());

    JPanel southPanel = new JPanel();
    southPanel.setLayout(new GridLayout(0, 1));
    add(BorderLayout.SOUTH, southPanel);

    oscPanel = new JPanel();
    oscPanel.setLayout(new GridLayout(2, 5));
    southPanel.add(oscPanel);

    southPanel.add(PortControllerFactory.createExponentialPortSlider(freqRamp.input));
    southPanel.add(PortControllerFactory.createExponentialPortSlider(oscGain.inputB));
    southPanel.add(widthSlider = PortControllerFactory.createPortSlider(widthRamp.input));
    widthSlider.setEnabled(false);
    southPanel.add(shapeSlider = PortControllerFactory.createPortSlider(shapeRamp.input));
    shapeSlider.setEnabled(false);

    oscPanel.validate();
    validate();
}
 
Example 9
Source File: LegendBuilder.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
private void pack() {
	JPanel panel = new JPanel();
	if (dimension != null) {
		panel.setSize(dimension);
		panel.setLayout(new BorderLayout());
		panel.add(legendPanel, BorderLayout.CENTER);
	} else {
		panel.setSize(MAX_SIZE, MAX_SIZE);
		panel.setLayout(new FlowLayout());
		panel.add(legendPanel);
	}
	panel.addNotify();
	panel.validate();
}
 
Example 10
Source File: PreviewFileChooser.java    From pdfxtk with Apache License 2.0 5 votes vote down vote up
private void setPreview(JPanel panel, AbstractPreview p) {
  if(currentPreview != null) {
    panel.remove(currentPreview);
    currentPreview = null;
  }
  if(p != null) {
    currentPreview = p;
    panel.add(currentPreview, BorderLayout.CENTER);
    panel.validate();
    currentPreview.preview(currentFile);
  }    
}
 
Example 11
Source File: BreadCrumbComponent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void expand(int startX, final Node what) {
    if (what.getChildren().getNodesCount() == 0) return ;
    
    final ExplorerManager expandManager = new ExplorerManager();
    class Expanded extends JPanel implements ExplorerManager.Provider {
        public Expanded(LayoutManager layout) {
            super(layout);
        }
        @Override public ExplorerManager getExplorerManager() {
            return expandManager;
        }
    }
    final JPanel expanded = new Expanded(new BorderLayout());
    expanded.setBorder(new LineBorder(Color.BLACK, 1));
    
    final ListView listView = new ListView() {
        {
            int nodesCount = what.getChildren().getNodesCount();
            
            if (nodesCount >= MAX_ROWS_IN_POP_UP) {
                list.setVisibleRowCount(MAX_ROWS_IN_POP_UP);
            } else {
                list.setVisibleRowCount(nodesCount);
                
                NodeRenderer nr = new NodeRenderer();
                int i = 0;
                int width = getPreferredSize().width;
                
                for (Node n : what.getChildren().getNodes()) {
                    if (nr.getListCellRendererComponent(list, n, i, false, false).getPreferredSize().width > width) {
                        Dimension pref = getPreferredSize();
                        pref.height += getHorizontalScrollBar().getPreferredSize().height;
                        setPreferredSize(pref);
                        break;
                    }
                }
            }
        }
    };
    listView.setPopupAllowed(false);
    expanded.add(listView, BorderLayout.CENTER);
    expandManager.setRootContext(what);
    
    Point place = new Point(startX, 0);
    
    SwingUtilities.convertPointToScreen(place, this);
    
    expanded.validate();
    
    final Popup popup = PopupFactory.getSharedInstance().getPopup(this, expanded, place.x, place.y - expanded.getPreferredSize().height);
    final AWTEventListener multicastListener = new AWTEventListener() {
        @Override public void eventDispatched(AWTEvent event) {
                if (event instanceof MouseEvent && ((MouseEvent) event).getClickCount() > 0) {
                    Object source = event.getSource();
                    
                    while (source instanceof Component) {
                        if (source == expanded) return ; //accept
                        source = ((Component) source).getParent();
                    }
                    
                    popup.hide();
                    Toolkit.getDefaultToolkit().removeAWTEventListener(this);
                }
        }
    };
    
    Toolkit.getDefaultToolkit().addAWTEventListener(multicastListener, AWTEvent.MOUSE_EVENT_MASK);
    
    expandManager.addPropertyChangeListener(new PropertyChangeListener() {
        @Override public void propertyChange(PropertyChangeEvent evt) {
            if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) {
                Node[] selected = expandManager.getSelectedNodes();
                if (selected.length == 1) {
                    open(selected[0]);
                    popup.hide();
                    Toolkit.getDefaultToolkit().removeAWTEventListener(multicastListener);
                }
            }
        }
    });
    
    popup.show();
}
 
Example 12
Source File: ProcessorsListJPanelDemo.java    From clearvolume with GNU Lesser General Public License v3.0 4 votes vote down vote up
public JPanel getPanel(int pIndex)
{
	final JPanel lJPanel = new JPanel();

	final JLabel lJLabel = new JLabel("This is panel %" + pIndex);

	lJPanel.add(lJLabel);

	final JButton lJButton = new JButton();

	lJPanel.add(lJButton);

	lJPanel.validate();

	return lJPanel;
}
 
Example 13
Source File: Panels.java    From RipplePower with Apache License 2.0 4 votes vote down vote up
public static void invalidate(JPanel panel) {
	panel.validate();
	panel.repaint();
}