Java Code Examples for java.awt.event.ComponentAdapter

The following are top voted examples for showing how to use java.awt.event.ComponentAdapter. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: incubator-netbeans   File: AutoHideStatusText.java   Source Code and License 6 votes vote down vote up
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();
        }
    });
}
 
Example 2
Project: incubator-netbeans   File: UIUtils.java   Source Code and License 6 votes vote down vote up
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));
                    }
                }
            });
    }
}
 
Example 3
Project: rapidminer   File: FunctionDescriptionPanel.java   Source Code and License 6 votes vote down vote up
/**
 * Creates a panel for the given {@link FunctionDescription}. When the panel is expanded, the
 * extra information is shown.
 *
 * @param functionEntry
 */
public FunctionDescriptionPanel(FunctionDescription functionEntry) {
	this.functionEntry = functionEntry;

	initGUI();
	if (functionEntry != null) {
		updateFunctionEntry(functionEntry);
		showMoreInformation(isExpanded);
	} else {
		showMoreInformation(false);
	}
	registerMouseListener();
	addComponentListener(new ComponentAdapter() {

		@Override
		public void componentResized(ComponentEvent arg0) {
			updateHeight();
		}
	});
	initialized = true;
}
 
Example 4
Project: Open-DM   File: JobProgressPanel.java   Source Code and License 6 votes vote down vote up
/**
 * @param jobStatus
 *            - must never be null
 * @param jobType
 *            - type of job; copy, delete or set metadata
 */
public JobProgressPanel(JobStatus jobStatus, ManagedJob.Type jobType) {
    currentJobStatus = jobStatus;
    numberFormat = NumberFormat.getInstance();
    numberFormat.setGroupingUsed(true);
    this.jobType = jobType;
    processingModel = new ProcessingTableModel();
    completedModel = new CompletedTableModel();
    errorModel = new ErrorTableModel();
    initGuiComponents();

    addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent evt) {
            resizeTables();
        }
    });
}
 
Example 5
Project: BachSys   File: TelaDadosMusica.java   Source Code and License 6 votes vote down vote up
private void adicionarBotaoEditar() {
    Tela t = this;
    btnEditar = new JButton("Editar");
    adicionarComponente(btnEditar, GridBagConstraints.EAST, 
                GridBagConstraints.NONE, 0, 0, 2, 1);
    btnEditar.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            TelaEditarMusica tem = new TelaEditarMusica(musica.getNome(), musica, t);
            tem.setVisible(true);
            tem.addComponentListener(new ComponentAdapter() {
                @Override
                public void componentHidden(ComponentEvent e) {
                    musica = tem.getMusica();
                    editou = true;
                    adicionarValores();
                }
            });
        }
    });
}
 
Example 6
Project: OpenJSharp   File: FontPanel.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 7
Project: monarch   File: SequenceDiagram.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 8
Project: JITRAX   File: QueryResultViewer.java   Source Code and License 6 votes vote down vote up
public QueryResultViewer() {
	resultSet = null;
	tableModel = new DefaultTableModel();
	emptyResultLabel = new JLabel(EMPTY_RESULT_MSG);
	mainContainer = new JPanel();
	
	setLayout(new BorderLayout());
	tableSP = new JScrollPane(graphicTable,
			JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, 
			JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	tableSP.setBorder(BorderFactory.createEmptyBorder());
	
	graphicTable.setModel(tableModel);
	graphicTable.setFillsViewportHeight(true);
	graphicTable.setEnabled(false);
	
	addComponentListener(new ComponentAdapter() {
	    public void componentResized(ComponentEvent e) {
	        resizeColumnWidth(COL_MIN_WIDTH);          
	    }
	});
	
	mainContainer.add(tableSP);
	setLayout(new GridLayout(1,1));
	add(tableSP);
}
 
Example 9
Project: Tarski   File: BasicGraphEditor.java   Source Code and License 6 votes vote down vote up
/**
 * 
 */
public EditorPalette insertPalette(String title) {
  final EditorPalette palette = new EditorPalette();
  final JScrollPane scrollPane = new JScrollPane(palette);
  scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  libraryPane.add(title, scrollPane);

  // Updates the widths of the palettes if the container size changes
  libraryPane.addComponentListener(new ComponentAdapter() {
    /**
     * 
     */
    public void componentResized(ComponentEvent e) {
      int w = scrollPane.getWidth() - scrollPane.getVerticalScrollBar().getWidth();
      palette.setPreferredWidth(w);
    }

  });

  return palette;
}
 
Example 10
Project: jdk8u-jdk   File: FontPanel.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 11
Project: openjdk-jdk10   File: FontPanel.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 12
Project: openjdk-jdk10   File: SetShape.java   Source Code and License 6 votes vote down vote up
@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() + "...");
}
 
