Java Code Examples for java.awt.GridLayout

The following examples show how to use java.awt.GridLayout. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: netbeans   Source File: TreeTableMemoryLeakTest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void run() {

    // create panel (implementing ExplorerManager.Provider) with TTV
    MyPanel panel = new MyPanel();
    panel.setLayout(new GridLayout(1, 2));
    ttv = new TreeTableView();
    panel.add(ttv);

    // set root and keep the same root
    panel.setExplorerManagerRoot(root);


    //comment the next line to make the test works
    ttv.expandNode(root);

    // remove child
    children.remove(new Node[]{child});
    root = null;
    children = null;
}
 
Example 2
public HouseholdsPanelForCurrency(final Currency currency) {
	this.currency = currency;

	setLayout(new GridLayout(0, 3));

	this.add(createUtilityPanel(currency));
	// this.add(createUtilityFunctionMechanicsPanel(currency));
	this.add(createIncomeConsumptionSavingPanel(currency));
	this.add(createConsumptionSavingRatePanel(currency));
	this.add(createWageDividendPanel(currency));
	this.add(createIncomeSourcePanel(currency));
	incomeDistributionChart = createIncomeDistributionPanel(currency);
	this.add(new ChartPanel(incomeDistributionChart));
	this.add(createLorenzCurvePanel(currency));
	this.add(createHouseholdBalanceSheetPanel(currency));
	this.add(createLabourHourSupplyPanel(currency));
	this.add(createPricingBehaviourMechanicsPanel(currency, GoodType.LABOURHOUR));

	ApplicationContext.getInstance().getModelRegistry()
			.getNationalEconomyModel(currency).householdsModel.incomeDistributionModel.registerListener(this);
	// no registration with the price and market depth model, as they
	// call listeners synchronously

	notifyListener();
}
 
