Java 类javax.swing.plaf.basic.BasicProgressBarUI 实例源码

项目:Bootstrapper    文件:ProgressSplashScreen.java   
public ProgressSplashScreen() {
    super(Toolkit.getDefaultToolkit().getImage(SplashScreen.class.getResource("/splash.png")));

    this.progressBar.setFont(new Font("Arial", 0, 12));
    this.progressBar.setMaximum(100);
    this.progressBar.setBounds(0, this.icon.getIconHeight(), this.icon.getIconWidth(), 20);
    this.progressBar.setString("Downloading launcher updates...");
    this.progressBar.setStringPainted(true);
    this.progressBar.setBackground(Color.BLACK);
    this.progressBar.setForeground(Color.CYAN);
    this.progressBar.setUI(new BasicProgressBarUI() {
        protected Color getSelectionBackground() {
            return Color.cyan;
        }

        protected Color getSelectionForeground() {
            return Color.black;
        }
    });
    getContentPane().add(this.progressBar);
    setVisible(true);
}
项目:featurea    文件:FSProgressBar.java   
public FSProgressBar() {
    setBorder(BorderFactory.createEmptyBorder());
    setUI(new BasicProgressBarUI() {
        @Override
        public void paint(Graphics g, JComponent component) {
            super.paint(g, component);
            Graphics2D graphics = (Graphics2D) g;
            int dy = (int) ((component.getHeight() - progressHeight) / 2);
            int x1 = paddingX;
            int y1 = dy;
            int width = (int) ((component.getWidth() - 2 * paddingX) * progress);
            int height = (int) progressHeight;
            graphics.setColor(FSProgressBarUI.GRAY_128);
            graphics.fillRect(x1, y1, width, height);
        }
    });
    setIndeterminate(false);
}
项目:dsworkbench    文件:ColoredProgressBar.java   
public ColoredProgressBar(int start, int end) {
    setMinimum(start);
    setMaximum(end);
    setForeground(SystemColor.window);
    setBackground(SystemColor.window);
    setBorder(new EmptyBorder(3, 5, 3, 5));
    Dimension size = new Dimension(300, 20);
    setPreferredSize(size);
    setMaximumSize(size);
    setMinimumSize(size);
    BasicProgressBarUI ui = new BasicProgressBarUI() {

        protected Color getSelectionForeground() {
            return Color.BLACK;
        }

        protected Color getSelectionBackground() {
            return Color.BLACK;
        }
    };
    setUI(ui);
}
项目:WorldGrower    文件:TiledHorizontalImageProgressBar.java   
private void changeUI() {
    setOpaque(false);
    setUI(new BasicProgressBarUI() {

        @Override
        public void paint(Graphics g, JComponent c) {
            Insets b = TiledHorizontalImageProgressBar.this.getInsets(); // area for border
            int barRectWidth = TiledHorizontalImageProgressBar.this.getWidth() - (b.right + b.left);
            int barRectHeight = TiledHorizontalImageProgressBar.this.getHeight() - (b.top + b.bottom);

            int amountFull = getAmountFull(b, barRectWidth, barRectHeight);
            g.clipRect(b.left, b.top, amountFull, barRectHeight);
            TiledImagePainter.paintComponent(TiledHorizontalImageProgressBar.this, g, tileImage);
            g.setClip(null);
        }
    });
}
项目:WorldGrower    文件:TiledVerticalImageProgressBar.java   
private void changeUI() {
    setUI(new BasicProgressBarUI() {

        @Override
        public void paint(Graphics g, JComponent c) {
            Insets b = TiledVerticalImageProgressBar.this.getInsets(); // area for border
            int barRectWidth = TiledVerticalImageProgressBar.this.getWidth() - (b.right + b.left);
            int barRectHeight = TiledVerticalImageProgressBar.this.getHeight() - (b.top + b.bottom);

            int amountFull = getAmountFull(b, barRectWidth, barRectHeight);

            g.clipRect(b.left, b.top + barRectHeight - amountFull, barRectWidth, amountFull);
            TiledImagePainter.paintComponent(TiledVerticalImageProgressBar.this, g, tileImage);
            g.setClip(null);
        }
    });
}
项目:SmartBetSystem    文件:StatusBarNovo.java   
public void init() {
    UIManager.put("ProgressBar.selectionBackground",Color.BLUE);
    UIManager.put("ProgressBar.selectionForeground",Color.WHITE);
    bar = new JProgressBar();
    panel.setLayout(new BorderLayout());
    JPanel container = new JPanel(new BorderLayout());
    bar.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    bar.setMinimum(0);
    bar.setMaximum(progress.getMaxIterations());
    bar.setUI(new BasicProgressBarUI());
    bar.setStringPainted(true);

    container.add(bar);
    panel.add(container, BorderLayout.CENTER);

    time = System.nanoTime();

    update("init");
}
项目:APIManager-Java    文件:Loading.java   
/**
 * 初始化组件
 */
