类java.awt.event.ComponentAdapter源码实例Demo

下面列出了怎么用java.awt.event.ComponentAdapter的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: btdex   文件: Toast.java
private void createGUI(){
    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            setShape(new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), WINDOW_RADIUS, WINDOW_RADIUS));
        }
    });
    
    setAlwaysOnTop(true);
    setUndecorated(true);
    setFocusableWindowState(false);
    setModalityType(ModalityType.MODELESS);
    getContentPane().setBackground(mBackgroundColor);
    
    JLabel label = new JLabel(mText);
    label.setFont(label.getFont().deriveFont(16.0f));
    label.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    label.setForeground(mForegroundColor);
    add(label);
    pack();
}
 
源代码2 项目: dragonwell8_jdk   文件: FontPanel.java
public FontPanel( Font2DTest demo, JFrame f ) {
    f2dt = demo;
    parent = f;

    verticalBar = new JScrollBar ( JScrollBar.VERTICAL );
    fc = new FontCanvas();

    this.setLayout( new BorderLayout() );
    this.add( "Center", fc );
    this.add( "East", verticalBar );

    verticalBar.addAdjustmentListener( this );
    this.addComponentListener( new ComponentAdapter() {
        public void componentResized( ComponentEvent e ) {
            updateBackBuffer = true;
            updateFontMetrics = true;
        }
    });

    /// Initialize font and its infos
    testFont = new Font(fontName, fontStyle, (int)fontSize);
    if ((float)((int)fontSize) != fontSize) {
        testFont = testFont.deriveFont(fontSize);
    }
    updateFontInfo();
}
 
源代码3 项目: haystack   文件: FlutterReduxGen.java
@Override
public void onJsonParsed(PageModel pageModel) {
    if (pageModel.isUIOnly) {
        checkProjectStructure(pageModel);
    } else {
        ModelTableDialog tableDialog = new ModelTableDialog(pageModel, languageResolver,
                textResources, this);
        if (lastDialogLocation != null) {
            tableDialog.setLocation(lastDialogLocation);
        }
        tableDialog.addComponentListener(new ComponentAdapter() {
            public void componentMoved(ComponentEvent e) {
                lastDialogLocation = tableDialog.getLocation();
            }
        });

        tableDialog.pack();
        tableDialog.setVisible(true);
    }
}
 
源代码4 项目: ghidra   文件: VariableHeightPanel.java
/**
 * 
 * Construct a new VariableHeigthPanel.
 * @param pack true means to fit as many components on a row, not worrying about lining up 
 *        columns; false means to fit as many components on a row, and line up the columns 
 *        as if in a grid
 * @param hgap horizontal gap between components
 * @param vgap vertical gap between components
 */
public VariableHeightPanel(final boolean pack, int hgap, int vgap) {
	this.pack = pack;
	this.hGap = hgap;
	this.vGap = vgap;

	setLayout(new VariableHeightLayoutManager(hGap, vGap, pack));

	// this is needed to know when our the layout model changes this panel's height, which
	// requires that we notify our containing parent of the change so that it will re-layout
	// it's children to deal with our new space
	addComponentListener(new ComponentAdapter() {
		@Override
		public void componentResized(ComponentEvent e) {
			invalidate();
			getRootComponent(VariableHeightPanel.this).validate();
		}
	});
}
 
源代码5 项目: arcusplatform   文件: DashboardSection.java
@Override
protected Component createComponent() {
   JPanel content = new JPanel(new BorderLayout());
   content.add(new JScrollPane(createLogTable()), BorderLayout.CENTER);
   content.add(createToolbar(), BorderLayout.SOUTH);
   content.addComponentListener(new ComponentAdapter() {

      /* (non-Javadoc)
       * @see java.awt.event.ComponentAdapter#componentShown(java.awt.event.ComponentEvent)
       */
      @Override
      public void componentShown(ComponentEvent e) {
         controller.refreshLogs();
      }
      
   });
   return content;
}
 
源代码6 项目: arcusplatform   文件: BehaviorSection.java
@Override
protected Component createComponent() {
   JPanel content = new JPanel(new BorderLayout());
   content.add(new JScrollPane(createBehaviorTable()), BorderLayout.CENTER);
   content.add(createToolbar(), BorderLayout.SOUTH);
   content.addComponentListener(new ComponentAdapter() {

      @Override
      public void componentShown(ComponentEvent e) {
         controller.refreshBehaviors();
      }

   });

   IrisClientFactory
         .getClient().addMessageListener(l -> {
            if (isBehavior().apply(l.getEvent())) {
               controller.refreshBehaviors();
            }
         });
   return content;
}
 
