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

The following examples show how to use javax.swing.JPanel#repaint() . 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: StreamPanel.java    From moa with GNU General Public License v3.0 6 votes vote down vote up
private void drawClustering(JPanel layer, Clustering clustering, List<DataPoint> points, Color color){
    if (clustering.get(0) instanceof NonConvexCluster) {
    	drawNonConvexClustering(layer, clustering, points, color);
    } else {	
 	layer.removeAll();
     for (int c = 0; c < clustering.size(); c++) {
         SphereCluster cluster = (SphereCluster)clustering.get(c);
	
         ClusterPanel clusterpanel = new ClusterPanel(cluster, color, this);
         
         layer.add(clusterpanel);
         clusterpanel.updateLocation();
     }
	
     if(layer.isVisible() && pointsVisible){
         Graphics2D imageGraphics = (Graphics2D) pointCanvas.createGraphics();
         imageGraphics.setColor(color);
         drawClusteringsOnCanvas(layer, imageGraphics);
         layerPointCanvas.repaint();
     }
	
     layer.repaint();
    }
}
 
Example 3
Source File: StreamOutlierPanel.java    From moa with GNU General Public License v3.0 6 votes vote down vote up
private void drawOutliers(JPanel layer, Vector<Outlier> outliers, Color color){        
    layer.removeAll();
    for (Outlier outlier : outliers) {  
        int length = outlier.inst.numValues() - 1; // -1
        double[] center = new double[length]; // last value is the class
        for (int i = 0; i < length; i++) {
            center[i] = outlier.inst.value(i);                
        }            
        SphereCluster cluster = new SphereCluster(center, 0);                
            
        OutlierPanel outlierpanel = new OutlierPanel(m_outlierDetector, outlier, cluster, color, this);
        
        layer.add(outlierpanel);
        outlierpanel.updateLocation();
    }

    layer.repaint();
}
 
Example 4
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 5
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 6
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 7
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 8
Source File: JavaMixer.java    From Spark with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    final JavaMixer sm = new JavaMixer();
    final JFrame jf = new JFrame("Mixer Test");
    final JPanel jp = new JPanel();
    jf.add(jp);
    jp.add(sm.getTree());
    jf.setSize(600, 500);
    jf.setVisible(true);
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    sm.getTree().addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            TreePath path = e.getPath();
            if (path.getLastPathComponent() instanceof JavaMixer.ControlNode) {
                JavaMixer.ControlNode controlNode = (JavaMixer.ControlNode) path.getLastPathComponent();
                if (!(controlNode.getControl() instanceof CompoundControl)) {
                    if (jp.getComponentCount() > 1)
                        jp.remove(1);
                    jp.add(controlNode.getComponent(), 1);
                    jp.repaint();
                }
            }
        }
    });
    jp.add(sm.getPrefferedMasterVolume());
    jp.add(sm.getPrefferedMasterVolume());
    jp.add(sm.getPrefferedInputVolume());
    jp.repaint();
    sm.setMicrophoneInput();
    sm.setMuteForMicrophoneOutput();
}
 
Example 9
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 10
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 11
Source File: MenuEditLayer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void rebuildOnScreenMenu(RADVisualContainer menuRAD) {
    if(menuRAD == null) return;
    if(hackedPopupFactory == null) return;
    JMenu menu = (JMenu) formDesigner.getComponent(menuRAD);
    if(hackedPopupFactory.containerMap.containsKey(menu)) {
        JPanel popupContainer = hackedPopupFactory.containerMap.get(menu);
        if(popupContainer == null) return;
        for(Component c : popupContainer.getComponents()) {
            if(c instanceof JMenu) {
                unconfigureMenu((JMenu)c);
            } else {
                unconfigureMenuItem((JComponent)c);
            }
        }
        popupContainer.removeAll();
        // rebuild it
        for(RADVisualComponent child : menuRAD.getSubComponents()) {
            if(child != null) {
                JComponent jchild = (JComponent) formDesigner.getComponent(child);
                if(!isConfigured(jchild)) {
                    if(jchild instanceof JMenu) {
                        configureMenu(menu, (JMenu)jchild);
                    } else {
                        configureMenuItem(menu,jchild);
                    }
                }
                popupContainer.add(jchild);
            }
        }
        
        // repack it
        popupContainer.setSize(popupContainer.getLayout().preferredLayoutSize(popupContainer));
        validate();
        popupContainer.repaint();
    }
}
 
Example 12
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 13
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 14
Source File: GeochronProjectExportManager.java    From ET_Redux with Apache License 2.0 4 votes vote down vote up
private void initSamplesDisplay() {
    aliquotsLayeredPane.removeAll();

    int leftMargin = 40;
    int topMarginForSampleDetails = 10;

    int row = 0;
    int initialSampleHeight = 75;
    for (SampleInterface sample : project.getProjectSamples()) {
        if (!sample.isReferenceMaterial()) {
            JPanel geochronAliquotManager
                    = new GeochronAliquotManager(
                            project,// needs to be interfaced
                            sample, //
                            myState.getReduxPreferences().getGeochronUserName(), //
                            myState.getReduxPreferences().getGeochronPassWord(), //
                            geoSamplesUserCode, //
                            leftMargin, //
                            topMarginForSampleDetails + row * initialSampleHeight, 1100, initialSampleHeight);
            aliquotsLayeredPane.add(geochronAliquotManager, JLayeredPane.DEFAULT_LAYER);
            geochronAliquotManager.repaint();

            row++;
        }
    }

    aliquotsScrollPane.setPreferredSize(new Dimension(1100, topMarginForSampleDetails + (row + 1) * 100));
    aliquotsScrollPane.validate();
    aliquotsLayeredPane.setPreferredSize(new Dimension(1100, topMarginForSampleDetails + (row + 1) * 100));
    aliquotsLayeredPane.validate();

    instructionsTextPane.addHyperlinkListener((HyperlinkEvent e) -> {
        if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
            if (Desktop.isDesktopSupported()) {
                try {
                    Desktop.getDesktop().browse(e.getURL().toURI());
                } catch (IOException | URISyntaxException e1) {
                }
            }
        }
    });

    revalidate();
}
 
Example 15
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();
}
 
Example 16
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 17
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);
}