private void initComp() {

    progress = new JProgressBar();
    progress.setMinimum(0);
    progress.setMaximum(100);
    progress.setStringPainted(true);
    // 字体设置
    progress.setFont(new Font("微软雅黑", Font.PLAIN, 11));
    // 背景设置
    progress.setBackground(Color.WHITE);
    progress.setForeground(new Color(196, 196, 196));
    // 边框设置
    progress.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new Color(170, 170, 170)));
    // 字体颜色设置
    progress.setUI(new BasicProgressBarUI() {

        protected Color getSelectionBackground() {

            return Color.BLACK;
        }

        protected Color getSelectionForeground() {

            return Color.BLACK;
        }
    });
    this.add(progress);
}
项目:AppWoksUtils    文件:CircledProgressBar.java   
/**
 * @param model
 */
public CircledProgressBar(final BoundedRangeModel model) {
    eventSender = new ChangeEventSender();
    tooltipFactory = new TooltipTextDelegateFactory(this);
    installPainer();
    setModel(model);
    BasicProgressBarUI.class.getAnnotations();
    updateUI();
    setIndeterminate(false);

}
项目:java-swing-tips    文件:MainPanel.java   
@Override public void updateUI() {
    super.updateUI();
    setUI(new BasicProgressBarUI());
    setStringPainted(true);
    setString("");
    setOpaque(false);
    setBorder(BorderFactory.createEmptyBorder());
}
项目:java-swing-tips    文件:MainPanel.java   
private MainPanel() {
    super(new BorderLayout());

    BoundedRangeModel model = new DefaultBoundedRangeModel();
    JProgressBar progressBar0 = new JProgressBar(model);

    UIManager.put("ProgressBar.foreground", Color.RED);
    UIManager.put("ProgressBar.selectionForeground", Color.ORANGE);
    UIManager.put("ProgressBar.background", Color.WHITE);
    UIManager.put("ProgressBar.selectionBackground", Color.RED);
    JProgressBar progressBar1 = new JProgressBar(model);

    JProgressBar progressBar2 = new JProgressBar(model);
    progressBar2.setForeground(Color.BLUE);
    progressBar2.setBackground(Color.CYAN.brighter());
    progressBar2.setUI(new BasicProgressBarUI() {
        @Override protected Color getSelectionForeground() {
            return Color.PINK;
        }
        @Override protected Color getSelectionBackground() {
            return Color.BLUE;
        }
    });

    progressBar0.setStringPainted(true);
    progressBar1.setStringPainted(true);
    progressBar2.setStringPainted(true);

    JPanel p = new JPanel(new GridLayout(5, 1));
    p.add(makePanel(progressBar0));
    p.add(makePanel(progressBar1));
    p.add(makePanel(progressBar2));

    JButton button = new JButton("Test start");
    button.addActionListener(e -> {
        if (Objects.nonNull(worker) && !worker.isDone()) {
            worker.cancel(true);
        }
        worker = new BackgroundTask();
        worker.addPropertyChangeListener(new ProgressListener(progressBar0));
        worker.addPropertyChangeListener(new ProgressListener(progressBar1));
        worker.addPropertyChangeListener(new ProgressListener(progressBar2));
        worker.execute();
    });

    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    box.add(button);
    box.add(Box.createHorizontalStrut(5));

    addHierarchyListener(e -> {
        if ((e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0 && !e.getComponent().isDisplayable() && Objects.nonNull(worker)) {
            System.out.println("DISPOSE_ON_CLOSE");
            worker.cancel(true);
            worker = null;
        }
    });
    add(p);
    add(box, BorderLayout.SOUTH);
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setPreferredSize(new Dimension(320, 240));
}
项目:MediathekView    文件:CellRendererDownloads.java   
public CellRendererDownloads() {
    ja_16 = Icons.ICON_TABELLE_EIN;
    nein_12 = Icons.ICON_TABELLE_AUS;
    film_start_tab = Icons.ICON_TABELLE_FILM_START;
    film_start_sw_tab = Icons.ICON_TABELLE_FILM_START_SW;
    download_stop_tab = Icons.ICON_TABELLE_DOWNOAD_STOP;
    download_stop_sw_tab = Icons.ICON_TABELLE_DOWNOAD_STOP_SW;
    download_start_tab = Icons.ICON_TABELLE_DOWNOAD_START;
    download_start_sw_tab = Icons.ICON_TABELLE_DOWNOAD_START_SW;
    download_clear_tab = Icons.ICON_TABELLE_DOWNOAD_CLEAR;
    download_clear_sw_tab = Icons.ICON_TABELLE_DOWNOAD_CLEAR_SW;
    download_del_tab = Icons.ICON_TABELLE_DOWNOAD_DEL;
    download_del_sw_tab = Icons.ICON_TABELLE_DOWNOAD_DEL_SW;
    geoMelden = Boolean.parseBoolean(MVConfig.get(MVConfig.Configs.SYSTEM_GEO_MELDEN));
    Listener.addListener(new Listener(Listener.EREIGNIS_GEO, CellRendererDownloads.class.getSimpleName()) {
        @Override
        public void ping() {
            geoMelden = Boolean.parseBoolean(MVConfig.get(MVConfig.Configs.SYSTEM_GEO_MELDEN));
        }
    });

    progressBar = new JProgressBar(0, 1000);
    progressBar.setStringPainted(true);
    //on OSX the OS provided progress bar looks much better...
    if (!SystemInfo.isMacOSX()) {
        progressBar.setUI(new BasicProgressBarUI() {
            @Override
            protected Color getSelectionBackground() {
                return UIManager.getDefaults().getColor("Table.foreground");
            }

            @Override
            protected Color getSelectionForeground() {
                return Color.white;
            }
        });
    }

    panel = new JPanel(new BorderLayout());
    panel.add(progressBar);

    senderIconCache = new MVSenderIconCache();
}
项目:osrsclient    文件:LevelInfoPanel.java   
private void setup() {

        this.setLayout(new MigLayout("ins 05, gapx 5, align left, "));
        setBackground(new Color(51, 51, 51));
        setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));

        skillLabel = new JLabel("SKILL:");
        rankLabel = new JLabel("RANK:");
        xpLabel = new JLabel("XP:");
        xpToLevelLabel = new JLabel("XP TO LEVEL:");
        xpToLevelBar = new JProgressBar(0);
        xpToLevelBar.setStringPainted(true);

        skill = new JLabel("");
        rank = new JLabel("");
        xp = new JLabel("");
        xpToLevel = new JLabel("");

        skillLabel.setFont(new Font(skillLabel.getFont().getFontName(), Font.BOLD, skillLabel.getFont().getSize()));
        rankLabel.setFont(new Font(skillLabel.getFont().getFontName(), Font.BOLD, rankLabel.getFont().getSize()));
        xpLabel.setFont(new Font(skillLabel.getFont().getFontName(), Font.BOLD, xpLabel.getFont().getSize()));
        xpToLevelLabel.setFont(new Font(skillLabel.getFont().getFontName(), Font.BOLD, xpToLevelLabel.getFont().getSize()));

        skill.setFont(new Font(skillLabel.getFont().getFontName(), Font.BOLD, skillLabel.getFont().getSize()));
        rank.setFont(new Font(skillLabel.getFont().getFontName(), Font.BOLD, rankLabel.getFont().getSize()));
        xp.setFont(new Font(skillLabel.getFont().getFontName(), Font.BOLD, xpLabel.getFont().getSize()));
        xpToLevel.setFont(new Font(skillLabel.getFont().getFontName(), Font.BOLD, xpToLevelLabel.getFont().getSize()));

        skillLabel.setForeground(Color.white);
        rankLabel.setForeground(Color.white);
        xpLabel.setForeground(Color.white);
        xpToLevelLabel.setForeground(Color.white);

        skill.setForeground(Color.white);
        rank.setForeground(Color.white);
        xp.setForeground(Color.white);
        xpToLevel.setForeground(Color.white);

       xpToLevelBar.setForeground(Color.green);
       xpToLevelBar.setBackground(Color.red);
       xpToLevelBar.setBorder(BorderFactory.createLineBorder(Color.black));
       xpToLevelBar.setUI(new BasicProgressBarUI());

        add(skillLabel, "cell 0 0,spanx ");
        add(rankLabel, "cell 0 1,spanx ");
        add(xpLabel, "cell 0 2, gap 0,spanx");
        add(xpToLevelLabel, "cell 0 3, gap 0,spanx ");

        add(skill, "cell 1 0,spanx, gap 45");
        add(rank, "cell 1 1, spanx, gap 45");
        add(xp, "cell 1 2,spanx, gap 25");
        add(xpToLevel, "cell 1 3, spanx, gap 100");
        add(xpToLevelBar, "cell 0 4,spanx, width 100%  ");
    }