Example 3
Source Project: Qora   Source File: PasswordPane.java    License: MIT License 6 votes vote down vote up
public static String showUnlockWalletDialog()
{
	JPanel userPanel = new JPanel();
	userPanel.setLayout(new GridLayout(2,2));

	//Labels for the textfield components        
	JLabel passwordLbl = new JLabel("Enter wallet password:");
	JPasswordField passwordFld = new JPasswordField();

	//Add the components to the JPanel        
	userPanel.add(passwordLbl);
	userPanel.add(passwordFld);

	//As the JOptionPane accepts an object as the message
	//it allows us to use any component we like - in this case 
	//a JPanel containing the dialog components we want
	if(JOptionPane.showConfirmDialog(null, userPanel, "Unlock Wallet" ,JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION)
	{
		return new String(passwordFld.getPassword());
	}
	
	return "";
}
 
Example 4
Source Project: java-photoslibrary   Source File: LoadingView.java    License: Apache License 2.0 6 votes vote down vote up
private LoadingView() {
  UIHelper.setFixedSize(this, LOADING_DIMENSION);
  setTitle("Loading");
  moveToCenter();
  setResizable(false);
  setAlwaysOnTop(true);
  setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

  JProgressBar progressBar = new JProgressBar();
  progressBar.setIndeterminate(true);

  JPanel panel = new JPanel();
  panel.setBorder(BORDER);
  panel.setLayout(new GridLayout(1 /* rows */, 1 /* cols */));
  panel.add(progressBar);

  add(panel);
}
 
Example 5
Source Project: binnavi   Source File: CControlsPanel.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new control settings panel.
 *
 * @param settings Settings object that provides the graph settings to display.
 */
public CControlsPanel(final ZyGraphViewSettings settings) {
  super(new GridLayout(3, 1));
  setBorder(new TitledBorder("Controls"));

  CSettingsPanelBuilder.addComboBox(this,
      mouseWheelBehaviorBox,
      "Mousewheel Action" + ":",
      "Specifies whether the mousewheel is used for zooming or scrolling in graph windows.",
      new String[] {"Zoom", "Scroll"},
      settings.getMouseSettings().getMouseWheelAction().ordinal());

  CSettingsPanelBuilder.addDoubleSlider(this, m_tfScrollSensitivity, "Scroll Sensitivity" + ":",
      "Mouse sensitivity during scroll operations.",
      settings.getMouseSettings().getScrollSensitivity() / 5);

  CSettingsPanelBuilder.addDoubleSlider(this, m_tfZoomSensitivity, "Zoom Sensitivity" + ":",
      "Mouse sensitivity during zoom operations.",
      settings.getMouseSettings().getZoomSensitivity() / 5);
}
 
Example 6
Source Project: java-photoslibrary   Source File: ShareAlbumToolPanel.java    License: Apache License 2.0 6 votes vote down vote up
private JTextArea getMetadataTextArea(Album album) {
  JTextArea metadataTextArea = new JTextArea();
  metadataTextArea.setBorder(METADATA_BORDER);
  metadataTextArea.setLayout(
      new GridLayout(2 /* rows */, 1 /* cols */, 0 /* unset hgap */, 10 /* vgap */));
  metadataTextArea.setEditable(false);
  metadataTextArea.setLineWrap(true);
  metadataTextArea.append(String.format("URL: %s", album.getProductUrl()));
  if (album.hasShareInfo()) {
    metadataTextArea.append(
        String.format("\nShare URL: %s", album.getShareInfo().getShareableUrl()));
    metadataTextArea.append(
        String.format("\nShare Token: %s", album.getShareInfo().getShareToken()));
  }
  return metadataTextArea;
}
 
Example 7
Source Project: netbeans   Source File: DefaultPlugin.java    License: Apache License 2.0 6 votes vote down vote up
/**
 */
private static JComponent wrapDialogContent(JComponent comp,
                                            boolean selfResizing) {
    JComponent result;
    
    if ((comp.getBorder() != null) || selfResizing) {
        result = selfResizing ? new SelfResizingPanel() : new JPanel();
        result.setLayout(new GridLayout());
        result.add(comp);
    } else {
        result = comp;
    }
    result.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
    result.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_title_select_generator"));
    return result;
}
 
Example 8
/**
 * Creates a panel to choose a map transform.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 */
public MapEditorTransformPanel(FreeColClient freeColClient) {
    super(freeColClient, null, new BorderLayout());

    listPanel = new JPanel(new GridLayout(2, 0));

    group = new ButtonGroup();
    //Add an invisible, move button to de-select all others
    group.add(new JToggleButton());
    buildList();

    JScrollPane sl = new JScrollPane(listPanel,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    sl.getViewport().setOpaque(false);
    add(sl);
}
 
Example 9
Source Project: Spark   Source File: RawPacketSender.java    License: Apache License 2.0 6 votes vote down vote up
public RawPacketSender() {

	_mainframe = new JFrame("Send Raw Packets");
	_mainframe.setIconImage(SparkRes.getImageIcon(SparkRes.MAIN_IMAGE)
		.getImage());
	_mainpanel = new JPanel();
	_mainpanel.setLayout(new GridLayout(2, 1));
	_textarea = new JTextArea();
	_inputarea = new JTextArea();
	_textscroller = new JScrollPane(_textarea);
	_sendButton = new JButton("Send",
		SparkRes.getImageIcon(SparkRes.SMALL_CHECK));
	_clear = new JButton("Clear",
		SparkRes.getImageIcon(SparkRes.SMALL_DELETE));

	createGUI();

    }
 
Example 10
Source Project: java-photoslibrary   Source File: SearchMediaItemView.java    License: Apache License 2.0 6 votes vote down vote up
/** Creates a border-layout panel with padding. */
private JPanel initializeContentPanel() {
  JPanel panel = new JPanel();
  panel.setLayout(new BorderLayout(0 /* hgap */, 20 /* vgap */));

  JScrollPane scrollPane =
      new JScrollPane(
          panel,
          JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
          JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  scrollPane.setBorder(UIHelper.NO_BORDER);

  JPanel outerPanel = new JPanel();
  outerPanel.setLayout(new GridLayout(1 /* rows */, 1 /* cols */));
  outerPanel.setBorder(CONTENT_BORDER);
  outerPanel.add(scrollPane);
  add(outerPanel, BorderLayout.CENTER);

  return panel;
}
 
Example 11
Source Project: netbeans   Source File: DialogSupport.java    License: Apache License 2.0 6 votes vote down vote up
/** Create a panel with buttons that will be placed according
 * to the required alignment */
private JPanel createButtonPanel( JButton[] buttons, boolean sidebuttons ) {
    int count = buttons.length;
    
    JPanel outerPanel = new JPanel( new BorderLayout() );
    outerPanel.setBorder( new EmptyBorder( new Insets(
            sidebuttons ? 5 : 0, sidebuttons ? 0 : 5, 5, 5 ) ) );

    LayoutManager lm = new GridLayout( // GridLayout makes equal cells
            sidebuttons ? count : 1, sidebuttons ? 1 : count,  5, 5 );
        
    JPanel innerPanel = new JPanel( lm );
    
    for( int i = 0; i < count; i++ ) innerPanel.add( buttons[i] );
    
    outerPanel.add( innerPanel,
        sidebuttons ? BorderLayout.NORTH : BorderLayout.EAST ) ;
    return outerPanel;
}
 
Example 12
private PrintPreviewDialog(PCGenFrame frame)
{
	super(frame, true);
	this.frame = frame;
	this.character = frame.getSelectedCharacterRef().get();
	this.previewPanelParent = new JPanel(new GridLayout(1, 1));
	this.sheetBox = new JComboBox<>();
	this.progressBar = new JProgressBar();
	this.pageBox = new JComboBox<>();
	this.zoomBox = new JComboBox<>();
	this.zoomInButton = new JButton();
	this.zoomOutButton = new JButton();
	this.printButton = new JButton();
	this.cancelButton = new JButton();
	initComponents();
	initLayout();
	pack();
	new SheetLoader().execute();
}
 
Example 13
void createObjects() {
    textArea = new TextArea( bigString() );
    robot = Util.createRobot();

    Panel panel = new Panel();
    panel.setLayout( new GridLayout(3,3) );

    for( int y=0; y<3; ++y ) {
        for( int x=0; x<3; ++x ) {
            if( x==1 && y==1 ) {
                panel.add( textArea );
            } else {
                panel.add( new Panel() );
            }
        }
    }

    Frame frame = new Frame( "TextArea cursor icon test" );
    frame.setSize( 300, 300 );
    frame.add( panel );
    frame.setVisible( true );
}
 
Example 14
Source Project: JavaMainRepo   Source File: AFrame.java    License: Apache License 2.0 6 votes vote down vote up
public AFrame(String title) {
	super(title);
	contentPanel.setLayout(new GridLayout(0, 3, 0, 0));
	
	JPanel panel = new JPanel();
	contentPanel.add(panel);

	JPanel pan = new JPanel();
	contentPanel.add(pan);
	SpringLayout slPanel = new SpringLayout();
	pan.setLayout(slPanel);

	animalButton = new JButton("Animal");
	slPanel.putConstraint(SpringLayout.NORTH, animalButton, 65, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, animalButton, 93, SpringLayout.WEST, pan);
	pan.add(animalButton);

	employeeButton = new JButton("Employee");
	slPanel.putConstraint(SpringLayout.NORTH, employeeButton, 100, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, employeeButton, 93, SpringLayout.WEST, pan);
	pan.add(employeeButton);

	JPanel rightPanel = new JPanel();
	contentPanel.add(rightPanel);
	setVisible(true);
}
 
Example 15
Source Project: JavaMainRepo   Source File: EmployeeFrame.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param title
 *            The title of the frame.
 */
public EmployeeFrame(final String title) {
	super(title);
	contentPanel.setLayout(new GridLayout(0, 1, 0, 0));
	JPanel pan = new JPanel();
	contentPanel.add(pan);
	SpringLayout slPanel = new SpringLayout();
	pan.setLayout(slPanel);
	Caretaker = new JButton("Caretaker");
	slPanel.putConstraint(SpringLayout.NORTH, Caretaker, 180, SpringLayout.NORTH, pan);
	slPanel.putConstraint(SpringLayout.WEST, Caretaker, 280, SpringLayout.WEST, pan);
	pan.add(Caretaker);
	JPanel panel_2 = new JPanel();
	contentPanel.add(panel_2);
	setVisible(true);
}
 
Example 16
Source Project: birt   Source File: Regression_119808.java    License: Eclipse Public License 1.0 6 votes vote down vote up
ControlPanel( Regression_119808 siv )
{
	this.siv = siv;

	setLayout( new GridLayout( 0, 1, 0, 0 ) );

	JPanel jp = new JPanel( );
	jp.setLayout( new FlowLayout( FlowLayout.LEFT, 3, 3 ) );

	jp.add( new JLabel( "Choose:" ) );//$NON-NLS-1$
	jcbModels = new JComboBox( );

	jcbModels.addItem( "Bar Chart" );
	jcbModels.setSelectedIndex( 0 );
	jp.add( jcbModels );

	jbUpdate = new JButton( "Update" );//$NON-NLS-1$
	jbUpdate.addActionListener( this );
	jp.add( jbUpdate );

	add( jp );
}
 
Example 17
Source Project: ApkToolPlus   Source File: InterfacesGeneralPane.java    License: Apache License 2.0 6 votes vote down vote up
protected void setupComponent() {
	addButton = new JButton("Add interface");
	name = new JTextField(15);

	JPanel namePanel = new JPanel();
	namePanel.setLayout(new GridLayout(2, 1));
	namePanel.add(new JLabel("Interface name"));
	namePanel.add(name);
	add(namePanel);

	JPanel buttonPanel = new JPanel();
	buttonPanel.setLayout(new GridLayout(2, 1));
	
	buttonPanel.add(new JLabel(""));
	buttonPanel.add(addButton);
       Border simpleBorder = BorderFactory.createEtchedBorder();
       Border border = BorderFactory.createTitledBorder(simpleBorder,
               "Add interface");
	this.setBorder(border);		
	add(buttonPanel);
	addButton.addActionListener(this);
	addButton.setActionCommand("add");
}
 
Example 18
Source Project: rest-client   Source File: OptionsEtcPanel.java    License: Apache License 2.0 6 votes vote down vote up
OptionsEtcPanel(){
    this.setLayout(new FlowLayout(FlowLayout.LEFT));
    jcb_indentResponse.setMnemonic('a');

    jcb_syntaxRequest.setToolTipText("Requires RESTClient restart!");
    jcb_syntaxResponse.setToolTipText("Requires RESTClient restart!");
    
    JPanel jp = new JPanel();
    jp.setLayout(new GridLayout(4, 1));
    
    jp.add(jcb_indentResponse);
    jp.add(jcb_syntaxRequest);
    jp.add(jcb_syntaxResponse);
    JPanel jp_scrollSpeed = new JPanel(new BorderLayout());
    JPanel jp_scrollSpeed_inner = new JPanel(new FlowLayout());
    jp_scrollSpeed_inner.add(new JLabel("Text areas scroll speed"));
    jp_scrollSpeed_inner.add(js_scrollSpeed);
    jp_scrollSpeed.add(BorderLayout.WEST, jp_scrollSpeed_inner);
    jp.add(jp_scrollSpeed);
    ((JSpinner.DefaultEditor)js_scrollSpeed.getEditor()).getTextField().setColumns(2);
    
    this.add(jp);
}
 
Example 19
/**
 * Create the GUI components
 * @param inTopLabelKey key for description label at top
 * @param inLowerLabelKey key for description label at bottom, if any
 */
private void createComponents(String inTopLabelKey, String inLowerLabelKey)
{
	setLayout(new BorderLayout());
	add(new JLabel(I18nManager.getText(inTopLabelKey)), BorderLayout.NORTH);
	// panel for the radio buttons
	JPanel gridPanel = new JPanel();
	gridPanel.setLayout(new GridLayout(0, 3, 15, 3));
	final String[] keys = {"beginning", "middle", "end"};
	ButtonGroup group = new ButtonGroup();
	for (int i=0; i<3; i++)
	{
		_radios[i] = new JRadioButton(I18nManager.getText("dialog.correlate.timestamp." + keys[i]));
		group.add(_radios[i]);
		gridPanel.add(_radios[i]);
	}
	_radios[0].setSelected(true);
	add(gridPanel, BorderLayout.CENTER);
	if (inLowerLabelKey != null) {
		add(new JLabel(I18nManager.getText(inLowerLabelKey)), BorderLayout.SOUTH);
	}
}
 
Example 20
Source Project: birt   Source File: DataChartsViewer.java    License: Eclipse Public License 1.0 5 votes vote down vote up
ControlPanel( DataChartsViewer dcv )
{
	this.dcv = dcv;

	setLayout( new GridLayout( 0, 1, 0, 0 ) );

	JPanel jp = new JPanel( );
	jp.setLayout( new FlowLayout( FlowLayout.LEFT, 3, 3 ) );

	JLabel choose=new JLabel( "Choose:" );//$NON-NLS-1$
	choose.setDisplayedMnemonic( 'c' );
	jp.add( choose );
	jcbModels = new JComboBox( );

	jcbModels.addItem( "Min Slice" );//$NON-NLS-1$
	jcbModels.addItem( "Multiple Y Axis" );//$NON-NLS-1$
	jcbModels.addItem( "Multiple Y Series" );//$NON-NLS-1$
	jcbModels.addItem( "Big number Y Series" );//$NON-NLS-1$

	jcbModels.setSelectedIndex( 0 );
	choose.setLabelFor( jcbModels );
	jp.add( jcbModels );

	jbUpdate = new JButton( "Update" );//$NON-NLS-1$
	jbUpdate.setMnemonic( 'u' );
	jbUpdate.setToolTipText( "Update" );//$NON-NLS-1$
	jbUpdate.addActionListener( this );
	jp.add( jbUpdate );

	add( jp );
}
 
Example 21
Source Project: plugins   Source File: FeedPanel.java    License: GNU General Public License v3.0 5 votes vote down vote up
FeedPanel(FeedConfig config, Supplier<FeedResult> feedSupplier)
{
	super(true);
	this.config = config;
	this.feedSupplier = feedSupplier;

	setBorder(new EmptyBorder(10, 10, 10, 10));
	setBackground(ColorScheme.DARK_GRAY_COLOR);
	setLayout(new GridLayout(0, 1, 0, 4));
}
 
Example 22
Source Project: JByteMod-Beta   Source File: PageEndPanel.java    License: GNU General Public License v2.0 5 votes vote down vote up
public PageEndPanel() {
  this.pb = new JProgressBar() {
    @Override
    public void setValue(int n) {
      if (n == 100) {
        super.setValue(0);
        percent.setText("");
      } else {
        super.setValue(n);
        percent.setText(n + "%");
      }
    }
  };
  this.setLayout(new GridLayout(1, 4, 10, 10));
  this.setBorder(new EmptyBorder(3, 0, 0, 0));
  this.add(pb);
  this.add(percent = new JLabel());
  percent.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13));
  label = new JLabel(copyright);
  label.setHorizontalAlignment(SwingConstants.RIGHT);
  label.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13));
  this.add(label);
  memoryBar = new WebMemoryBar();
  memoryBar.setShowMaximumMemory(false);
  this.add(memoryBar);

}
 
