Java Code Examples for javax.swing.JLabel#setVisible()

The following examples show how to use javax.swing.JLabel#setVisible() . 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: Spark   File: IconTextField.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new IconTextField with Icon.
 *
 * @param icon the icon.
 */
public IconTextField(Icon icon) {
    setLayout(new GridBagLayout());
    setBackground((Color)UIManager.get("TextField.background"));

    textField = new JTextField();
    textField.setBorder(null);
    setBorder(new JTextField().getBorder());

    imageComponent = new JLabel(icon);
    downOption = new JLabel(SparkRes.getImageIcon(SparkRes.DOWN_OPTION_IMAGE));

    add(downOption, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    add(imageComponent, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    add(textField, new GridBagConstraints(2, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 5, 0, 0), 0, 0));

    downOption.setVisible(false);
}
 
Example 2
Source Project: collect-earth   File: PropertiesDialog.java    License: MIT License 5 votes vote down vote up
public void handleVisibilityPlotLayout(JComboBox plotShape, JComboBox numberPoints, JComboBox distanceBetweenPoints,
		JComboBox distanceToFrame, JComboBox dotsSide, JComboBox distanceBetweenPlots, JLabel area,
		JLabel distanceOrRadiuslabel, JComboBox largeCentralPlotSide ) {
	numberPoints.setEnabled(false);
	distanceBetweenPoints.setEnabled(false);
	distanceToFrame.setEnabled(false);
	dotsSide.setEnabled(false);
	area.setVisible(false);
	distanceBetweenPlots.setVisible(false);
	distanceBetweenPlots.setEnabled(false);
	largeCentralPlotSide.setVisible( false );
	largeCentralPlotSide.setEnabled(false);

	if (plotShape.getSelectedItem().equals(SAMPLE_SHAPE.SQUARE) || plotShape.getSelectedItem().equals(SAMPLE_SHAPE.SQUARE_WITH_LARGE_CENTRAL_PLOT) ) {
		numberPoints.setEnabled(true);
		distanceBetweenPoints.setEnabled(true);
		distanceToFrame.setEnabled(true);
		dotsSide.setEnabled(true);
		area.setVisible(true);
		distanceOrRadiuslabel.setText(Messages.getString("OptionWizard.36"));

		if( plotShape.getSelectedItem().equals(SAMPLE_SHAPE.SQUARE_WITH_LARGE_CENTRAL_PLOT) ) {
			largeCentralPlotSide.setVisible( true );
			largeCentralPlotSide.setEnabled(true);
		}

	} else if (plotShape.getSelectedItem().equals(SAMPLE_SHAPE.CIRCLE)
			|| plotShape.getSelectedItem().equals(SAMPLE_SHAPE.HEXAGON)) {
		distanceBetweenPoints.setEnabled(true);
		dotsSide.setEnabled(true);
		numberPoints.setEnabled(true);
		distanceOrRadiuslabel.setText("Radius");
	} else if (plotShape.getSelectedItem().equals(SAMPLE_SHAPE.NFI_THREE_CIRCLES) || plotShape.getSelectedItem().equals(SAMPLE_SHAPE.NFI_FOUR_CIRCLES)) {
		dotsSide.setEnabled(true);
		distanceBetweenPoints.setEnabled(true);
		distanceBetweenPlots.setVisible(true);
		distanceBetweenPlots.setEnabled(true);
		distanceOrRadiuslabel.setText("Radius of the plots");
	}
}
 
Example 3
/**
 * Hide all status icons. This is called when the user entity is deleted.
 */
void resetStatuses() {
	for (JLabel status : statusIDMap.values()) {
		if (status.isVisible()) {
			status.setVisible(false);
		}
	}
}
 
Example 4
Source Project: netbeans   File: BoxFillerInitializer.java    License: Apache License 2.0 5 votes vote down vote up
WidthHeightPanel(boolean showWidth, boolean showHeight) {
    ResourceBundle bundle = NbBundle.getBundle(BoxFillerInitializer.class);
    JLabel widthLabel = new JLabel(bundle.getString("BoxFillerInitializer.width")); // NOI18N
    JLabel heightLabel = new JLabel(bundle.getString("BoxFillerInitializer.height")); // NOI18N
    widthField = new JSpinner(new SpinnerNumberModel());
    heightField = new JSpinner(new SpinnerNumberModel());
    GroupLayout layout = new GroupLayout(this);
    setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                .addComponent(widthLabel)
                .addComponent(heightLabel))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addComponent(widthField)
                .addComponent(heightField))
            .addContainerGap())
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(widthLabel)
                .addComponent(widthField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(heightLabel)
                .addComponent(heightField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
            .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    widthLabel.setVisible(showWidth);
    heightLabel.setVisible(showHeight);
    widthField.setVisible(showWidth);
    heightField.setVisible(showHeight);
}
 
Example 5
protected StatusIconPanel() {
	setLayout(new SBoxLayout(SBoxLayout.HORIZONTAL));
	setOpaque(false);

	eating = new JLabel(eatingIcon);
	add(eating);
	eating.setVisible(false);

	choking = new JLabel(chokingIcon);
	add(choking);
	choking.setVisible(false);

	away = new AnimatedIcon(awaySprite, 2000);
	add(away);
	away.setVisible(false);

	grumpy = new AnimatedIcon(grumpySprite, 2000);
	add(grumpy);
	grumpy.setVisible(false);

	/** Initialize map */
       statusIDMap = new EnumMap<StatusID, JLabel>(StatusID.class);
       statusIDMap.put(StatusID.CONFUSE, createStatusIndicator("confuse"));
       statusIDMap.put(StatusID.POISON, createStatusIndicator("poison"));
       statusIDMap.put(StatusID.SHOCK, createStatusIndicator("shock"));
       statusIDMap.put(StatusID.ZOMBIE, createStatusIndicator("zombie"));
       statusIDMap.put(StatusID.HEAVY, createStatusIndicator("heavy"));
}
 
Example 6
Source Project: pumpernickel   File: QOptionPaneUI.java    License: MIT License 5 votes vote down vote up
protected void updateIcon(QOptionPane pane) {
	Icon icon = pane.getIcon();
	JLabel label = getIconLabel(pane);
	if (icon == null) {
		label.setIcon(null);
		label.setVisible(false);
	} else {
		label.setIcon(icon);
		label.setVisible(true);
	}
}
 
Example 7
void visibleApp(boolean visible, JLabel paramsLabel, JTextField paramsTextField, JTextField nameTextField) {
    paramsLabel.setVisible(visible);
    paramsTextField.setVisible(visible);
    if (nameTextField != null) {
        nameTextField.setVisible(visible);
    }
}
 
Example 8
private void setStars() {
    int locationPoint = 390;
    for (int i = 0; i < 5; i++) {
        stars = new JLabel("");
        stars.setHorizontalTextPosition(SwingConstants.CENTER);
        stars.setHorizontalAlignment(SwingConstants.CENTER);
        stars.setIcon(new ImageIcon(HotelPropertiesWindow.class.getResource("/com/coder/hms/icons/hotel_external_star.png")));
        stars.setBounds(locationPoint, 19, 46, 37);
        stars.setVisible(false);
        starHolder.add(stars);

        starlabels[i] = stars;
        locationPoint = locationPoint + 44;
    }
}
 
Example 9
/**
 * Create the dialog.
 */
public SizeSelectDialog() {
  setBounds(100, 100, 198, 161);
  getContentPane().setLayout(new BorderLayout());
  contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
  getContentPane().add(contentPanel, BorderLayout.CENTER);
  contentPanel.setLayout(new MigLayout("", "[][]", "[][][]"));
  {
    JLabel lblWidth = new JLabel("width");
    contentPanel.add(lblWidth, "cell 0 0,alignx trailing");
  }
  {
    txtWidth = new JTextField();
    txtWidth.setText("400");
    contentPanel.add(txtWidth, "cell 1 0,growx");
    txtWidth.setColumns(10);
  }
  {
    JLabel lblHeight = new JLabel("height");
    contentPanel.add(lblHeight, "cell 0 1,alignx trailing");
  }
  {
    txtHeight = new JTextField();
    txtHeight.setText("300");
    contentPanel.add(txtHeight, "cell 1 1,growx");
    txtHeight.setColumns(10);
  }
  {
    lblWrongInput = new JLabel("wrong input");
    lblWrongInput.setFont(new Font("Tahoma", Font.BOLD, 13));
    lblWrongInput.setForeground(new Color(220, 20, 60));
    lblWrongInput.setVisible(false);
    contentPanel.add(lblWrongInput, "cell 0 2 2 1");
  }
  {
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
    getContentPane().add(buttonPane, BorderLayout.SOUTH);
    {
      JButton okButton = new JButton("OK");
      okButton.addActionListener(e -> checkResultsAndFinish());
      buttonPane.add(okButton);
      getRootPane().setDefaultButton(okButton);
    }
    {
      JButton cancelButton = new JButton("Cancel");
      cancelButton.addActionListener(e -> setVisible(false));
      buttonPane.add(cancelButton);
    }
  }
  setModalityType(ModalityType.APPLICATION_MODAL);
  setVisible(true);
  pack();
}
 
Example 10
Source Project: SikuliX1   File: TransitionDialog.java    License: MIT License 4 votes vote down vote up
void init(String text){

      setBackground(Color.yellow);
      setForeground(Color.black);

      JPanel content = new JPanel();
      content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
      add(content);

      textPane = new TextPane();
      textPane.setText(text);
      textPane.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));

      Color darkyellow = new Color(238,185,57);

      titleBar = new JLabel();
      titleBar.setFont(new Font("sansserif", Font.BOLD, 14));
      titleBar.setBackground(darkyellow);
      titleBar.setOpaque(true);
      titleBar.setBorder(BorderFactory.createEmptyBorder(5, 5, 3, 5));
      titleBar.setSize(titleBar.getPreferredSize());
      titleBar.setVisible(false);

      buttons = new Box(BoxLayout.X_AXIS);
      defaultButton = new Button("Close");
      buttons.add(defaultButton);
      buttons.setBorder(BorderFactory.createEmptyBorder(15,5,5,5));

      content.add(titleBar);
      content.add(textPane);
      content.add(buttons);

      // this allows the title bar to take the whole width of the dialog box
      titleBar.setMaximumSize(new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE));
      buttons.setMaximumSize(new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE));
      textPane.setMaximumSize(new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE));

      // these allow all the parts to left aligned
      titleBar.setAlignmentX(Component.LEFT_ALIGNMENT);
      textPane.setAlignmentX(Component.LEFT_ALIGNMENT);
      buttons.setAlignmentX(Component.LEFT_ALIGNMENT);

      // these are meant to prevent the message box from stealing
      // focus when it's clicked, but they don't seem to work