项目:beautyeye    文件:BEProgressBarUI.java   
/**
 * Paints the progress string.
 *
 * @param g Graphics used for drawing.
 * @param x x location of bounding box
 * @param y y location of bounding box
 * @param width width of bounding box
 * @param height height of bounding box
 * @param fillStart start location, in x or y depending on orientation,
 *        of the filled portion of the progress bar.
 * @param amountFull size of the fill region, either width or height
 *        depending upon orientation.
 * @param b Insets of the progress bar.
 */
private void paintString(Graphics g, int x, int y, int width, int height,
        int fillStart, int amountFull, Insets b) 
{
    //* 由Jack Jiang修改:因父类中的本方法是private(其实完全可以弄成protected),而如果要全部把该方法拷贝过来
    //* 则会因它调用了sun的非公开api而使得在不同的java版本里有兼容性问题(就是SwingUtilities2类,在1.5里
    //* 位于com.sun.swing.**而在1.6及1.7里是放在sun.swing里的,而且以后果的版本它还会不会改位置也说不定),
    //* 所以为了兼容性,此处利用反射来非正常的调用父类私有方法paintString(正常情况下子类是调用不到了父类的私有方法的撒)
    ReflectHelper.invokeMethod(BasicProgressBarUI.class, this, "paintString"
            , new Class[]{Graphics.class, int.class, int.class, int.class, int.class, int.class, int.class, Insets.class}
            , new Object[]{g,x,y,width,height,fillStart,amountFull,b});
}
项目:concurrent    文件:BEProgressBarUI.java   
/**
 * Paints the progress string.
 *
 * @param g Graphics used for drawing.
 * @param x x location of bounding box
 * @param y y location of bounding box
 * @param width width of bounding box
 * @param height height of bounding box
 * @param fillStart start location, in x or y depending on orientation,
 *        of the filled portion of the progress bar.
 * @param amountFull size of the fill region, either width or height
 *        depending upon orientation.
 * @param b Insets of the progress bar.
 */
private void paintString(Graphics g, int x, int y, int width, int height,
        int fillStart, int amountFull, Insets b) 
{
    //* 由Jack Jiang修改:因父类中的本方法是private(其实完全可以弄成protected),而如果要全部把该方法拷贝过来
    //* 则会因它调用了sun的非公开api而使得在不同的java版本里有兼容性问题(就是SwingUtilities2类,在1.5里
    //* 位于com.sun.swing.**而在1.6及1.7里是放在sun.swing里的,而且以后果的版本它还会不会改位置也说不定),
    //* 所以为了兼容性,此处利用反射来非正常的调用父类私有方法paintString(正常情况下子类是调用不到了父类的私有方法的撒)
    ReflectHelper.invokeMethod(BasicProgressBarUI.class, this, "paintString"
            , new Class[]{Graphics.class, int.class, int.class, int.class, int.class, int.class, int.class, Insets.class}
            , new Object[]{g,x,y,width,height,fillStart,amountFull,b});
}