Example 23
/**
 * Constructor
 * @param siteName the site name.
 * @param completion the completion level.
 */
ExplorationSitePanel(String siteName, double completion) {
	// Use JPanel constructor.
	super();

	this.completion = completion;

	setLayout(new GridLayout(1, 2, 3, 3));

	WebPanel namePanel = new WebPanel(new FlowLayout(FlowLayout.RIGHT, 3, 3));
	namePanel.setAlignmentX(CENTER_ALIGNMENT);
	add(namePanel);

	WebLabel nameLabel = new WebLabel("  " + Conversion.capitalize(siteName), SwingConstants.RIGHT);
	nameLabel.setAlignmentX(CENTER_ALIGNMENT);
	namePanel.add(nameLabel);

	WebPanel barPanel = new WebPanel(new FlowLayout(FlowLayout.LEFT, 3, 0));
	barPanel.setAlignmentX(CENTER_ALIGNMENT);
	add(barPanel);

	completionBar = new WebProgressBar(0, 100);
	completionBar.setAlignmentX(CENTER_ALIGNMENT);
	completionBar.setStringPainted(true);
	completionBar.setValue((int) (completion * 100D));
	barPanel.add(completionBar);
}
 
Example 24
Source Project: hottub   Source File: CardTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
CardPanel(ActionListener actionListener) {
    listener = actionListener;
    setLayout(new CardLayout());
    add("one", create(new FlowLayout()));
    add("two", create(new BorderLayout()));
    add("three", create(new GridLayout(2, 2)));
    add("four", create(new BorderLayout(10, 10)));
    add("five", create(new FlowLayout(FlowLayout.LEFT, 10, 10)));
    add("six", create(new GridLayout(2, 2, 10, 10)));
}
 