源代码7 项目: arcusplatform   文件: ModelStoreViewBuilder.java
public Component build() {
   JPanel panel = new JPanel();
   CardLayout layout = new CardLayout();
   panel.setLayout(layout);
   panel.add(buildSelectorPanel(), "selector");
   panel.add(buildDetailPanel(), "details");
   if(showListeners.hasListeners()) {
      panel.addComponentListener(new ComponentAdapter() {
         @Override
         public void componentShown(ComponentEvent e) {
            showListeners.fireEvent(e);
         }
         
      });
   }
   selectionModel.addSelectionListener((o) -> {
      if(o.isPresent()) {
         layout.show(panel, "details");
      }
      else {
         layout.show(panel, "selector");
      }
   });
   
   return panel;
}
 
源代码8 项目: arcusplatform   文件: PagingFilterToolbar.java
private void init() {
   filterDescription = new JLabel("Filtering...");

   setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
   add(new JButton(filterAction));
   add(filterDescription);
   add(Box.createHorizontalGlue());
   add(new JButton(prevAction));
   add(new JButton(nextAction));
   
   addComponentListener(new ComponentAdapter() {
      @Override
      public void componentShown(ComponentEvent e) {
         reloadCurrentPage();
      }
   });
}
 
源代码9 项目: TencentKona-8   文件: FontPanel.java
public FontPanel( Font2DTest demo, JFrame f ) {
    f2dt = demo;
    parent = f;

    verticalBar = new JScrollBar ( JScrollBar.VERTICAL );
    fc = new FontCanvas();

    this.setLayout( new BorderLayout() );
    this.add( "Center", fc );
    this.add( "East", verticalBar );

    verticalBar.addAdjustmentListener( this );
    this.addComponentListener( new ComponentAdapter() {
        public void componentResized( ComponentEvent e ) {
            updateBackBuffer = true;
            updateFontMetrics = true;
        }
    });

    /// Initialize font and its infos
    testFont = new Font(fontName, fontStyle, (int)fontSize);
    if ((float)((int)fontSize) != fontSize) {
        testFont = testFont.deriveFont(fontSize);
    }
    updateFontInfo();
}
 
源代码10 项目: jdk8u60   文件: FontPanel.java
public FontPanel( Font2DTest demo, JFrame f ) {
    f2dt = demo;
    parent = f;

    verticalBar = new JScrollBar ( JScrollBar.VERTICAL );
    fc = new FontCanvas();

    this.setLayout( new BorderLayout() );
    this.add( "Center", fc );
    this.add( "East", verticalBar );

    verticalBar.addAdjustmentListener( this );
    this.addComponentListener( new ComponentAdapter() {
        public void componentResized( ComponentEvent e ) {
            updateBackBuffer = true;
            updateFontMetrics = true;
        }
    });

    /// Initialize font and its infos
    testFont = new Font(fontName, fontStyle, (int)fontSize);
    if ((float)((int)fontSize) != fontSize) {
        testFont = testFont.deriveFont(fontSize);
    }
    updateFontInfo();
}
 
源代码11 项目: mylizzie   文件: AnalysisFrame.java
/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 */
public static JDialog createAnalysisDialog(JFrame owner) {
    // Create and set up the window.
    JDialog dialog = new JDialog(owner, resourceBundle.getString("AnalysisFrame.title"));

    // Create and set up the content pane.
    final AnalysisFrame newContentPane = new AnalysisFrame();
    newContentPane.setOpaque(true); // content panes must be opaque
    dialog.setContentPane(newContentPane);

    // Display the window.
    dialog.setSize(800, 600);

    // Handle close event
    dialog.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentHidden(ComponentEvent e) {
            newContentPane.getAnalysisTableModel().setSelectedMove(null);
            Lizzie.optionSetting.setAnalysisWindowShow(false);
        }
    });

    return dialog;
}
 
源代码12 项目: radiance   文件: MatrixRain.java
public MatrixPanel() {
    try {
        InputStream is = MatrixRain.class.getClassLoader().getResourceAsStream(
                "fonts/katakana.ttf");
        Font kf = Font.createFont(Font.TRUETYPE_FONT, is);
        int fontSize = 14;
        font = kf.deriveFont(Font.BOLD, fontSize);
    } catch (Exception exc) {
        exc.printStackTrace();
    }

    SwingRepaintTimeline.repaintBuilder(this).playLoop(RepeatBehavior.LOOP);

    this.drops = new ArrayList<>();
    this.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            while (drops.size() < 40)
                addDrop();
        }
    });
}
 
