/** * Creates a new instance of <code>JXBusyLabel</code> initialized to the arbitrary size and using default circular progress indicator. * @param dim Preferred size of the label. */ public JXBusyLabel(Dimension dim) { super(); this.setPreferredSize(dim); // Initialize the BusyPainter. getBusyPainter(); }
private BusyLabel(JScrollPane scrollpane, String text, JComponent component) { this.scrollPane = scrollpane; this.component = component; busyLabel = new JXBusyLabel(new Dimension(20, 20)); busyLabel.setText(text); busyLabel.setHorizontalAlignment(SwingConstants.CENTER); }
/** * <p>Sets whether this <code>JXBusyLabel</code> instance should consider * itself busy. A busy component may indicate that it is busy via animation, * or some other means.</p> * * @param busy whether this <code>JXBusyLabel</code> instance should * consider itself busy */ public void setBusy(boolean busy) { boolean old = isBusy(); if (!old && busy) { startAnimation(); firePropertyChange("busy", old, isBusy()); } else if (old && !busy) { stopAnimation(); firePropertyChange("busy", old, isBusy()); } }
/** * Returns the current BusyPainter. If no BusyPainter is currently * set on this BusyLabel, the {@link #createBusyPainter(Dimension)} * method is called to create one. Afterwards, * {@link #initPainter(Dimension)} is called to update the BusyLabel * with the created BusyPainter. * * @return the busyPainter * * @see #createBusyPainter(Dimension) * @see #initPainter(Dimension) */ public final BusyPainter getBusyPainter() { if (null == busyPainter) { Dimension prefSize = getPreferredSize(); busyPainter = createBusyPainter((prefSize.width == 0 && prefSize.height == 0 && !isPreferredSizeSet()) ? null : prefSize); if (null != busyPainter) { if (!isPreferredSizeSet() && (null == prefSize || prefSize.width == 0 || prefSize.height == 0)) { Rectangle rt = busyPainter.getTrajectory().getBounds(); Rectangle rp = busyPainter.getPointShape().getBounds(); int max = Math.max(rp.width, rp.height); prefSize = new Dimension(rt.width + max, rt.height + max); } initPainter(prefSize); } } return busyPainter; }
/** * @param busyPainter the busyPainter to set */ public final void setBusyPainter(BusyPainter busyPainter) { this.busyPainter = busyPainter; initPainter(new Dimension(getIcon().getIconWidth(), getIcon().getIconHeight())); }
private void stopAnimation() { if (busy != null) { busy.stop(); getBusyPainter().setFrame(-1); repaint(); busy = null; } }
/** * @param delay the delay to set */ public void setDelay(int delay) { int old = getDelay(); this.delay = delay; if (old != getDelay()) { if (busy != null && busy.isRunning()) { busy.setDelay(getDelay()); } firePropertyChange("delay", old, getDelay()); } } //------------------------------------------------------------- UI Logic
private void startAnimation() { if(busy != null) { stopAnimation(); } busy = new Timer(delay, new ActionListener() { BusyPainter busyPainter = getBusyPainter(); int frame = busyPainter.getPoints(); public void actionPerformed(ActionEvent e) { frame = (frame+1)%busyPainter.getPoints(); busyPainter.setFrame(direction == Direction.LEFT ? busyPainter.getPoints() - frame : frame); frameChanged(); } }); busy.start(); }
/** * Initialize the BusyPainter and (this) JXBusyLabel with the given * preferred size. This method is called automatically when the * BusyPainter is set/changed. * * @param dim The new Preferred Size for the BusyLabel. * * @see #getBusyPainter() * @see #setBusyPainter(BusyPainter) */ protected void initPainter(Dimension dim) { BusyPainter busyPainter = getBusyPainter(); // headw01 // TODO: Should we force the busyPainter to NOT be cached? // I think we probably should, otherwise the UI will never // be updated after the first paint. if (null != busyPainter) { busyPainter.setCacheable(false); } PainterIcon icon = new PainterIcon(dim); icon.setPainter(busyPainter); this.setIcon(icon); } /**
java.awt.GridBagConstraints gridBagConstraints; busyLabel = new org.jdesktop.swingx.JXBusyLabel(new Dimension(16, 16)); displayLabel = new javax.swing.JLabel(); resultLabel = new javax.swing.JLabel(); setLayout(new java.awt.GridBagLayout()); busyLabel.setText(org.openide.util.NbBundle.getMessage(StatisticsFrontEnd.class, "StatisticsFrontEnd.busyLabel.text")); // NOI18N busyLabel.setMinimumSize(new java.awt.Dimension(16, 16)); busyLabel.setPreferredSize(new java.awt.Dimension(16, 16)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0;
busyLabel.setBusy(false); busyLabel.setVisible(false); reportButton.setEnabled(false); resultLabel.setText(""); runButton.setText(CANCEL); busyLabel.setVisible(true); busyLabel.setBusy(true); reportButton.setEnabled(false); resultLabel.setText(""); runButton.setText(RUN); busyLabel.setBusy(false); busyLabel.setVisible(false); currentStatistics = null; refreshResult(model);
@Override public void actionPerformed(ActionEvent e) { frame = (frame+1)%busyPainter.getPoints(); busyPainter.setFrame(direction == BusyPainter.Direction.LEFT ? busyPainter.getPoints() - frame : frame); frameChanged(); } });
/** * Sets direction of rotation. <code>Direction.RIGHT</code> is the default * value. Direction is taken from the very top point so <code>Direction.RIGHT</code> enables rotation clockwise. * @param dir Direction of rotation. */ public void setDirection(BusyPainter.Direction dir) { direction = dir; getBusyPainter().setDirection(dir); }
busyPanel.setLayout(new BoxLayout(busyPanel, BoxLayout.X_AXIS)); busyLabel = new JXBusyLabel(new Dimension(15, 15)); busyLabel.setVisible(false); busyLabel.setName("busyLabel"); busyPanel.add(busyLabel);
java.awt.GridBagConstraints gridBagConstraints; southBusyLabel = new JXBusyLabel(new Dimension(14,14)); bannerPanel = new javax.swing.JPanel(); bannerLabel = new javax.swing.JLabel(); sketchPanel = new javax.swing.JPanel(); refreshPanel = new javax.swing.JPanel(); busyLabel = new JXBusyLabel(new Dimension(20,20)); southToolbar = new javax.swing.JToolBar(); backgroundButton = new JColorButton(Color.WHITE);
/** * <p>Sets whether this <code>JXBusyLabel</code> instance should consider * itself busy. A busy component may indicate that it is busy via animation, * or some other means.</p> * * @param busy whether this <code>JXBusyLabel</code> instance should * consider itself busy */ public void setBusy(boolean busy) { boolean old = isBusy(); if (!old && busy) { startAnimation(); firePropertyChange("busy", old, isBusy()); } else if (old && !busy) { stopAnimation(); firePropertyChange("busy", old, isBusy()); } }
/** * Returns the current BusyPainter. If no BusyPainter is currently * set on this BusyLabel, the {@link #createBusyPainter(Dimension)} * method is called to create one. Afterwards, * {@link #initPainter(Dimension)} is called to update the BusyLabel * with the created BusyPainter. * * @return the busyPainter * * @see #createBusyPainter(Dimension) * @see #initPainter(Dimension) */ public final BusyPainter getBusyPainter() { if (null == busyPainter) { Dimension prefSize = getPreferredSize(); busyPainter = createBusyPainter((prefSize.width == 0 && prefSize.height == 0 && !isPreferredSizeSet()) ? null : prefSize); if (null != busyPainter) { if (!isPreferredSizeSet() && (null == prefSize || prefSize.width == 0 || prefSize.height == 0)) { Rectangle rt = busyPainter.getTrajectory().getBounds(); Rectangle rp = busyPainter.getPointShape().getBounds(); int max = Math.max(rp.width, rp.height); prefSize = new Dimension(rt.width + max, rt.height + max); } initPainter(prefSize); } } return busyPainter; }
/** * @param busyPainter the busyPainter to set */ public final void setBusyPainter(BusyPainter busyPainter) { this.busyPainter = busyPainter; initPainter(new Dimension(getIcon().getIconWidth(), getIcon().getIconHeight())); }
private void stopAnimation() { if (busy != null) { busy.stop(); getBusyPainter().setFrame(-1); repaint(); busy = null; } }