相关疑难解决方法(0)

java等待光标显示问题

我在应用程序中显示等待光标时遇到问题.只要鼠标位于定义自己光标的面板上方,就不会出现等待光标.如果面板未更改光标,则会出现等待光标.

我附上了SSCE来准确解释我的问题.

public class BusyCursorTest extends javax.swing.JFrame {

public BusyCursorTest() {

    javax.swing.JMenuBar menuBar = new javax.swing.JMenuBar();
    javax.swing.JMenu menu = new javax.swing.JMenu("Menu");
    javax.swing.JMenuItem wait1 = new javax.swing.JMenuItem("Wait 100 ms");
    javax.swing.JMenuItem wait2 = new javax.swing.JMenuItem("Wait 250 ms");
    javax.swing.JMenuItem wait3 = new javax.swing.JMenuItem("Wait 500 ms");
    javax.swing.JMenuItem wait4 = new javax.swing.JMenuItem("Wait 1000 ms");
    menu.add(wait1);
    menu.add(wait2);
    menu.add(wait3);
    menu.add(wait4);
    menuBar.add(menu);
    setJMenuBar(menuBar);
    wait1.addActionListener(getActionListener(this, delayActionListener(100)));
    wait2.addActionListener(getActionListener(this, delayActionListener(250)));
    wait3.addActionListener(getActionListener(this, delayActionListener(500)));
    wait4.addActionListener(getActionListener(this, delayActionListener(1000)));

    cursorPanel = new javax.swing.JPanel();
    cursorPanel.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mouseEntered(java.awt.event.MouseEvent e) {
            cursorPanel.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.CROSSHAIR_CURSOR));
        }

        public void mouseExited(java.awt.event.MouseEvent …
Run Code Online (Sandbox Code Playgroud)

java swing busy-cursor

15
推荐指数
1
解决办法
2万
查看次数

JTable如何改变BackGround Color

我从MeBigFatGuy有趣的问题中获得灵感,在这个连接中,我有一个非常具体的问题Graphisc2D,如何改变BackGround Color取决于是否JTables Row可见JViewPort,

1)如果1st. & last JTables Row在中可见JViewPort,则BackGround将被着色为Color.red

2)如果1st. & last JTables Row在中不可见JViewPort,那么BackGround就会被着色了Color.whatever

在此输入图像描述

来自SSCCE

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.image.BufferedImage;
import javax.swing.*;
import javax.swing.RepaintManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.table.TableModel;

/*
https://stackoverflow.com/questions/1249278/
how-to-disable-the-default-painting-behaviour-of-wheel-scroll-event-on-jscrollpan
 *
and
 *
https://stackoverflow.com/questions/8195959/
swing-jtable-event-when-row-is-visible-or-when-scrolled-to-the-bottom
 */
public class ViewPortFlickering {

    private JFrame frame = new JFrame("Table");
    private JViewport viewport = new JViewport(); …
Run Code Online (Sandbox Code Playgroud)

java swing gradient jtable jviewport

8
推荐指数
1
解决办法
3319
查看次数

标签 统计

java ×2

swing ×2

busy-cursor ×1

gradient ×1

jtable ×1

jviewport ×1