//      setFocusableWindowState(false);
//      setFocusable(false);

      // this allows the window to be dragged to another location on the screen
      ComponentMover cm = new ComponentMover();
      cm.registerComponent(this);

      pack();
   }
 
Example 11
public StatusBar()
{
    super(new BorderLayout());
    JPanel outerPanel = new JPanel(new BorderLayout());
    add(outerPanel, BorderLayout.CENTER);
    if (Platform.isMac())
    {
        // add some empty space so that status bar does not overlap the
        // window resize widget on Mac OS X
        Dimension dimension = new Dimension(20, 1);
        Box.Filler filler =
            new Box.Filler(dimension, dimension, dimension);
        outerPanel.add(filler, BorderLayout.EAST);
    }
    JPanel panel = new JPanel(new BorderLayout());
    //panel.setBorder(BorderFactory.createLineBorder(Color.gray));
    outerPanel.add(panel, BorderLayout.CENTER);
    m_iconBox = Box.createHorizontalBox();
    panel.add(m_iconBox, BorderLayout.WEST);
    m_toPlayLabel = new JLabel();
    m_toPlayLabel.setMaximumSize(new Dimension(Short.MAX_VALUE,
                                               Short.MAX_VALUE));
    setToPlay(BLACK);
    m_iconBox.add(m_toPlayLabel);

    m_labelSetup
        = new JLabel(GuiUtil.getIcon("gogui-setup-16x16",
                                     i18n("LB_STATUS_SETUP")));
    m_labelSetup.setVisible(false);
    m_labelSetup.setToolTipText(i18n("TT_STATUS_SETUP"));
    m_iconBox.add(m_labelSetup);

    m_iconBox.add(GuiUtil.createSmallFiller());

    m_text = new JLabel() {
            /** Use tool tip if text is truncated. */
            protected void paintComponent(Graphics g)
            {
                super.paintComponent(g);
                String text = super.getText();
                if (text == null
                    || g.getFontMetrics().stringWidth(text) < getWidth())
                    setToolTipText(null);
                else
                    setToolTipText(text);
            }
        };
    setPreferredLabelSize(m_text, 10);
    panel.add(m_text, BorderLayout.CENTER);
    Box moveTextBox = Box.createHorizontalBox();
    panel.add(moveTextBox, BorderLayout.EAST);
    m_moveText = new JLabel();
    setPreferredLabelSize(m_moveText, 12);
    m_moveText.setHorizontalAlignment(SwingConstants.LEFT);
    m_moveTextSeparator = new JSeparator(SwingConstants.VERTICAL);
    moveTextBox.add(m_moveTextSeparator);
    moveTextBox.add(GuiUtil.createSmallFiller());
    moveTextBox.add(m_moveText);
}
 