Example 13
Project: defense-solutions-proofs-of-concept   File: ComponentShowingButton.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
                }
            }
            
        });
    }
}
 
Example 14
Project: intellij-ce-playground   File: EditConfigurationsDialog.java   Source Code and License 6 votes vote down vote up
public void addRunConfiguration(@NotNull final ConfigurationFactory factory) {
  final RunConfigurable configurable = (RunConfigurable)getConfigurable();
  final SingleConfigurationConfigurable<RunConfiguration> configuration = configurable.createNewConfiguration(factory);

  if (!isVisible()) {
     getContentPanel().addComponentListener(new ComponentAdapter() {
       @Override
       public void componentShown(ComponentEvent e) {
         if (configuration != null) {
           configurable.updateRightPanel(configuration);
           getContentPanel().removeComponentListener(this);
         }
       }
     });
  }
}
 
Example 15
Project: openjdk9   File: SetShape.java   Source Code and License 6 votes vote down vote up
@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() + "...");
}
 
Example 16
Project: Code-Glosser   File: Toast.java   Source Code and License 6 votes vote down vote up
private void createGUI(){
    setLayout(new GridBagLayout());
    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);
    setSize(mText.length() * CHARACTER_LENGTH_MULTIPLIER, 25);
    getContentPane().setBackground(mBackgroundColor);
    
    JLabel label = new JLabel(mText);
    label.setForeground(mForegroundColor);
    add(label);
}
 
Example 17
Project: ec2watch   File: ImageViewer.java   Source Code and License 6 votes vote down vote up
public ImageViewer(String title, byte[] imageData) {
  

  imageIcon = new ImageIcon();
  imageLabel = new JLabel(imageIcon);

  this.setTitle(title);
  this.getContentPane().add(imageLabel);
  this.setSize(720, 400);
  this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  this.setVisible(true);

  setImageData(imageData);

  this.getRootPane().addComponentListener(new ComponentAdapter() {
    @Override
    public void componentResized(ComponentEvent e) {
      updateImage();
    }
  });

}
 
Example 18
Project: ApkToolPlus   File: ProgressDialog.java   Source Code and License 6 votes vote down vote up
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();
            }
        });
    }
 
Example 19
Project: gemfirexd-oss   File: SequenceDiagram.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 20
Project: PhET   File: ApparatusPanel.java   Source Code and License 6 votes vote down vote up
/**
 *
 */
public ApparatusPanel( final AffineTransformFactory tx ) {
    // Call superclass constructor with null so that we
    // don't get the default layout manager. This allows us
    // to lay out components with absolute coordinates
    super( null );
    this.mvTx = tx;


    this.mh = new MouseHandler();
    addMouseListener( mh );
    addMouseMotionListener( mh );

    addComponentListener( new ComponentAdapter() {
        public void componentResized( ComponentEvent e ) {
            updateTransform();
        }
    } );
}
 