源代码13 项目: 3Dscript   文件: SingleSlider.java
public SingleSliderCanvas(final int realMax, int setMax, Color color, SingleSlider slider) {
	this.color = color;
	this.slider = slider;
	this.setMax = setMax;
	this.realMax = realMax;

	this.diagram = new DiagramCanvas();
	diagram.setMargins(2, 2, 2, 2);
	diagram.setBoundingBox(0, 0, realMax, 5);

	this.addMouseMotionListener(this);
	this.addMouseListener(this);
	this.setBackground(Color.WHITE);
	this.setFont(new Font("Helvetica", Font.PLAIN, 10));
	this.addComponentListener(new ComponentAdapter() {
		@Override
		public void componentResized(ComponentEvent e) {
			diagram.setSizes(getWidth(), getHeight());
		}
	});
}
 
源代码14 项目: 3Dscript   文件: DoubleSlider.java
public DoubleSliderCanvas(final int[] realMinMax, int[] setMinMax, Color color, DoubleSlider slider) {
	this.color = color;
	this.slider = slider;
	this.setMinMax = setMinMax;
	this.realMinMax = realMinMax;

	this.diagram = new DiagramCanvas();
	diagram.setMargins(2, 2, 2, 2);
	diagram.setBoundingBox(realMinMax[0], 0, realMinMax[1], 5);

	this.addMouseMotionListener(this);
	this.addMouseListener(this);
	this.setBackground(Color.WHITE);
	this.setFont(new Font("Helvetica", Font.PLAIN, 10));
	this.addComponentListener(new ComponentAdapter() {
		@Override
		public void componentResized(ComponentEvent e) {
			diagram.setSizes(getWidth(), getHeight());
			repaint();
		}
	});
}
 
源代码15 项目: openjdk-jdk8u   文件: FontPanel.java
public FontPanel( Font2DTest demo, JFrame f ) {
    f2dt = demo;
    parent = f;

    verticalBar = new JScrollBar ( JScrollBar.VERTICAL );
    fc = new FontCanvas();

    this.setLayout( new BorderLayout() );
    this.add( "Center", fc );
    this.add( "East", verticalBar );

    verticalBar.addAdjustmentListener( this );
    this.addComponentListener( new ComponentAdapter() {
        public void componentResized( ComponentEvent e ) {
            updateBackBuffer = true;
            updateFontMetrics = true;
        }
    });

    /// Initialize font and its infos
    testFont = new Font(fontName, fontStyle, (int)fontSize);
    if ((float)((int)fontSize) != fontSize) {
        testFont = testFont.deriveFont(fontSize);
    }
    updateFontInfo();
}
 
源代码16 项目: netbeans   文件: AutoHideStatusText.java
private AutoHideStatusText( JFrame frame, JPanel statusContainer  ) {
    this.statusContainer = statusContainer;
    Border outerBorder = UIManager.getBorder( "Nb.ScrollPane.border" ); //NOI18N
    if( null == outerBorder ) {
        outerBorder = BorderFactory.createEtchedBorder();
    }
    panel.setBorder( BorderFactory.createCompoundBorder( outerBorder, 
            BorderFactory.createEmptyBorder(3,3,3,3) ) );
    lblStatus.setName("AutoHideStatusTextLabel"); //NOI18N
    panel.add( lblStatus, BorderLayout.CENTER );
    frame.getLayeredPane().add( panel, Integer.valueOf( 101 ) );
    StatusDisplayer.getDefault().addChangeListener( this );

    frame.addComponentListener( new ComponentAdapter() {
        @Override
        public void componentResized( ComponentEvent e ) {
            run();
        }
    });
}
 
源代码17 项目: netbeans   文件: UIUtils.java
public static void ensureMinimumSize(Component comp) {
    comp = getParentWindow(comp);

    if (comp != null) {
        final Component top = comp;
        top.addComponentListener(new ComponentAdapter() {
                public void componentResized(ComponentEvent e) {
                    Dimension d = top.getSize();
                    Dimension min = top.getMinimumSize();

                    if ((d.width < min.width) || (d.height < min.height)) {
                        top.setSize(Math.max(d.width, min.width), Math.max(d.height, min.height));
                    }
                }
            });
    }
}
 