Example 12
Source Project: netbeans   File: StringEditor.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Component getCustomEditor () {
    if (customEditor == null) {
        JTextArea textArea = new JTextArea();
        textArea.setWrapStyleWord(true);
        textArea.setLineWrap(true);
        textArea.setColumns(60);
        textArea.setRows(8);
        textArea.getDocument().addDocumentListener(this);
        textArea.getAccessibleContext().setAccessibleName(
                NbBundle.getBundle(StringEditor.class).getString("ACSN_StringEditorTextArea")); //NOI18N
        textArea.getAccessibleContext().setAccessibleDescription(
                NbBundle.getBundle(StringEditor.class).getString("ACSD_StringEditorTextArea")); //NOI18N

        JScrollPane scroll = new JScrollPane();
        scroll.setViewportView(textArea);

        JLabel htmlTipLabel = new JLabel(NbBundle.getMessage(StringEditor.class, "StringEditor.htmlTipLabel.text")); // NOI18N

        JPanel panel = new JPanel();
        GroupLayout layout = new GroupLayout(panel);
        layout.setAutoCreateGaps(true);
        panel.setLayout(layout);
        layout.setHorizontalGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup()
                    .addComponent(scroll)
                    .addComponent(htmlTipLabel))
                .addContainerGap());
        layout.setVerticalGroup(layout.createSequentialGroup()
                .addContainerGap().addComponent(scroll).addComponent(htmlTipLabel));

        customEditor = panel;
        textComp = textArea;
        htmlTipLabel.setVisible(htmlText);
    }

    textComp.setEditable(editable);
    setValueToCustomEditor();

    return customEditor;
}
 