Example 21
Project: PhET   File: HeadModuleControlPanel.java   Source Code and License 6 votes vote down vote up
/**
     * Constructor
     *
     * @param module
     */
    public HeadModuleControlPanel( HeadModule module,
                                   GradientElectromagnet horizontalGradientMagnet,
                                   GradientElectromagnet verticalGradientMagnet ) {
        MriModel model = (MriModel)module.getModel();

        addControlFullWidth( new MriLegend() );
        addControlFullWidth( new FadingMagnetControl( model ) );
        addControlFullWidth( new GradientMagnetControlPanel( horizontalGradientMagnet, verticalGradientMagnet ) );
        addControlFullWidth( new HeadControl( module ) );

        addComponentListener( new ComponentAdapter() {
            public void componentResized( ComponentEvent e ) {
//                getLayout().layoutContainer( PhetUtilities.getPhetFrame().getContentPane() );
            }
        } );
    }
 
Example 22
Project: PhET   File: ApparatusPanel.java   Source Code and License 6 votes vote down vote up
/**
 *
 */
public ApparatusPanel( final AffineTransformFactory tx ) {
    // Call superclass constructor with null so that we
    // don't get the default layout manager. This allows us
    // to lay out components with absolute coordinates
    super( null );
    this.mvTx = tx;


    this.mh = new MouseHandler();
    addMouseListener( mh );
    addMouseMotionListener( mh );

    addComponentListener( new ComponentAdapter() {
        @Override
        public void componentResized( ComponentEvent e ) {
            updateTransform();
        }
    } );
}
 
Example 23
Project: PhET   File: MotionPanel.java   Source Code and License 6 votes vote down vote up
public MotionPanel( final Motion2DPanel myJP, int width, int height ) {
    this.width = width;
    this.height = height;
    this.myJP = myJP;
    motionOn = false;
    setBackground( Color.orange );

    constAIRadBtn = new JRadioButton( Motion2DResources.getString( "MotionPanel.LinearAccIRadioButton" ), false );
    constAIIRadBtn = new JRadioButton( Motion2DResources.getString( "MotionPanel.LinearAccIIRadioButton" ), false );
    sHMRadBtn = new JRadioButton( Motion2DResources.getString( "MotionPanel.SimpleHarmonicRadioButton" ), false );
    circularRadBtn = new JRadioButton( Motion2DResources.getString( "MotionPanel.CircularRadioButton" ), false );
    stopRadBtn = new JRadioButton( Motion2DResources.getString( "MotionPanel.StopRadioButton" ), true );

    constAIRadBtn.setBackground( Color.orange );
    constAIIRadBtn.setBackground( Color.orange );
    sHMRadBtn.setBackground( Color.orange );
    circularRadBtn.setBackground( Color.orange );
    stopRadBtn.setBackground( Color.orange );
    amplitude = 175;
    myJP.addComponentListener( new ComponentAdapter() {
        public void componentResized( ComponentEvent e ) {
            MotionPanel.this.width = myJP.getWidth();
            MotionPanel.this.height = myJP.getHeight();
        }
    } );
}
 
Example 24
Project: PhET   File: TestGraphSetNode.java   Source Code and License 6 votes vote down vote up
public TestGraphSetNode() {
    phetPCanvas = new BufferedPhetPCanvas();


    frame.setContentPane( phetPCanvas );
    frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    frame.setSize( 800, 600 );

    TimeSeriesModel timeSeriesModel = new TimeSeriesModel( new TestTimeSeries.MyRecordableModel(), new ConstantDtClock( 30, 1 ) );
    MinimizableControlGraph minimizableControlGraphA = new MinimizableControlGraph( "labelA", new ControlGraph(
            phetPCanvas, new ControlGraphSeries( new DefaultTemporalVariable() ), "titleA", 0, 10, timeSeriesModel ) );
    MinimizableControlGraph minimizableControlGraphB = new MinimizableControlGraph( "Long labelB", new ControlGraph(
            phetPCanvas, new ControlGraphSeries( new DefaultTemporalVariable() ), "Long titleB", 0, 10, timeSeriesModel ) );


    graphSetNode = new GraphSetNode( new GraphSetModel( new GraphSuite( new MinimizableControlGraph[] { minimizableControlGraphA, minimizableControlGraphB } ) ) );
    graphSetNode.setAlignedLayout();
    phetPCanvas.addScreenChild( graphSetNode );

    phetPCanvas.addComponentListener( new ComponentAdapter() {
        public void componentResized( ComponentEvent e ) {
            relayout();
        }
    } );
    relayout();
}
 