源代码18 项目: openjdk-jdk8u-backup   文件: FontPanel.java
public FontPanel( Font2DTest demo, JFrame f ) {
    f2dt = demo;
    parent = f;

    verticalBar = new JScrollBar ( JScrollBar.VERTICAL );
    fc = new FontCanvas();

    this.setLayout( new BorderLayout() );
    this.add( "Center", fc );
    this.add( "East", verticalBar );

    verticalBar.addAdjustmentListener( this );
    this.addComponentListener( new ComponentAdapter() {
        public void componentResized( ComponentEvent e ) {
            updateBackBuffer = true;
            updateFontMetrics = true;
        }
    });

    /// Initialize font and its infos
    testFont = new Font(fontName, fontStyle, (int)fontSize);
    if ((float)((int)fontSize) != fontSize) {
        testFont = testFont.deriveFont(fontSize);
    }
    updateFontInfo();
}
 
源代码19 项目: openjdk-jdk9   文件: FontPanel.java
public FontPanel( Font2DTest demo, JFrame f ) {
    f2dt = demo;
    parent = f;

    verticalBar = new JScrollBar ( JScrollBar.VERTICAL );
    fc = new FontCanvas();

    this.setLayout( new BorderLayout() );
    this.add( "Center", fc );
    this.add( "East", verticalBar );

    verticalBar.addAdjustmentListener( this );
    this.addComponentListener( new ComponentAdapter() {
        public void componentResized( ComponentEvent e ) {
            updateFontMetrics = true;
        }
    });

    /// Initialize font and its infos
    testFont = new Font(fontName, fontStyle, (int)fontSize);
    if ((float)((int)fontSize) != fontSize) {
        testFont = testFont.deriveFont(fontSize);
    }
    updateFontInfo();
}
 
源代码20 项目: openjdk-jdk9   文件: SetShape.java
@Override
public void initGUI() {
    if (windowClass.equals(Frame.class)) {
        window = new Frame();
        ((Frame) window).setUndecorated(true);
    } else  if (windowClass.equals(Dialog.class)) {
        window = new Dialog(background);
        ((Dialog) window).setUndecorated(true);
    } else {
        window = new Window(background);
    }
    window.setBackground(FG_COLOR);
    window.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            window.setShape(shape);
        }
    });
    window.setSize(200, 200);
    window.setLocation(2*dl, 2*dl);
    window.setVisible(true);

    System.out.println("Checking " + window.getClass().getName() + "...");
}
 
源代码21 项目: jdk8u-jdk   文件: FontPanel.java
public FontPanel( Font2DTest demo, JFrame f ) {
    f2dt = demo;
    parent = f;

    verticalBar = new JScrollBar ( JScrollBar.VERTICAL );
    fc = new FontCanvas();

    this.setLayout( new BorderLayout() );
    this.add( "Center", fc );
    this.add( "East", verticalBar );

    verticalBar.addAdjustmentListener( this );
    this.addComponentListener( new ComponentAdapter() {
        public void componentResized( ComponentEvent e ) {
            updateBackBuffer = true;
            updateFontMetrics = true;
        }
    });

    /// Initialize font and its infos
    testFont = new Font(fontName, fontStyle, (int)fontSize);
    if ((float)((int)fontSize) != fontSize) {
        testFont = testFont.deriveFont(fontSize);
    }
    updateFontInfo();
}
 
/**
 * Sets the component to be shown.
 * @param component the component to be shown.
 * @param parent the container to which the shown component should be added.
 *               This parameter can be null if you add the component yourself.
 */
public void setComponent(Component component) {
    this.component = component;
    if (null != component) {
        component.addComponentListener(new ComponentAdapter() {

            @Override
            public void componentHidden(ComponentEvent e) {
                if (null != unselectButton && isSelected()) {
                    unselectButton.setSelected(true);
                }
            }
            
        });
    }
}
 
源代码23 项目: hottub   文件: FontPanel.java
public FontPanel( Font2DTest demo, JFrame f ) {
    f2dt = demo;
    parent = f;

    verticalBar = new JScrollBar ( JScrollBar.VERTICAL );
    fc = new FontCanvas();

    this.setLayout( new BorderLayout() );
    this.add( "Center", fc );
    this.add( "East", verticalBar );

    verticalBar.addAdjustmentListener( this );
    this.addComponentListener( new ComponentAdapter() {
        public void componentResized( ComponentEvent e ) {
            updateBackBuffer = true;
            updateFontMetrics = true;
        }
    });

    /// Initialize font and its infos
    testFont = new Font(fontName, fontStyle, (int)fontSize);
    if ((float)((int)fontSize) != fontSize) {
        testFont = testFont.deriveFont(fontSize);
    }
    updateFontInfo();
}
 