Example 13
/**
 * Constructor, creating GUI items.
 */
public EditTrafficModelControlPanel() {
	setLayout(new GridBagLayout());
	
	// global layout settings
	GridBagConstraints c = new GridBagConstraints();
	c.fill = GridBagConstraints.BOTH;
	c.anchor = GridBagConstraints.PAGE_START;
	c.weightx = 0.5;
	c.gridx = 0;
	c.gridy = 0;
	c.gridheight = 1;
	
	c.gridwidth = 1;

	c.insets = new Insets(5,5,5,5);
	
	c.gridx = 0;
	
	// Radio buttons to select add, edit or delete mode
	ButtonGroup group = new ButtonGroup();
	selectModel_ = new JRadioButton(Messages.getString("EditTrafficControlPanel.model")); //$NON-NLS-1$
	selectModel_.setActionCommand("model"); //$NON-NLS-1$
	selectModel_.addActionListener(this);
	selectModel_.setSelected(true);
	group.add(selectModel_);
	++c.gridy;
	add(selectModel_,c);
			
	selectTraces_ = new JRadioButton(Messages.getString("EditTrafficControlPanel.traces")); //$NON-NLS-1$
	selectTraces_.setActionCommand("traces"); //$NON-NLS-1$
	selectTraces_.addActionListener(this);
	group.add(selectTraces_);
	++c.gridy;
	add(selectTraces_,c);
		
	
	c.gridx = 0;
	chooseTrafficModelLabel_ = new JLabel(Messages.getString("EditTrafficControlPanel.comboBoxModel")); //$NON-NLS-1$
	++c.gridy;
	add(chooseTrafficModelLabel_,c);
	chooseTrafficModel_ = new JComboBox<String>();
	chooseTrafficModel_.setActionCommand("chooseTrafficModel");
	chooseTrafficModel_.addItem("VANETSim classic");
	chooseTrafficModel_.addItem("IDM/MOBIL");
	chooseTrafficModel_.addActionListener(this);
	c.gridx = 1;
	add(chooseTrafficModel_, c);
	
	
	c.gridx = 0;
	chooseTracesLabel_ = new JLabel(Messages.getString("EditTrafficControlPanel.comboBoxTraces")); //$NON-NLS-1$
	++c.gridy;
	add(chooseTracesLabel_,c);
	chooseTraces_ = new JComboBox<String>();
	chooseTraces_.setActionCommand("chooseTraces");
	chooseTraces_.addItem("sjtu taxi traces");
	chooseTraces_.addItem("San Francisco traces");
	chooseTraces_.addActionListener(this);
	c.gridx = 1;
	add(chooseTraces_, c);
	chooseTraces_.setVisible(false);
	chooseTracesLabel_.setVisible(false);
	
	
	
	//to consume the rest of the space
	c.weighty = 1.0;
	++c.gridy;
	JPanel space = new JPanel();
	space.setOpaque(false);
	add(space, c);
}
 