Example 25
Source Project: Luyten   Source File: JFontChooser.java    License: Apache License 2.0 5 votes vote down vote up
protected JDialog createDialog(Component parent) {
	Frame frame = parent instanceof Frame ? (Frame) parent
			: (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
	JDialog dialog = new JDialog(frame, ("Select Font"), true);

	Action okAction = new DialogOKAction(dialog);
	Action cancelAction = new DialogCancelAction(dialog);

	JButton okButton = new JButton(okAction);
	okButton.setFont(DEFAULT_FONT);
	JButton cancelButton = new JButton(cancelAction);
	cancelButton.setFont(DEFAULT_FONT);

	JPanel buttonsPanel = new JPanel();
	buttonsPanel.setLayout(new GridLayout(2, 1));
	buttonsPanel.add(okButton);
	buttonsPanel.add(cancelButton);
	buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));

	ActionMap actionMap = buttonsPanel.getActionMap();
	actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
	actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
	InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
	inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
	inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));

	JPanel dialogEastPanel = new JPanel();
	dialogEastPanel.setLayout(new BorderLayout());
	dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH);

	dialog.getContentPane().add(this, BorderLayout.CENTER);
	dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST);
	dialog.pack();
	dialog.setLocationRelativeTo(frame);
	return dialog;
}
 
