Java Code Examples for javax.swing.SwingConstants#LEADING

The following examples show how to use javax.swing.SwingConstants#LEADING . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Thunder   File: ConfigPane.java    License: Apache License 2.0 6 votes vote down vote up
public ConfigPane(String labelText, String hintText) {
    label = new JBasicLabel(labelText);
    textField = new JBasicTextField();
    saveButton = new JClassicButton(createSaveAction());
    hintLabel = new JBasicLabel(hintText, ConsoleIconFactory.getSwingIcon("question_message.png"), SwingConstants.LEADING);

    double[][] size = {
            { 100, TableLayout.FILL, TableLayout.PREFERRED },
            { TableLayout.PREFERRED, TableLayout.PREFERRED }
    };

    TableLayout tableLayout = new TableLayout(size);
    tableLayout.setHGap(0);
    tableLayout.setVGap(5);

    setLayout(tableLayout);
    add(label, "0, 0");
    add(textField, "1, 0");
    add(saveButton, "2, 0");
    add(hintLabel, "1, 1, 2, 1");
}
 
Example 2
Source Project: netbeans   File: ProfilerTable.java    License: Apache License 2.0 5 votes vote down vote up
static boolean isLeadingAlign(Component component) {
    int alignment;
    
    if (component instanceof ProfilerRenderer) {
        alignment = ((ProfilerRenderer)component).getHorizontalAlignment();
    } else if (component instanceof JLabel) {
        alignment = ((JLabel)component).getHorizontalAlignment();
    } else {
        alignment = SwingConstants.LEADING;
    }
    
    return alignment == SwingConstants.LEADING ||
           alignment == SwingConstants.LEFT ||
           alignment == SwingConstants.CENTER;
}
 
Example 3
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    ServerResourceDescriptor srd = resources.get(rowIndex);
    if (columnIndex == 0) {
        return srd.getType();
    } else {
        return new JLabel(srd.getName(), srd.getIcon(), SwingConstants.LEADING);
    }
}
 
Example 4
static boolean isLeadingAlign(Component component) {
    int alignment;
    
    if (component instanceof ProfilerRenderer) {
        alignment = ((ProfilerRenderer)component).getHorizontalAlignment();
    } else if (component instanceof JLabel) {
        alignment = ((JLabel)component).getHorizontalAlignment();
    } else {
        alignment = SwingConstants.LEADING;
    }
    
    return alignment == SwingConstants.LEADING ||
           alignment == SwingConstants.LEFT ||
           alignment == SwingConstants.CENTER;
}
 
Example 5
Source Project: raccoon4   File: InfoBuilder.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected JPanel assemble() {
	JPanel ret = new JPanel();
	ret.setLayout(new BoxLayout(ret, BoxLayout.Y_AXIS));

	content = new HyperTextPane("-").withTransparency();
	HTMLEditorKit kit = new HTMLEditorKit();
	content.setEditorKit(kit);
	StyleSheet styleSheet = kit.getStyleSheet();
	styleSheet.addRule("body {color:#292929; font-family:Helvetica, Arial, sans-serif; margin: 4px;}");
	
	if (listener != null) {
		content.addHyperlinkListener(listener);
	}
	JPanel wrapper = new JPanel(false);
	wrapper.setLayout(new GridLayout(1, 0, 0, 0));
	JLabel lbl = new JLabel(title, new ImageIcon(getClass().getResource(
			"/icons/famfam/icons/bell.png")), SwingConstants.LEADING);
	if (color != null) {
		lbl.setForeground(color);
	}
	wrapper.add(lbl);
	wrapper.setBackground(wrapper.getBackground().darker());
	wrapper.setBorder(BorderFactory.createEtchedBorder());

	ret.add(wrapper);
	ret.add(content);
	return ret;
}
 
Example 6
Source Project: RipplePower   File: LayoutStyle.java    License: Apache License 2.0 5 votes vote down vote up
private boolean isLeftAligned(AbstractButton button, int position) {
	if (position == SwingConstants.WEST) {
		boolean ltr = button.getComponentOrientation().isLeftToRight();
		int hAlign = button.getHorizontalAlignment();
		return ((ltr && (hAlign == SwingConstants.LEFT || hAlign == SwingConstants.LEADING))
				|| (!ltr && (hAlign == SwingConstants.TRAILING)));
	}
	return false;
}
 