Example 25
Project: PhET   File: TestTimeSeriesGraphSetNode.java   Source Code and License 6 votes vote down vote up
public TestTimeSeriesGraphSetNode() {
    frame = new JFrame();
    frame.setSize( 1024, 768 );
    frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

    pSwingCanvas = new PhetPCanvas();
    frame.setContentPane( pSwingCanvas );
    clock = new ConstantDtClock( 30, 1 );
    final TestMotionModel testMotionModel = new TestMotionModel( clock );
    timeSeriesGraphSetNode = new TimeSeriesGraphSetNode( new GraphSetModel( new TestGraphSet( pSwingCanvas, testMotionModel ).getGraphSuite( 0 ) ), new TimeSeriesModel( new TestTimeSeries.MyRecordableModel(), clock ), 0.01, 1.0 );
    pSwingCanvas.getLayer().addChild( timeSeriesGraphSetNode );
    pSwingCanvas.addComponentListener( new ComponentAdapter() {
        public void componentResized( ComponentEvent e ) {
            relayout();
        }
    } );

    clock.addClockListener( new ClockAdapter() {
        public void simulationTimeChanged( ClockEvent clockEvent ) {
            testMotionModel.stepInTime( clockEvent.getSimulationTimeChange() );
        }
    } );
}
 
Example 26
Project: PhET   File: TestControlGraph.java   Source Code and License 6 votes vote down vote up
public TestControlGraph() {
    frame = new JFrame();
    frame.setSize( 600, 600 );
    frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

    ITemporalVariable v = new DefaultTemporalVariable();

    ControlGraphSeries graphSeries = new ControlGraphSeries( "series", Color.blue, "abbr", "units", null, v );

    phetPCanvas = new BufferedPhetPCanvas();
    controlGraph = new ControlGraph( phetPCanvas, graphSeries, "title", -10, 10, new TimeSeriesModel( new TestTimeSeries.MyRecordableModel(), new ConstantDtClock( 30, 1 ) ) );

    controlGraph.addValue( 0, 0 );
    controlGraph.addValue( 600, 10 );
    controlGraph.addValue( 800, -3 );
    phetPCanvas.addScreenChild( controlGraph );
    phetPCanvas.addComponentListener( new ComponentAdapter() {
        public void componentResized( ComponentEvent e ) {
            relayout();
        }
    } );
    frame.setContentPane( phetPCanvas );
    relayout();
}
 
Example 27
Project: PhET   File: JMEModule.java   Source Code and License 6 votes vote down vote up
public JMEModule( Frame parentFrame, Function1<Frame, PhetJMEApplication> applicationFactory ) {
    super( JMECanvasFactory.createCanvas( parentFrame, applicationFactory ) );

    // gets what we created in the super-call
    canvas = (Canvas) getContent();

    // stores the created application statically, so we need to retrieve this
    app = JMEUtils.getApplication();

    addListener( new Listener() {
        public void activated() {
            app.startCanvas();
        }

        public void deactivated() {
        }
    } );

    // listen to resize events on our canvas, so that we can update our layout
    canvas.addComponentListener( new ComponentAdapter() {
        @Override public void componentResized( ComponentEvent e ) {
            app.onResize( canvas.getSize() );
        }
    } );
}
 