Example 14
public GeneralSettingsPanel(final Program program, final SettingsDialog optionsDialog) {
	super(program, optionsDialog, DialoguesSettings.get().general(),  Images.DIALOG_SETTINGS.getIcon());

	jEnterFilters = new JCheckBox(DialoguesSettings.get().enterFilter());

	jHighlightSelectedRow = new JCheckBox(DialoguesSettings.get().highlightSelectedRow());

	jFocusEveOnline = new JCheckBox(DialoguesSettings.get().focusEveOnline());

	JLabel jFocusEveOnlineLinuxHelp = new JLabel(DialoguesSettings.get().focusEveOnlineLinuxHelp());
	jFocusEveOnlineLinuxHelp.setVisible(Platform.isLinux());
	JTextField jFocusEveOnlineLinuxCmd = new JTextField(DialoguesSettings.get().focusEveOnlineLinuxCmd());
	jFocusEveOnlineLinuxCmd.addFocusListener(new FocusAdapter() {
		@Override
		public void focusGained(FocusEvent e) {
			jFocusEveOnlineLinuxCmd.selectAll();
		}
	});
	jFocusEveOnlineLinuxCmd.setEditable(false);
	jFocusEveOnlineLinuxCmd.setVisible(Platform.isLinux());

	layout.setHorizontalGroup(
		layout.createParallelGroup(GroupLayout.Alignment.LEADING)
			.addComponent(jEnterFilters)
			.addComponent(jHighlightSelectedRow)
			.addComponent(jFocusEveOnline)
			.addGroup(layout.createSequentialGroup()
				.addGap(30)
				.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
					.addComponent(jFocusEveOnlineLinuxHelp)
					.addComponent(jFocusEveOnlineLinuxCmd)
				)
			)
	);
	layout.setVerticalGroup(
		layout.createSequentialGroup()
			.addComponent(jEnterFilters, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			.addComponent(jHighlightSelectedRow, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			.addComponent(jFocusEveOnline, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			.addComponent(jFocusEveOnlineLinuxHelp, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			.addComponent(jFocusEveOnlineLinuxCmd, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
	);
}
 
Example 15
Source Project: txtUML   File: GUI.java    License: Eclipse Public License 1.0 4 votes vote down vote up
protected void changeImage(JLabel to) {
	currentImage.setVisible(false);
	to.setVisible(true);
	currentImage = to;
}
 
Example 16
/**
 * Create the dialog.
 */
public SizeSelectDialog() {
  setBounds(100, 100, 198, 161);
  getContentPane().setLayout(new BorderLayout());
  contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
  getContentPane().add(contentPanel, BorderLayout.CENTER);
  contentPanel.setLayout(new MigLayout("", "[][]", "[][][]"));
  {
    JLabel lblWidth = new JLabel("width");
    contentPanel.add(lblWidth, "cell 0 0,alignx trailing");
  }
  {
    txtWidth = new JTextField();
    txtWidth.setText("400");
    contentPanel.add(txtWidth, "cell 1 0,growx");
    txtWidth.setColumns(10);
  }
  {
    JLabel lblHeight = new JLabel("height");
    contentPanel.add(lblHeight, "cell 0 1,alignx trailing");
  }
  {
    txtHeight = new JTextField();
    txtHeight.setText("300");
    contentPanel.add(txtHeight, "cell 1 1,growx");
    txtHeight.setColumns(10);
  }
  {
    lblWrongInput = new JLabel("wrong input");
    lblWrongInput.setFont(new Font("Tahoma", Font.BOLD, 13));
    lblWrongInput.setForeground(new Color(220, 20, 60));
    lblWrongInput.setVisible(false);
    contentPanel.add(lblWrongInput, "cell 0 2 2 1");
  }
  {
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
    getContentPane().add(buttonPane, BorderLayout.SOUTH);
    {
      JButton okButton = new JButton("OK");
      okButton.addActionListener(e -> checkResultsAndFinish());
      buttonPane.add(okButton);
      getRootPane().setDefaultButton(okButton);
    }
    {
      JButton cancelButton = new JButton("Cancel");
      cancelButton.addActionListener(e -> setVisible(false));
      buttonPane.add(cancelButton);
    }
  }
  setModalityType(ModalityType.APPLICATION_MODAL);
  setVisible(true);
  pack();
}
 
Example 17
private JComponent createProgressComponent() {
    progressLabel = new JLabel(getDisplayName());

    progressBar = super.getProgressComponent();

    stopButton = new JButton(NbBundle.getMessage(WizardStepProgressSupport.class, "BK2022")); // NOI18N
    stopButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            cancel();
        }
    });

    JPanel panel = new JPanel();
    GroupLayout layout = new GroupLayout(panel);

    progressLine = new JPanel();
    progressLine.add(progressBar);
    progressLine.add(Box.createHorizontalStrut(
                            LayoutStyle.getInstance()
                            .getPreferredGap(progressBar,
                                             stopButton,
                                             RELATED,
                                             SwingConstants.EAST,
                                             progressLine)));
    progressLine.add(stopButton);

    progressLine.setLayout(new BoxLayout(progressLine, BoxLayout.X_AXIS));
    progressBar.setAlignmentX(JComponent.CENTER_ALIGNMENT);
    stopButton.setAlignmentX(JComponent.CENTER_ALIGNMENT);

    layout.setHorizontalGroup(
            layout.createParallelGroup(LEADING)
            .addComponent(progressLabel)
            .addComponent(progressLine));
    layout.setVerticalGroup(
            layout.createSequentialGroup()
            .addComponent(progressLabel)
            .addPreferredGap(RELATED)
            .addComponent(progressLine));
    panel.setLayout(layout);

    layout.setHonorsVisibility(false);   //hiding should not affect prefsize

    progressLabel.setVisible(false);
    progressLine.setVisible(false);

    return panel;
}
 
Example 18
public ProgressPanel() {
  super();

  setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
  
  int width = 400;

  progressTotal = new SafeJProgressBar();
  progressTotal.setAlignmentX(CENTER_ALIGNMENT);
  progressTotal.setMaximumSize(
      new Dimension(width, progressTotal.getPreferredSize().height));
  progressTotal.setIndeterminate(true);

  message = new JLabel("");
  message.setIcon(new ProgressIcon(48, 48));
  message.setHorizontalTextPosition(SwingConstants.RIGHT);
  message.setHorizontalAlignment(SwingConstants.CENTER);
  message.setAlignmentX(CENTER_ALIGNMENT);

  dlMsg = new JLabel("Downloading CREOLE Plugin...");
  dlMsg.setIcon(new DownloadIcon(48, 48));
  dlMsg.setHorizontalTextPosition(SwingConstants.RIGHT);
  dlMsg.setHorizontalAlignment(SwingConstants.CENTER);
  dlMsg.setAlignmentX(CENTER_ALIGNMENT);
  dlMsg.setVisible(false);

  partProgress = new JPanel();
  partProgress.setLayout(new BoxLayout(partProgress, BoxLayout.Y_AXIS));

  scroller = new JScrollPane(partProgress);
  scroller.setAlignmentX(CENTER_ALIGNMENT);
  scroller.setMaximumSize(
      new Dimension(width, progressTotal.getPreferredSize().height*6));
  scroller.setPreferredSize(
      new Dimension(width, progressTotal.getPreferredSize().height*6));
  

  add(Box.createVerticalGlue());
  add(message);
  add(Box.createVerticalStrut(5));
  add(progressTotal);
  add(Box.createVerticalStrut(10));
  add(dlMsg);
  add(Box.createVerticalStrut(5));
  add(scroller);

  add(Box.createVerticalGlue());

  addComponentListener(this);
}
 
Example 19
Source Project: Math-Game   File: WorkspacePanel.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * @param fr - The JFrame that this dialog originates from
 * @param answer - The answer to the equation
 * @param equation - The equation to display
 */
public AnswerDialog(JFrame fr, Double answer, String equation) {
	super(fr, true);
	this.answer = answer;
	this.equation = equation;
	
	text = new JTextField(10); // Size 10 font
	text.addActionListener(this);
	
	incorrect = new JLabel("Incorrect");
	
	cancel = new JButton("Cancel");
	cancel.addActionListener(this);
	
	panel = new JPanel();
	panel.add(new JLabel(this.equation));
	panel.add(text);
	panel.add(incorrect);
	panel.add(cancel);
	
	incorrect.setVisible(false);
	
	setContentPane(panel);
	setAutoRequestFocus(true);
	
	/*
	addWindowListener(new WindowAdapter()	{
		public void windowClosing(WindowEvent we)	{
			option.setValue(new Integer(JOptionPane.CLOSED_OPTION));
		}
	});
	*/
	
	addComponentListener(new ComponentAdapter() {
		public void componentShown(ComponentEvent ce) {
			text.requestFocusInWindow();
		}
	});
	
	addWindowStateListener(new WindowStateListener() {
		@Override
		public void windowStateChanged(WindowEvent we) {
			isCorrect = false;
		}
	});
}
 
Example 20
/**
 * Display or hide a status icon.
 *
 * @param ID
 *      The ID value of the status
 * @param visible
 *      Show the icon
 */
void setStatus(final StatusID ID, final boolean visible) {
    final JLabel status = statusIDMap.get(ID);
    if (status.isVisible() != visible) {
        status.setVisible(visible);
    }
}