Example 26
private void constructPanel(String[] values) {
	// constructing editors
	editors = new PropertyValueCellEditor[types.length];
	for (int i = 0; i < types.length; i++) {
		editors[i] = PropertyPanel.instantiateValueCellEditor(types[i], operator);
	}

	// building panel
	panel = new JPanel();
	panel.setFocusable(true);
	panel.setLayout(new GridLayout(1, editors.length));
	for (int i = 0; i < types.length; i++) {
		Component editorComponent = editors[i].getTableCellEditorComponent(null, values[i], false, 0, 0);

		if (editorComponent instanceof JComboBox) {
			if (((JComboBox<?>) editorComponent).isEditable()) {
				ComboBoxEditor editor = ((JComboBox<?>) editorComponent).getEditor();
				if (editor instanceof BasicComboBoxEditor) {
					editor.getEditorComponent().addFocusListener(focusListener);
				}
			} else {
				editorComponent.addFocusListener(focusListener);
			}
		} else if (editorComponent instanceof JPanel) {
			JPanel editorPanel = (JPanel) editorComponent;
			Component[] components = editorPanel.getComponents();
			for (Component comp : components) {
				comp.addFocusListener(focusListener);
			}
		} else {

			editorComponent.addFocusListener(focusListener);
		}
		panel.add(editorComponent);
		panel.addFocusListener(focusListener);
	}
}
 