Example 7
Source Project: RipplePower   File: LayoutStyle.java    License: Apache License 2.0 5 votes vote down vote up
private boolean isRightAligned(AbstractButton button, int position) {
	if (position == SwingConstants.EAST) {
		boolean ltr = button.getComponentOrientation().isLeftToRight();
		int hAlign = button.getHorizontalAlignment();
		return ((ltr && (hAlign == SwingConstants.RIGHT || hAlign == SwingConstants.TRAILING))
				|| (!ltr && (hAlign == SwingConstants.LEADING)));
	}
	return false;
}
 
Example 8
Source Project: chipster   File: SimpleInternalFrame.java    License: MIT License 5 votes vote down vote up
/**
 * Constructs a SimpleInternalFrame with the specified 
 * icon, title, tool bar, and content panel.
 * 
 * @param icon        the initial icon
 * @param title       the initial title
 * @param bar         the initial tool bar
 * @param content     the initial content pane
 */
public SimpleInternalFrame(
    Icon icon,
    String title,
    JToolBar bar,
    JComponent content) {
    super(new BorderLayout());
    this.selected = false;
    this.titleLabel = new JLabel(title, icon, SwingConstants.LEADING);        
    titleLabel.setFont(getTittleFont());        
    
    // Minimizing by double clicking
    this.addMouseListener(this);
    
    this.paintGradient = true;
    this.paintTitleBorder = false;
    
    JPanel top = buildHeader(titleLabel, bar);

    add(top, BorderLayout.NORTH);
    if (content != null) {
        setContent(content);
    }
    setBorder(new ShadowBorder());
    setSelected(true);
    updateHeader();
}
 
Example 9
Source Project: pdfxtk   File: StyleEditor.java    License: Apache License 2.0 5 votes vote down vote up
static boolean validHorizontalKey(int key) {
  return ((key == SwingConstants.LEFT)    ||
   (key == SwingConstants.CENTER)  ||
   (key == SwingConstants.RIGHT)   ||
   (key == SwingConstants.LEADING) ||
   (key == SwingConstants.TRAILING));
}
 
Example 10
public ImprovedFileChooser(File currentDirectory, FileSystemView fsv) {
  super(currentDirectory, fsv);

  AbstractButton detailsViewButton = getDetailsViewButton(this);
  if (detailsViewButton == null) {
    // mac osx does not have a details button. It is recommended to use
    // a java.awt.FileDialog box on MacOSX for the proper look and feel.
    // so, don't warn if on a mac.
    // https://developer.apple.com/library/mac/documentation/Java/Conceptual/Java14Development/07-NativePlatformIntegration/NativePlatformIntegration.html
    if (!isMacOs) {
      logger.warn("Couldn't find Details button!");
    }
    return;
  }

  detailsViewButton.doClick(); // Programmatically switch to the Details View.

  List<JTable> tables = SwingUtils.getDescendantsOfType(JTable.class, this);
  JTable detailsTable;

  if (tables.size() != 1) {
    logger.warn("Expected to find 1 JTable in the file chooser, but found " + tables.size());
    return;
  } else if ((detailsTable = tables.get(0)) == null) {
    logger.warn("The details view table was null!");
    return;
  }

  // Set the preferred column widths so that they're big enough to display all data without truncation.
  ColumnWidthsResizer resizer = new ColumnWidthsResizer(detailsTable);
  detailsTable.getModel().addTableModelListener(resizer);
  detailsTable.getColumnModel().addColumnModelListener(resizer);

  // Left-align every cell, including header cells.
  TableAligner aligner = new TableAligner(detailsTable, SwingConstants.LEADING);
  detailsTable.getColumnModel().addColumnModelListener(aligner);

  // Every time the directory is changed in a JFileChooser dialog, a new TableColumnModel is created.
  // This is bad, because it discards the alignment decorators that we installed on the old model.
  // So, we 're going to listen for the creation of new TableColumnModels so that we can reinstall the decorators.
  detailsTable.addPropertyChangeListener(new NewColumnModelListener(detailsTable, SwingConstants.LEADING));

  // It's quite likely that the total width of the table is NOT EQUAL to the sum of the preferred column widths
  // that our TableModelListener calculated. In that case, resize all of the columns an equal percentage.
  // This will ensure that the relative ratios of the *actual* widths match those of the *preferred* widths.
  detailsTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
}
 
