Giter Club home page Giter Club logo

java-swing-tips's Introduction

java-swing-tips

日本語: Java SwingGUIプログラムを、 小さなソースコード付きサンプル を使って紹介しています。
English: Introduce the GUI program of Java Swing using small source code examples.

Swingとは

About the JFC and Swing (The Java™ Tutorials)

Swingは、GUI(グラフィカル・ユーザ・インタフェース)を作成するための、Java標準のコンポーネントセット(ライブラリ、UIツールキット)です。

Licence

編集方針

java-swing-tips's People

Contributors

andreikud avatar aterai avatar jpierre03 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-swing-tips's Issues

Wheel scroll problem on nested JTabbedPane for tabPlacement other than TOP

I'm encountering a strange Swing problem on basic nested JTabbedPane, and I wonder if you know what is happening.

Wheel scrolling is added to tabbedPanes and all is fine when tabs are on top of panes. But behavior doesn't work has expected when tab placement is on bottom or on left/right, it's the parent tabbedPane that is scrolled instead of the wheeled tabbedPane.

Have you encountered this problem already and have you thought about a fix?

Many thanks.

I made some debugging, it appears the e.getSource() of MouseWheelListener does not return the wheeled tabbedPane which is on SwingConstants.BOTTOM/LEFT/RIGHT, instead it returns the parent tabbedPane.

Here is the animated Gif of the problem:

  • the two tabs on top are fine with tabPlacement on default (SwingConstants.TOP)
  • the tabs on the left and on the bottom are scrolling their parents.

Gif Imgur: parent tabbedPane is changing when nested left/bottom tabbedPane is wheel-scrolled

image

Code

/**
 * Mousewheel allows to navigate to next/previous tab.
 */
public class TabbedPaneMouseWheelScroller implements MouseWheelListener {
    
    /**
     * Log4j logger sent to view.
     */
    private static final Logger LOGGER = Logger.getRootLogger();
    
    @Override
    public void mouseWheelMoved(MouseWheelEvent e) {
        
        JTabbedPane tabPane = (JTabbedPane) e.getSource();

        int dir = -e.getWheelRotation();
        int selIndex = tabPane.getSelectedIndex();
        int maxIndex = tabPane.getTabCount() - 1;
        
        if ((selIndex == 0 && dir < 0) || (selIndex == maxIndex && dir > 0)) {
            
            selIndex = maxIndex - selIndex;
            
        } else {
            
            selIndex += dir;
        }
        
        if (0 <= selIndex && selIndex < tabPane.getTabCount()) {
            
            // Fix #54575: NullPointerException on setSelectedIndex()
            try {
                tabPane.setSelectedIndex(selIndex);
            } catch (NullPointerException err) {
                LOGGER.error(err, err);
            }
        }
    }
}

NumberFormatter: ClassCastException when clicking on the spinner's arrow button

ClassCastException when clicking on the spinner's arrow button.

 java.lang.ClassCastException: class java.lang.Double cannot be cast to class java.lang.Long (java.lang.Double and java.lang.Long are in module java.base of loader 'bootstrap')
   at example.MainPanel$2.stringToValue(MainPanel.java:80)
   at java.desktop/javax.swing.JFormattedTextField.commitEdit(JFormattedTextField.java:563)

JAVA SWING

paano gawin yung minute reminder using java swing? for example may inventory system ka tapos low qty na yung isang product mo dahil nabawasan ito tapos bigla may mag alert message na low stock na yung product mag snooze yon.

素晴らしい。

10何年前から、Java Swing Tips をお世話になっております。

参加していたプロジェクトで Swing を使用することになり、ネットで検索したら https://ateraimemo.com/Swing.html
に辿り着きました。当時(今でも)Swing が人気がなく、ちゃんと Swing のことを紹介するサイトはあんまりなかったですが、そのまま実行できるサンプルコードまであるサイトには、本当に感動しました。
おかげさまでプロジェクトが無事終了しましたが、Swing に対し興味を持ちました。以来、ちょっとしたツールを作るなどの時には、必ず Java Swing Tips に来て、参考になるのもがないかと。来るたびに思うですが、Swing のことで10何年も更新し続けるのは、本当に素晴らしいです!心から感謝しています。本当にありがとうございます。

Swing は本当に使える物なのに、全然人気がないですね。
私は Swing 大好きな、時々遊びに来ますので、どうか続けてください。

よろしくお願いします。

DnDTabbedPane: Drag a tab and start moving it, the tab component disappears

This is not a problem with your class as written, but SwingUtilities.paintComponent() behaves in a way that can cause problems if small modifications are made.

I modified DnDTabbedPane so that the title of the tab is a Component and not a simple string. In my case, this Component consists of a JLabel and a JButton.

In initGlassPane(), SwingUtilities.paintComponent() is used to create the ghost image to drag around. For reasons I do not understand (Swing internals), the call to paintComponent() seems to change the ownership of the tab's Component -- or that is my guess. The fix is to duplicate the result of the call to getTabComponentAt(dragTabIndex) and feed that duplicate to paintComponent(). Exactly how this duplication is done will depend depend on the contents of the situation, so I can't offer a general fix.

CheckedComboBox: Rendering of the drop-down list with the check box opened from JComboBox becomes unstable on Ubuntu environment

Rendering of the drop-down list with the check box opened from JComboBox becomes unstable on Ubuntu environment.
It does not reproduce in Windows 10 + AdoptOpenJDK-11.0.11+9 environment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.