Example 28
Project: PhET   File: TabularFisheye.java   Source Code and License 6 votes vote down vote up
public TabularFisheye() {
    calendarNode = new CalendarNode();
    getLayer().addChild(calendarNode);
    setMinimumSize(new Dimension(300, 300));
    setPreferredSize(new Dimension(600, 600));
    setZoomEventHandler(null);
    setPanEventHandler(null);

    addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent arg0) {
            calendarNode.setBounds(getX(), getY(),
                    getWidth() - 1, getHeight() - 1);
            calendarNode.layoutChildren(false);
        }
    });
}
 
Example 29
Project: scelight   File: XTabbedPane.java   Source Code and License 6 votes vote down vote up
@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 );
}
 
Example 30
Project: bisis-v4   File: SearchBooks.java   Source Code and License 6 votes vote down vote up
public void init() {
//		getLPref1().setText("AU"); //$NON-NLS-1$
//		getTfPref1().setVisible(true);
//		getCodedPref1().setVisible(false);
//		getLPref2().setText("TI"); //$NON-NLS-1$
//		getTfPref2().setVisible(true);
//		getCodedPref2().setVisible(false);
//		getLPref3().setText("PU"); //$NON-NLS-1$
//		getTfPref3().setVisible(true);
//		getCodedPref3().setVisible(false);
//		getLPref4().setText("PY"); //$NON-NLS-1$
//		getTfPref4().setVisible(true);
//		getCodedPref4().setVisible(false);
//		getLPref5().setText("KW"); //$NON-NLS-1$
//		getTfPref5().setVisible(false);
//		getCodedPref5().setVisible(true);
//		getCodedPref5().setPref("KW"); //$NON-NLS-1$
  	
  	updatePrefixes();

    getPanel().addComponentListener(new ComponentAdapter() {
      public void componentShown(ComponentEvent e){
        getTfPref1().requestFocusInWindow();
      }
    });
	}
 
Example 31
Project: samebug-idea-plugin   File: ErrorBarPane.java   Source Code and License 6 votes vote down vote up
public ErrorBarPane() {
    setOpaque(true);
    setBackground(ColorService.Background);
    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            super.componentResized(e);
            if (mainComponent != null) repositionMainComponent();
            if (errorBar != null) repositionErrorBar();
        }
    });

    timer = new Timer(ShowPopupForMillis, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            removeErrorBar(errorBar);
        }
    });
    timer.setRepeats(false);
    updateUI();
}
 
Example 32
Project: bisis-v4   File: SearchUsers.java   Source Code and License 6 votes vote down vote up
public void init() {
	getCmbPref1().setVisible(false);
	getCmbPref2().setVisible(false);
	getCmbPref3().setVisible(false);
	getCmbPref4().setVisible(false);
	getCmbPref5().setVisible(false);
	getLPref1().setText(Messages.getString("circulation.firstname")); //$NON-NLS-1$
	getTfPref1().setVisible(true);
	getLPref2().setText(Messages.getString("circulation.lastname")); //$NON-NLS-1$
	getTfPref2().setVisible(true);
	getLPref3().setText(Messages.getString("circulation.umcn")); //$NON-NLS-1$
	getTfPref3().setVisible(true);
	getLPref4().setText(Messages.getString("circulation.address")); //$NON-NLS-1$
	getTfPref4().setVisible(true);
	getLPref5().setText(Messages.getString("circulation.usernumber")); //$NON-NLS-1$
	getTfPref5().setVisible(true);

	getLDate1().setText(Messages.getString("circulation.chargingdate")); //$NON-NLS-1$
	getLDate2().setText(Messages.getString("circulation.dischargingdate")); //$NON-NLS-1$
   getPanel().addComponentListener(new ComponentAdapter() {
     public void componentShown(ComponentEvent e){
       getTfPref1().requestFocusInWindow();
     }
   });
}
 
Example 33
Project: Push2Display   File: JGVTComponent.java   Source Code and License 6 votes vote down vote up
/**
 * Creates a new JGVTComponent.
 * @param eventsEnabled Whether the GVT tree should be reactive
 *        to mouse and key events.
 * @param selectableText Whether the text should be selectable.
 *        if eventEnabled is false, this flag is ignored.
 */
