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

The following examples show how to use javax.swing.JPanel#revalidate() . 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> void viewAlgebraHelper(JComponent top, Algebra<Ty, En, Sym, Fk, Att, Gen, Sk, X, Y> algebra,
		JPanel out, JCheckBox simp, JSlider sl, Map<Pair<Boolean, Integer>, JScrollPane> cache) {
	boolean b = simp.isSelected();
	int l = sl.getValue();
	Pair<Boolean, Integer> p = new Pair<>(b, l);
	JScrollPane jsp = cache.get(p);
	if (jsp == null) {
		jsp = makeList2(algebra, b, l);
		cache.put(p, jsp);
	}
	out.removeAll();
	out.add(jsp, BorderLayout.CENTER);
	out.add(top, BorderLayout.SOUTH);
	out.revalidate();
	out.repaint();
}
 
Example 2
Source File: AndroidSdkNode.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: AndroidSdkNode.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
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 4
Source File: MainFrameComponentFactory.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Creates the source code panel, but does not put anything in it.
 */
JPanel createSourceCodePanel() {
    Font sourceFont = new Font("Monospaced", Font.PLAIN, (int) Driver.getFontSize());
    mainFrame.getSourceCodeTextPane().setFont(sourceFont);
    mainFrame.getSourceCodeTextPane().setEditable(false);
    mainFrame.getSourceCodeTextPane().getCaret().setSelectionVisible(true);
    mainFrame.getSourceCodeTextPane().setDocument(SourceCodeDisplay.SOURCE_NOT_RELEVANT);
    JScrollPane sourceCodeScrollPane = new JScrollPane(mainFrame.getSourceCodeTextPane());
    sourceCodeScrollPane.getVerticalScrollBar().setUnitIncrement(20);

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(sourceCodeScrollPane, BorderLayout.CENTER);

    panel.revalidate();
    if (MainFrame.GUI2_DEBUG) {
        System.out.println("Created source code panel");
    }
    return panel;
}
 
Example 5
Source File: CustomCodeView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 6
Source File: StringTableCellEditor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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 7
Source File: TracerDataSingleView.java    From pega-tracerviewer with Apache License 2.0 5 votes vote down vote up
@Override
protected void updateSupplementUtilityJPanel() {

    JPanel supplementUtilityJPanel = getSupplementUtilityJPanel();

    supplementUtilityJPanel.removeAll();
    LayoutManager layout = new BoxLayout(supplementUtilityJPanel, BoxLayout.LINE_AXIS);
    supplementUtilityJPanel.setLayout(layout);
    supplementUtilityJPanel.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1));

    supplementUtilityJPanel.revalidate();
    supplementUtilityJPanel.repaint();
}
 
