Java Code Examples for javax.swing.plaf.ToolBarUI

The following examples show how to use javax.swing.plaf.ToolBarUI. These examples are extracted from open source projects. 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 Project: netbeans   Source File: ToolbarTest.java    License: Apache License 2.0 5 votes vote down vote up
public void testInitOutsideOfEDT() throws Exception {
    class MyToolbar extends Toolbar implements Runnable {

        @Override
        protected void setUI(ComponentUI newUI) {
            assertTrue("Can only be called in EDT", EventQueue.isDispatchThread());
            super.setUI(newUI);
        }

        @Override
        public void setUI(ToolBarUI ui) {
            assertTrue("Can only be called in EDT", EventQueue.isDispatchThread());
            super.setUI(ui);
        }

        private void assertUI() throws Exception {
            EventQueue.invokeAndWait(this);
        }

        @Override
        public void run() {
            assertNotNull("UI delegate is specified", getUI());
        }
    }
    
    assertFalse("We are not in EDT", EventQueue.isDispatchThread());
    MyToolbar mt = new MyToolbar();
    assertNotNull("Instance created", mt);
    
    mt.assertUI();
}
 
Example 2
Source Project: netbeans   Source File: ToolbarWithOverflowTest.java    License: Apache License 2.0 5 votes vote down vote up
public void testInitOutsideOfEDT() throws Exception {
    class MyToolbar extends ToolbarWithOverflow implements Runnable {

        @Override
        protected void setUI(ComponentUI newUI) {
            assertTrue("Can only be called in EDT", EventQueue.isDispatchThread());
            super.setUI(newUI);
        }

        @Override
        public void setUI(ToolBarUI ui) {
            assertTrue("Can only be called in EDT", EventQueue.isDispatchThread());
            super.setUI(ui);
        }

        private void assertUI() throws Exception {
            EventQueue.invokeAndWait(this);
        }

        @Override
        public void run() {
            assertNotNull("UI delegate is specified", getUI());
        }
    }

    assertFalse("We are not in EDT", EventQueue.isDispatchThread());
    MyToolbar mt = new MyToolbar();
    assertNotNull("Instance created", mt);

    mt.assertUI();
}
 
Example 3
Source Project: netbeans   Source File: NbEditorToolBar.java    License: Apache License 2.0 4 votes vote down vote up
public @Override void setUI(ToolBarUI ui){
    addListener = false;
    super.setUI(ui);
    addListener = true;
}