Example 27
public void start() {
    String[] instructions = new String[] {
        "1. Notice components in test window: main-panel, box-for-text,"
            +" 2 scroll-sliders, and 4 scroll-buttons.",
        "2. Hover mouse over box-for-text."
            +" Make sure, that mouse cursor is TextCursor (a.k.a. \"beam\").",
        "3. Hover mouse over each of components (see item 1), except for box-for-text."
            +" Make sure, that cursor is DefaultCursor (arrow).",
        "4. Drag mouse (using any mouse button) from box-for-text to every"
            +" component in item 1, and also outside application window."
            +" Make sure, that cursor remains TextCursor while mouse button is pressed.",
        "5. Repeat item 4 for each other component in item 1, except for box-for-text,"
            +" _but_ now make sure that cursor is DefaultCursor.",
        "6. If cursor behaves as described in items 2-3-4-5, then test passed; otherwise it failed."
    };
    Sysout.createDialogWithInstructions( instructions );

    Panel panel = new Panel();
    panel.setLayout( new GridLayout(3,3) );

    for( int y=0; y<3; ++y ) {
        for( int x=0; x<3; ++x ) {
            if( x==1 && y==1 ) {
                panel.add( new TextArea( bigString() ) );
            } else {
                panel.add( new Panel() );
            }
        }
    }

    Frame frame = new Frame( "TextArea cursor icon test" );
    frame.setSize( 300, 300 );
    frame.add( panel );
    frame.setVisible( true );
}
 