public JGVTComponent(boolean eventsEnabled,
                     boolean selectableText) {
    setBackground(Color.white);
    // setDoubleBuffered(false);

    this.eventsEnabled = eventsEnabled;
    this.selectableText = selectableText;

    listener = createListener();

    addAWTListeners();

    addGVTTreeRendererListener(listener);

    addComponentListener(new ComponentAdapter() {
            public void componentResized(ComponentEvent e) {
                if (updateRenderingTransform())
                    scheduleGVTRendering();
            }
        });

}
 
Example 34
Project: jdk8u_jdk   File: FontPanel.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 35
Project: jdk8u_jdk   File: Popup401.java   Source Code and License 6 votes vote down vote up
private static void createAndShowGUI() {
    frame = new JFrame("HangPopupTest");
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.setSize(1000, 1000);

    test = new Popup401();
    frame.add(test);
    frame.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentShown(ComponentEvent e) {
            super.componentShown(e);
            test.run();
            synchronized (testCompleted) {
                testCompleted.notifyAll();
            }
        }
    });
    frame.pack();
    frame.setVisible(true);
}
 
Example 36
Project: lookaside_java-1.8.0-openjdk   File: FontPanel.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 37
Project: intellij-ce-playground   File: ConfigurationErrorsComponent.java   Source Code and License 6 votes vote down vote up
public ConfigurationErrorsComponent(@NotNull final Project project) {
  setLayout(new BorderLayout());
  myConfigurationErrorsListModel = new ConfigurationErrorsListModel(project);
  myConfigurationErrorsListModel.addListDataListener(this);

  addComponentListener(new ComponentAdapter() {
    @Override
    public void componentResized(final ComponentEvent e) {
      revalidate();
      repaint();
    }
  });

  ensureCurrentViewIs(ONE_LINE, null);
  Disposer.register(this, myConfigurationErrorsListModel);
}
 
Example 38
Project: OWLAx   File: BasicGraphEditor.java   Source Code and License 6 votes vote down vote up
/**
 * 
 */
public EditorPalette insertPalette(String title) {
	final EditorPalette palette = new EditorPalette();
	final JScrollPane scrollPane = new JScrollPane(palette);
	scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
	scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	libraryPane.add(title, scrollPane);

	// Updates the widths of the palettes if the container size changes
	libraryPane.addComponentListener(new ComponentAdapter() {
		/**
		 * 
		 */
		public void componentResized(ComponentEvent e) {
			int w = scrollPane.getWidth() - scrollPane.getVerticalScrollBar().getWidth();
			palette.setPreferredWidth(w);
		}

	});

	return palette;
}
 
Example 39
Project: code-similarity   File: UtilGUI.java   Source Code and License 6 votes vote down vote up
/** 
 * Track a Window's position across application restarts; location is saved
 * in a Preferences node that you pass in; we attach a ComponentListener to
 * the Window.
 */
public static void monitorWindowPosition(
    final Window w, final Preferences pNode) {

    // Get the current saved position, if any
    Point p = getSavedLocation(pNode);
    int savedX = (int)p.getX();
    int savedY = (int)p.getY();
    if (savedX != -1) {
        // Move window to is previous location
        w.setLocation(savedX, savedY);
    } else {
        // Not saved yet, at least make it look nice
        centre(w);
    }
    // Now make sure that if the user moves the window,
    // we will save the new position.
    w.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentMoved(ComponentEvent e) {
            setSavedLocation(pNode, w);
        }
    });
}
 
Example 40
Project: VISNode   File: EventHelper.java   Source Code and License 5 votes vote down vote up
/**
 * Adds a component move listener
 * 
 * @param component
 * @param listener 
 */
public static void addMoveListener(Component component, ComponentMoveListener listener) {
    component.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentMoved(ComponentEvent e) {
            listener.componentMoved(e);
        }
    });
}