Example 8
Source File: Main_UpperToolbar.java    From Hotel-Properties-Management-System with GNU General Public License v2.0 4 votes vote down vote up
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 9
Source File: BeltColumnStatisticsPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Updates the charts.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private void updateCharts() {
	for (int i = 0; i < listOfChartPanels.size(); i++) {
		JPanel panel = listOfChartPanels.get(i);
		panel.removeAll();
		JFreeChart chartOrNull = getModel().getChartOrNull(i);
		if (chartOrNull != null) {
			final ChartPanel chartPanel = new ChartPanel(chartOrNull) {

				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 10
Source File: AttributeStatisticsPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * 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 11
Source File: JTagsPanel.java    From MtgDesktopCompanion with GNU General Public License v3.0 4 votes vote down vote up
private void initGUI() {
	setLayout(new BorderLayout(0, 0));

	panelTags = new JPanel();
	FlowLayout flowLayout = (FlowLayout) panelTags.getLayout();
	flowLayout.setAlignment(FlowLayout.LEFT);
	add(panelTags, BorderLayout.CENTER);

	panelAdds = new JPanel();
	add(panelAdds, BorderLayout.EAST);
	panelAdds.setLayout(new BorderLayout(0, 0));

	btnAdd = new JButton();
	
	AbstractAction action = new AbstractAction("+") {
		private static final long serialVersionUID = 1L;
		@Override
		public void actionPerformed(ActionEvent ae) {
			JTextField field = new JTextField(10);
			panelTags.add(field);
			field.requestFocus();
			panelTags.revalidate();
			btnAdd.setEnabled(false);
			field.addActionListener(e -> {
				String s = field.getText();
				panelTags.remove(field);
				if (!s.equals(""))
					addTag(s);

				btnAdd.setEnabled(true);
				btnAdd.requestFocus();
			});

		}
	};

	btnAdd.setAction(action);

	btnAdd.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "ADD");
	btnAdd.getActionMap().put("ADD", action);
	panelAdds.add(btnAdd);
	componentFont = MTGControler.getInstance().getFont().deriveFont(Font.PLAIN, 15);

}
 
Example 12
Source File: AlignmentPanel.java    From AML-Project with Apache License 2.0 4 votes vote down vote up
/**
 * Refreshes the AlignmentReviewer
 */
public void refresh()
{
	dialogPanel = new JPanel();
	dialogPanel.setLayout(new BoxLayout(dialogPanel, BoxLayout.PAGE_AXIS));
	if(aml.hasAlignment())
	{
		//The header button panel
		selectAll = new JCheckBox("Select All/None");
		selectAll.addItemListener(this);
		setCorrect = new JButton("Set Correct");
		setCorrect.setBackground(AMLColor.GREEN);
		setCorrect.setPreferredSize(new Dimension(110,28));
		setCorrect.addActionListener(this);
		reset = new JButton("Reset");
		reset.setBackground(AMLColor.GRAY);
		reset.setPreferredSize(new Dimension(110,28));
		reset.addActionListener(this);
		setIncorrect = new JButton("Set Incorrect");
		setIncorrect.setBackground(AMLColor.RED);
		setIncorrect.setPreferredSize(new Dimension(110,28));
		setIncorrect.addActionListener(this);
		sortAsc = new JButton("Sort \u2191");
		sortAsc.setPreferredSize(new Dimension(110,28));
		sortAsc.addActionListener(this);
		sortDes = new JButton("Sort \u2193");
		sortDes.setPreferredSize(new Dimension(110,28));
		sortDes.addActionListener(this);
		search = new JButton("Search");
		search.setPreferredSize(new Dimension(110,28));
		search.addActionListener(this);
		headerPanel = new JPanel(new FlowLayout());
		headerPanel.setMaximumSize(new Dimension(headerPanel.getMaximumSize().width,30));
		JPanel left = new JPanel();
		left.setBorder(new BevelBorder(1));
		left.add(selectAll);
		left.add(setCorrect);
		left.add(reset);
		left.add(setIncorrect);
		headerPanel.add(left);
		JPanel right = new JPanel();
		right.setBorder(new BevelBorder(1));
		right.add(sortAsc);
		right.add(sortDes);
		right.add(search);
		headerPanel.add(right);
		
		//The mapping list
		mappingPanel = new JPanel(new GridLayout(0,1));
		a = aml.getAlignment();
		check = new Vector<JCheckBox>();
		mappings = new Vector<MappingButton>(a.size());
		mappingPanel.setMaximumSize(new Dimension(mappingPanel.getMaximumSize().width,a.size()*30));
		for(Mapping m : a)
		{
			JCheckBox c = new JCheckBox(""); 
			check.add(c);
			MappingButton b = new MappingButton(m);
			mappings.add(b);
			b.addActionListener(this);
			JPanel subPanel = new JPanel(new BorderLayout());
			subPanel.add(c,BorderLayout.LINE_START);
			JPanel subSubPanel = new JPanel(new BorderLayout());
			subSubPanel.add(b,BorderLayout.LINE_START);
			subPanel.add(subSubPanel, BorderLayout.CENTER);
			subPanel.setMaximumSize(new Dimension(subPanel.getMaximumSize().width,28));
			subPanel.setPreferredSize(new Dimension(subPanel.getPreferredSize().width,28));
			mappingPanel.add(subPanel);
		}
		JPanel alignment = new JPanel();
		alignment.setLayout(new BoxLayout(alignment, BoxLayout.PAGE_AXIS));
		alignment.add(mappingPanel);
		JPanel filler = new JPanel();
		alignment.add(filler);
		scrollPane = new JScrollPane(alignment);
		scrollPane.setBorder(new BevelBorder(1));
		scrollPane.getVerticalScrollBar().setUnitIncrement(28);
		scrollPane.setBackground(AMLColor.WHITE);
		dialogPanel.add(headerPanel);
		dialogPanel.add(scrollPane);
	}
	setContentPane(dialogPanel);
	dialogPanel.revalidate();
	dialogPanel.repaint();
	this.pack();
	this.setVisible(true);
}
 
Example 13
Source File: JdotxtPreferencesDialog.java    From jdotxt with GNU General Public License v3.0 4 votes vote down vote up
private JPanel getHelpPanel() {
	JPanel panel = new JPanel();
	panel.setLayout(new BorderLayout());
	panel.setBackground(Color.WHITE);
	panel.setOpaque(true);

	JLabel labelIcon = new JLabel(new ImageIcon(JdotxtGUI.icon.getImage().getScaledInstance(64, 64, java.awt.Image.SCALE_SMOOTH)));
	labelIcon.setVerticalAlignment(SwingConstants.TOP);
	panel.add(labelIcon, BorderLayout.WEST);
	labelIcon.setPreferredSize(new Dimension(100, 100));

	JPanel panelInfo = new JPanel();
	panel.add(panelInfo, BorderLayout.CENTER);
	panelInfo.setLayout(new BoxLayout(panelInfo, BoxLayout.Y_AXIS));
	panelInfo.add(Box.createVerticalStrut(10));
	panelInfo.setBackground(Color.WHITE);
	panelInfo.setOpaque(true);

	JLabel labelTitle = new JLabel(JdotxtGUI.lang.getWord("jdotxt") + " (Version " + Jdotxt.VERSION + ")");
	labelTitle.setFont(JdotxtGUI.fontB.deriveFont(16f));
	panelInfo.add(labelTitle);

	panelInfo.add(Box.createVerticalStrut(20));

	JEditorPane textInfo = new JEditorPane();
	textInfo.setContentType("text/html");
	textInfo.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
	textInfo.setFont(JdotxtGUI.fontR);
	textInfo.setText(JdotxtGUI.lang.getWord("Text_help"));
	textInfo.setEditable(false);
	textInfo.setFocusable(false);
	textInfo.setAlignmentX(Component.LEFT_ALIGNMENT);
	textInfo.setBorder(BorderFactory.createEmptyBorder());
	textInfo.setMaximumSize(textInfo.getPreferredSize());

	panelInfo.add(textInfo);

	panelInfo.add(Box.createVerticalStrut(20));

	JLabel labelShortcuts = new JLabel(JdotxtGUI.lang.getWord("Shortcuts"));
	labelShortcuts.setFont(JdotxtGUI.fontB.deriveFont(14f));
	panelInfo.add(labelShortcuts);

	panelInfo.add(Box.createVerticalStrut(20));

	JEditorPane textShortcuts = new JEditorPane();
	textShortcuts.setContentType("text/html");
	textShortcuts.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
	textShortcuts.setFont(JdotxtGUI.fontR);
	textShortcuts.setText(JdotxtGUI.lang.getWord("Text_shortcuts"));
	textShortcuts.setEditable(false);
	textShortcuts.setFocusable(false);
	textShortcuts.setAlignmentX(Component.LEFT_ALIGNMENT);
	textShortcuts.setBorder(BorderFactory.createEmptyBorder());
	textShortcuts.setMaximumSize(textShortcuts.getPreferredSize());

	panelInfo.add(textShortcuts);
	panelInfo.add(Box.createVerticalGlue());

	panel.revalidate();
	return panel;
}