Example 11
/**
 * Updates the parameter panel for the selected {@link Configurable}.
 */
private void updateParameterPanel(Configurable config) {
	parameterPanel.removeAll();

	// save previously edited parameters
	updateModel();
	if (config != null) {
		try {
			// stripped text depending on the size of the panel
			String text = SwingTools.getStrippedJComponentText(outerPanel, config.getName(), outerPanel.getWidth() - 100,
					0);
			nameLabel.setText("<html><b>" + text + "</b></html>");

			// Get parameters based on Configurator implementation
			Parameters parameters = ConfigurationManager.getInstance().getAbstractConfigurator(config.getTypeId())
					.getParameterHandler(config).getParameters();

			// fill in real values of configurable
			for (String key : config.getParameters().keySet()) {
				parameters.setParameter(key, config.getParameters().get(key));
			}
			// init param panel with real values
			configParamPanel = new ConfiguratorParameterPanel(this, parameters);

			parameterLayer = new JLayer<JPanel>(configParamPanel);
			parameterLayer.setGlassPane(simpleGlassPane);
			simpleGlassPane.setVisible(false);

			// add it to wrapper panel
			parameterPanel.add(parameterLayer, BorderLayout.CENTER);

			boolean editingAllowed = true;
			boolean editingPossible = true;

			if (config.getSource() != null) {
				if (config.getSource().isConnected()) {
					if (!remoteControllers.get(config.getSource().getName()).getModel().hasAdminRights()) {
						editingAllowed = false;
					}
					// only interesting if we want to edit remote connections
					editingPossible = remoteControllers.get(config.getSource().getName()).getModel().isEditingPossible();
				}
			}

			if (!editingPossible) {

				SwingTools.setEnabledRecursive(configParamPanel, false);
				simpleGlassPane.setVisible(true);

			} else {
				if (!editingAllowed) {

					SwingTools.setEnabledRecursive(configParamPanel, false);
					simpleGlassPane.setVisible(true);
					renameButton.setVisible(false);
					removeButton.setVisible(false);
					actionPanel.setVisible(false);

				} else {

					if (!configParamPanel.isEnabled()) {
						SwingTools.setEnabledRecursive(configParamPanel, true);
					}

					if (simpleGlassPane.isVisible()) {
						simpleGlassPane.setVisible(false);
					}

					// make editing components visible
					renameButton.setVisible(true);
					removeButton.setVisible(true);
					actionPanel.setVisible(true);
				}
			}
		} catch (Exception e) {
			LogService.getRoot().log(Level.WARNING,
					"com.rapidminer.tools.config.gui.ConfigurableDialog.error_setting_parameters", e);

			// display error in GUI
			parameterPanel.removeAll();

			JLabel errorLabel = new JLabel(
					I18N.getGUIMessage(I18N
							.getGUIMessage("gui.dialog.configurable_dialog.error.display_stored_configurable.label")),
					FAILURE_ICON, SwingConstants.LEADING);
			errorLabel.setHorizontalAlignment(SwingConstants.CENTER);
			parameterPanel.add(errorLabel, BorderLayout.CENTER);
		}
	}
	updateButtonState(true);
	parameterPanel.revalidate();
	parameterPanel.repaint();
}
 
Example 12
public static void addSeparator(Container container, String text) {
	JLabel l = new JLabel(text, SwingConstants.LEADING);

	container.add(l, "gapbottom 1, span, split 2, aligny center");
	container.add(new JSeparator(), "gapleft rel, growx");
}