Java Code Examples for javax.swing.JPanel.revalidate()

The following are Jave code examples for showing how to use revalidate() of the javax.swing.JPanel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: NBANDROID-V2   File: AndroidSdkNode.java   View Source Code Vote up 6 votes
@Override
public void sdkValid() {
    fireIconChange();
    fireOpenedIconChange();
    setChildren(Children.create(new AndroidPlatformChildrenFactory(platform, holder), false));
    JPanel tmp = lastBrokenPanel.get();
    if (tmp != null) {
        tmp.removeAll();
        tmp.invalidate();
        tmp.repaint();
        tmp.setLayout(new java.awt.CardLayout());
        tmp.add(new AndroidSdkCustomizer(platform, holder));
        tmp.revalidate();
        tmp.repaint();
        tmp.requestFocus();
    }
}
 
Example 2
Project: NBANDROID-V2   File: AndroidSdkNode.java   View Source Code Vote up 6 votes
public void updateCustomizer() {
    if (valid != platform.isValid()) {
        valid = platform.isValid();
        setChildren(Children.create(new AndroidPlatformChildrenFactory(platform, holder), false));
        JPanel tmp = lastBrokenPanel.get();
        if (tmp != null) {
            tmp.removeAll();
            tmp.invalidate();
            tmp.repaint();
            tmp.setLayout(new java.awt.CardLayout());
            if (platform.isValid()) {
                tmp.add(new AndroidSdkCustomizer(platform, holder));
            } else {
                tmp.add(new BrokenPlatformCustomizer(platform, holder, this));
            }
            tmp.revalidate();
            tmp.repaint();
            tmp.requestFocus();
        }
    }
}
 
Example 3
Project: incubator-netbeans   File: CustomCodeView.java   View Source Code Vote up 5 votes
private void contentChange(DocumentEvent e) {
            changed = true;

            Document doc = e.getDocument();
            CodeCategory category = getCategoryForDocument(doc);
            int eBlockIndex = getEditBlockIndex(category, e.getOffset());
            if (eBlockIndex < 0) {
                return;
            }

            List<EditableLine> lines = getEditInfos(category)[eBlockIndex].lines;
            int[] blockBounds = getEditBlockBounds(category, eBlockIndex);
            boolean repaint = false;

            Integer lastLineCount = lastDocLineCounts.get(doc);
            int lineCount = getLineCount(doc);
            if (lastLineCount == null || lastLineCount.intValue() != lineCount) {
                lastDocLineCounts.put(doc, Integer.valueOf(lineCount));
                updateLines(doc, blockBounds[0], blockBounds[1], lines,
                            codeData.getEditableBlock(category, eBlockIndex));
                repaint = true;
                // make sure our listener is invoked after position listeners update
                doc.removeDocumentListener(this);
                doc.addDocumentListener(this);
            }

            repaint |= updateGutterComponents(lines, doc, blockBounds[0], blockBounds[1]);

            if (repaint) {
                JPanel gutter = getGutter(doc);
                gutter.revalidate();
                gutter.repaint();
            }
//            ((BaseDocument)doc).resetUndoMerge();
        }
 
Example 4
Project: incubator-netbeans   File: StringTableCellEditor.java   View Source Code Vote up 5 votes
@Override
public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, final int row, final int column) {
    final JComponent c = (JComponent) super.getTableCellEditorComponent(table, value, isSelected, row, column);      
    
    this.tableModel = table.getModel();
    this.columnName = table.getColumnName(column);
    this.modelRow = table.convertRowIndexToModel(row);
    this.modelColumn = table.convertColumnIndexToModel(column);  
    this.tc = c instanceof JTextComponent ? (JTextComponent) c : null;

    JPanel panel = new JPanel(new BorderLayout()) {
        @Override
        public void addNotify() {
            super.addNotify();
            c.requestFocus();
        }
    };
    panel.add(c);
    if (suppressEditorBorder) {
        c.setBorder(BorderFactory.createEmptyBorder());
    }
    panel.add(customEditorButton, BorderLayout.EAST);
    panel.revalidate();
    panel.repaint();

    return panel;
}
 
Example 5
Project: Equella   File: Wizard.java   View Source Code Vote up 5 votes
public void replacePage(JPanel parent, JPanel child)
{
	parent.removeAll();
	parent.add(child);
	parent.revalidate();
	parent.repaint();
}
 
Example 6
Project: jaer   File: ImageDisplayWriter.java   View Source Code Vote up 5 votes
@Override
public void setPanel(JPanel imagePanel) {
	hostPanel=imagePanel;

	imagePanel.setPreferredSize(new Dimension(300,300));
	imagePanel.setLayout(new GridLayout());
	imagePanel.revalidate();
	imagePanel.add(this);
}
 