源代码24 项目: ApkToolPlus   文件: ProgressDialog.java
private void setupEventHandlers() {

        addComponentListener(new ComponentAdapter() {
            public void componentShown(ComponentEvent event) {
                final Thread task = new Thread(runnable);
                task.start();
                new Thread() {
                    public void run() {
                        try {
                            task.join();
                        } catch (InterruptedException e) {
                        }
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                setVisible(false);
                            }
                        });
                    }
                }.start();
            }
        });
    }
 
源代码25 项目: openjdk-8-source   文件: FontPanel.java
public FontPanel( Font2DTest demo, JFrame f ) {
    f2dt = demo;
    parent = f;

    verticalBar = new JScrollBar ( JScrollBar.VERTICAL );
    fc = new FontCanvas();

    this.setLayout( new BorderLayout() );
    this.add( "Center", fc );
    this.add( "East", verticalBar );

    verticalBar.addAdjustmentListener( this );
    this.addComponentListener( new ComponentAdapter() {
        public void componentResized( ComponentEvent e ) {
            updateBackBuffer = true;
            updateFontMetrics = true;
        }
    });

    /// Initialize font and its infos
    testFont = new Font(fontName, fontStyle, (int)fontSize);
    if ((float)((int)fontSize) != fontSize) {
        testFont = testFont.deriveFont(fontSize);
    }
    updateFontInfo();
}
 
源代码26 项目: gemfirexd-oss   文件: SequenceDiagram.java
public SequenceDiagram(long minTime, long maxTime, List<String> lineNames, LineMapper lineMapper) {
    this.lineNames = lineNames;
    this.shortLineNames = parseShortNames(lineNames, lineMapper);
    this.minTime = minTime;
    this.maxTime = maxTime;
    int width = getInitialWidth();
    int height = 500;
    super.setPreferredSize(new Dimension(width, height));
    resizeMe(width, height);
    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            Component source = (Component) e.getSource();
            resizeMe(source.getWidth(), source.getHeight());
        }
    });
    setBackground(Color.WHITE);
}
 
源代码27 项目: scelight   文件: XTabbedPane.java
@Override
public void addTab( final String title, final IRIcon ricon, final Producer< JComponent > tabProducer, final boolean addTabMnemonic,
        final boolean closeable, final Runnable beforeCloseTask ) {
	
	// Wrapper component that listens to being shown first
	final BorderPanel p = new BorderPanel();
	p.addComponentListener( new ComponentAdapter() {
		@Override
		public void componentShown( final ComponentEvent event ) {
			p.addCenter( tabProducer.produce() );
			p.removeComponentListener( this );
			p.validate();
		}
	} );
	
	addTab( title, ricon, p, addTabMnemonic, closeable, beforeCloseTask );
}
 
源代码28 项目: visualvm   文件: UIUtils.java
public static void ensureMinimumSize(Component comp) {
    comp = getParentWindow(comp);

    if (comp != null) {
        final Component top = comp;
        top.addComponentListener(new ComponentAdapter() {
                public void componentResized(ComponentEvent e) {
                    Dimension d = top.getSize();
                    Dimension min = top.getMinimumSize();

                    if ((d.width < min.width) || (d.height < min.height)) {
                        top.setSize(Math.max(d.width, min.width), Math.max(d.height, min.height));
                    }
                }
            });
    }
}
 
源代码29 项目: java-disassembler   文件: ClassViewer.java
public ClassViewer(ViewerFile file) {
    super(file);
    updateName();
    this.setLayout(new BorderLayout());

    this.sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panels.get(0), panels.get(1));
    this.sp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp, panels.get(2));
    this.add(sp2, BorderLayout.CENTER);

    refresh(null);
    this.addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent e) {
            resetDivider();
        }
    });
}
 
源代码30 项目: openjdk-8   文件: FontPanel.java
public FontPanel( Font2DTest demo, JFrame f ) {
    f2dt = demo;
    parent = f;

    verticalBar = new JScrollBar ( JScrollBar.VERTICAL );
    fc = new FontCanvas();

    this.setLayout( new BorderLayout() );
    this.add( "Center", fc );
    this.add( "East", verticalBar );

    verticalBar.addAdjustmentListener( this );
    this.addComponentListener( new ComponentAdapter() {
        public void componentResized( ComponentEvent e ) {
            updateBackBuffer = true;
            updateFontMetrics = true;
        }
    });

    /// Initialize font and its infos
    testFont = new Font(fontName, fontStyle, (int)fontSize);
    if ((float)((int)fontSize) != fontSize) {
        testFont = testFont.deriveFont(fontSize);
    }
    updateFontInfo();
}