Example 28
private void initTemplatesPanel() {
    templatePanel = new TemplatePanelVisual();
    templatePanelHolder.setLayout(new GridLayout(1, 1));
    templatePanelHolder.add(templatePanel);
    templatePanel.setVisible(true);
    templatePanelHolder.setEnabled(false);
    repaint();
    revalidate();
    setVisibleTemplateInfo(false);
}
 
Example 29
Source Project: moa   Source File: ImageTreePanel.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructor.
 * @param chart
 */
public ImageTreePanel(ImageChart chart[]) {
    super(new GridLayout(1, 0));
    this.chart = chart;
    //Create the nodes.
    DefaultMutableTreeNode top
            = new DefaultMutableTreeNode("Images");
    imgPanel = new JPanel();
    imgPanel.setLayout(new GridLayout(1, 0));
    createNodes(top);
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
    tree.setSelectionRow(1);

    tree.addTreeSelectionListener(this);
    ImageIcon leafIcon = new ImageIcon("icon/img.png");
    if (leafIcon != null) {
        DefaultTreeCellRenderer renderer
                = new DefaultTreeCellRenderer();
        renderer.setLeafIcon(leafIcon);
        tree.setCellRenderer(renderer);
    }
    imgPanel.updateUI();
    JScrollPane treeView = new JScrollPane(tree);
    treeView.setMinimumSize(new Dimension(100, 50));

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(imgPanel);
    splitPane.setDividerLocation(100);
    splitPane.setPreferredSize(new Dimension(500, 300));
    add(splitPane);

}
 
Example 30
Source Project: openjdk-8   Source File: XOperations.java    License: GNU General Public License v2.0 5 votes vote down vote up
public XOperations(MBeansTab mbeansTab) {
    super(new GridLayout(1, 1));
    this.mbeansTab = mbeansTab;
    operationEntryTable = new Hashtable<JButton, OperationEntry>();
    ArrayList<NotificationListener> l =
            new ArrayList<NotificationListener>(1);
    notificationListenersList =
            Collections.synchronizedList(l);
}