Example 7
Project: Tarski   File: RelationModelEditor.java   View Source Code Vote up 5 votes
public static void addGraphToFrame(final JPanel graph) {
  if (RelationModelEditor.frame == null) {
    RelationModelEditor.frame = SWT_AWT.new_Frame(RelationModelEditor.animationEditor);
  }
  if (RelationModelEditor.frame.getComponents().length > 0) {
    RelationModelEditor.frame.remove(0);
  }
  RelationModelEditor.frame.revalidate();
  graph.revalidate();
  RelationModelEditor.frame.add(graph);
}
 
Example 8
Project: rapidminer   File: AttributeStatisticsPanel.java   View Source Code Vote up 4 votes
/**
 * Updates the charts.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private void updateCharts() {
	for (int i = 0; i < listOfChartPanels.size(); i++) {
		JPanel panel = listOfChartPanels.get(i);
		panel.removeAll();
		final ChartPanel chartPanel = new ChartPanel(getModel().getChartOrNull(i)) {

			private static final long serialVersionUID = -6953213567063104487L;

			@Override
			public Dimension getPreferredSize() {
				return DIMENSION_CHART_PANEL_ENLARGED;
			}
		};
		chartPanel.setPopupMenu(null);
		chartPanel.setBackground(COLOR_TRANSPARENT);
		chartPanel.setOpaque(false);
		chartPanel.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
		panel.add(chartPanel, BorderLayout.CENTER);

		JPanel openChartPanel = new JPanel(new GridBagLayout());
		openChartPanel.setOpaque(false);

		GridBagConstraints gbc = new GridBagConstraints();
		gbc.anchor = GridBagConstraints.CENTER;
		gbc.fill = GridBagConstraints.NONE;
		gbc.weightx = 1.0;
		gbc.weighty = 1.0;

		JButton openChartButton = new JButton(OPEN_CHART_ACTION);
		openChartButton.setOpaque(false);
		openChartButton.setContentAreaFilled(false);
		openChartButton.setBorderPainted(false);
		openChartButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
		openChartButton.setHorizontalAlignment(SwingConstants.LEFT);
		openChartButton.setHorizontalTextPosition(SwingConstants.LEFT);
		openChartButton.setIcon(null);
		Font font = openChartButton.getFont();
		Map attributes = font.getAttributes();
		attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
		openChartButton.setFont(font.deriveFont(attributes).deriveFont(10.0f));

		openChartPanel.add(openChartButton, gbc);

		panel.add(openChartPanel, BorderLayout.SOUTH);
		panel.revalidate();
		panel.repaint();
	}
}
 
Example 9
Project: rapidminer   File: OpenProcessCard.java   View Source Code Vote up 4 votes
private JPanel createRecoverButtonPanel(final AutoSave autosave) {
    final JPanel buttonPanel = new JPanel();
    buttonPanel.setBackground(WARNING_BACKGROUND_COLOR);
    final JLabel recoverLabel = new JLabel(I18N.getGUILabel("getting_started.label.recover", new Object[0]));
    recoverLabel.setIcon(SwingTools.createIcon("16/loading.gif"));
    recoverLabel.setFont(GettingStartedDialog.OPEN_SANS_SEMIBOLD_14);
    recoverLabel.setForeground(WARNING_TEXT_COLOR);
    recoverLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
    String autosavedPath = autosave.getAutosavedPath();
    JButton recoverButton = new JButton(new ResourceAction("getting_started.recover", new Object[]{autosavedPath == null?"autosaved process":autosavedPath}) {
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            if(OpenProcessCard.this.entryList != null) {
                OpenProcessCard.this.entryList.setFocusable(false);
            }

            buttonPanel.removeAll();
            buttonPanel.add(recoverLabel);
            buttonPanel.revalidate();
            (new ProgressThread("recover_process") {
                public void run() {
                    autosave.recoverAutosavedProcess();
                    SwingTools.invokeLater(new Runnable() {
                        public void run() {
                            if(OpenProcessCard.this.entryList != null) {
                                OpenProcessCard.this.entryList.setFocusable(true);
                            }

                            OpenProcessCard.this.owner.dispose();
                        }
                    });
                }
            }).start();
        }
    });
    this.styleButton(recoverButton);
    buttonPanel.add(recoverButton);
    this.owner.getRootPane().setDefaultButton(recoverButton);
    return buttonPanel;
}
 
Example 10
Project: Hotel-Properties-Management-System   File: Main_UpperToolbar.java   View Source Code Vote up 4 votes
public ActionListener UpperToolbarActionListener(final JPanel mainPanel) {

        ActionListener actionListener = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {

                if (e.getSource() == roomsBtn) {

                    theRooms = new Main_AllRooms();
                    infoColorTable = new ColorInfoTable();

                    // Set the usage of room into info table
                    infoColorTable.setCleanLabelCount(theRooms.cleanCounter);
                    infoColorTable.setDirtyLabelCount(theRooms.dirtyCounter);
                    infoColorTable.setDndLabelCount(theRooms.dndCounter);

                    mainPanel.removeAll();
                    mainPanel.add(theRooms.getWindow(), BorderLayout.WEST);
                    mainPanel.add(infoColorTable, BorderLayout.EAST);
                    mainPanel.revalidate();
                    mainPanel.repaint();

                } else if (e.getSource() == guestsBtn) {

                    customersFrame = new Main_CustomersFrame();
                    mainPanel.removeAll();
                    mainPanel.add(customersFrame, BorderLayout.CENTER);
                    mainPanel.revalidate();
                    mainPanel.repaint();
                } else if (e.getSource() == rezervationBtn) {

                    rezervFrame = new Main_Reservations();
                    mainPanel.removeAll();
                    rezervFrame.populateMainTable();
                    mainPanel.add(rezervFrame, BorderLayout.CENTER);
                    mainPanel.revalidate();
                    mainPanel.repaint();
                } else if (e.getSource() == blockadeBtn) {

                    blockadeFrame = new Main_Blockade();
                    mainPanel.removeAll();
                    mainPanel.add(blockadeFrame, BorderLayout.CENTER);
                    mainPanel.revalidate();
                    mainPanel.repaint();

                } else if (e.getSource() == roomCleaningBtn) {

                    cleaningFrame = new Main_RoomCleaning();
                    mainPanel.removeAll();
                    mainPanel.add(cleaningFrame, BorderLayout.CENTER);
                    mainPanel.revalidate();
                    mainPanel.repaint();
                } else if (e.getSource() == cashBtn) {

                    cashdesk = new Main_CashDesk();
                    mainPanel.removeAll();
                    mainPanel.add(cashdesk, BorderLayout.CENTER);
                    mainPanel.revalidate();
                    mainPanel.repaint();
                } else if (e.getSource() == auditBtn) {

                    audit = new Main_Audit();
                    audit.initializeAuditPane();
                    mainPanel.removeAll();
                    mainPanel.add(audit, BorderLayout.CENTER);
                    mainPanel.revalidate();
                    mainPanel.repaint();

                } else if (e.getSource() == refreshBtn) {
                    mainPanel.removeAll();
                    mainPanel.revalidate();
                    mainPanel.repaint();
                }
            }
        };
        return actionListener;
    }
 
Example 11
Project: Equella   File: InternalDataSourceTab.java   View Source Code Vote up 4 votes
private void attemptToShowFullUi()
{
	if( tree != null )
	{
		return;
	}

	GlassSwingWorker<?> worker = new GlassSwingWorker<Boolean>()
	{
		private Map<String, Pair<String, String>> predefinedTermDataKeys;

		@Override
		public Boolean construct() throws Exception
		{
			boolean valid = taxonomy != null
				&& clientService.getService(RemoteTaxonomyService.class).identifyByUuid(taxonomy.getUuid()) != 0;
			if( valid )
			{
				predefinedTermDataKeys = new HashMap<String, Pair<String, String>>();
				for( Extension ext : pluginService.getConnectedExtensions("com.tle.admin.taxonomy.tool",
					"predefinedTermDataKey") )
				{
					final String key = ext.getParameter("key").valueAsString();
					final String name = CurrentLocale.get(ext.getParameter("name").valueAsString());
					final String desc = CurrentLocale.get(ext.getParameter("description").valueAsString());

					predefinedTermDataKeys.put(key, new Pair<String, String>(name, desc));
				}
			}
			return valid;
		}

		@Override
		public void finished()
		{
			if( !get() )
			{
				return;
			}

			final JPanel p = InternalDataSourceTab.this;

			// Remove this listener and clear the panel
			p.removeComponentListener(ensureTaxonomySavedListener);
			p.removeAll();

			final RemoteTermService termService = clientService.getService(RemoteTermService.class);

			tree = new AbstractTreeEditor<TermTreeNode>()
			{
				@Override
				protected AbstractTreeEditorTree<TermTreeNode> createTree()
				{
					return new TermTree(taxonomy, true, termService);
				}

				@Override
				protected AbstractTreeNodeEditor createEditor(TermTreeNode node)
				{
					return new TermEditor(termService, predefinedTermDataKeys, taxonomy, node);
				}
			};

			p.setLayout(new MigLayout("wrap 1, fill"));
			p.add(new JLabel("<html>" + s("immediatechanges")));
			p.add(tree, "push, grow");

			p.revalidate();
			p.repaint();
		}
	};
	worker.setComponent(InternalDataSourceTab.this);
	worker.start();
}