本文整理汇总了Java中javax.swing.JLabel.setAlignmentX方法的典型用法代码示例。如果您正苦于以下问题:Java JLabel.setAlignmentX方法的具体用法?Java JLabel.setAlignmentX怎么用?Java JLabel.setAlignmentX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JLabel
的用法示例。
在下文中一共展示了JLabel.setAlignmentX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: InitPage
import javax.swing.JLabel; //导入方法依赖的package包/类
public InitPage(Menu crMenu) {
this.crMenu = crMenu;
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
JButton newPetriButton = new JButton("New Petri Net");
JButton newCrButton = new JButton("New CR Graph");
newCrButton.addActionListener(this);
newCrButton.setActionCommand("new_cr");
newCrButton.setAlignmentX(Component.CENTER_ALIGNMENT);
newPetriButton.addActionListener(this);
newPetriButton.setActionCommand("new_petri");
newPetriButton.setAlignmentX(Component.CENTER_ALIGNMENT);
JLabel statusLabel = new JLabel("Please create a new graph");
statusLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
// statusLabel.setLocation(150, 150);
add(statusLabel);
add(newCrButton);
add(newPetriButton);
}
示例2: createImportInProgressPane
import javax.swing.JLabel; //导入方法依赖的package包/类
private JComponent createImportInProgressPane() {
JLabel infoLabel = new JLabel( NbBundle.getMessage( ProgressTrackingPanel.class, "ProgressTrackingPanel.importInProgressMessage" ) );
infoLabel.setAlignmentX(0.5f);
JXBusyLabel busyLabel = new JXBusyLabel( new Dimension(48, 48) );
busyLabel.setAlignmentX(0.5f);
busyLabel.setBusy(true);
JPanel p1 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.PAGE_AXIS));
p1.add(infoLabel);
p1.add(Box.createVerticalStrut(20));
p1.add(busyLabel);
return p1;
}
示例3: ExpandableMessage
import javax.swing.JLabel; //导入方法依赖的package包/类
ExpandableMessage(String topMsgKey,
Collection<String> messages,
String bottomMsgKey,
JButton toggleButton) {
super(null);
this.messages = messages;
this.toggleButton = toggleButton;
lblTopMsg = new JLabel(getMessage(topMsgKey));
lblBotMsg = (bottomMsgKey != null)
? new JLabel(getMessage(bottomMsgKey))
: null;
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
add(lblTopMsg);
lblTopMsg.setAlignmentX(LEFT_ALIGNMENT);
if (lblBotMsg != null) {
add(makeVerticalStrut(lblTopMsg, lblBotMsg));
add(lblBotMsg);
lblBotMsg.setAlignmentX(LEFT_ALIGNMENT);
}
Mnemonics.setLocalizedText(toggleButton,
getMessage("LBL_ShowMoreInformation")); //NOI18N
toggleButton.addActionListener(this);
}
示例4: afficher
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* Affiche les �lements graphiques sur la fen�tre
*/
private void afficher() {
this.panPrinc = new JPanel();
this.panPrinc.setLayout(new BoxLayout(this.panPrinc, BoxLayout.PAGE_AXIS));
//Label identifiant
JLabel labIdentifiant = new JLabel("Identifiant");
labIdentifiant.setFont(new Font("Arial", Font.PLAIN, 20));
labIdentifiant.setAlignmentX(Component.CENTER_ALIGNMENT);
//Label mot de passe
JLabel labMdp = new JLabel("Mot de passe");
labMdp.setFont(new Font("Arial", Font.PLAIN, 20));
labMdp.setAlignmentX(Component.CENTER_ALIGNMENT);
//Champ de l'identifiant
this.fieldName = new JTextField();
this.fieldName.setPreferredSize(new Dimension(150,25));
this.fieldName.setAlignmentX(Component.CENTER_ALIGNMENT);
//Champ du mot de passe
this.fieldPassword = new JPasswordField();
this.fieldPassword.setEchoChar('*');
this.fieldPassword.setPreferredSize(new Dimension(150,25));
this.fieldPassword.setAlignmentX(Component.CENTER_ALIGNMENT);
//Bouton connecter
butConnecter = new JButton();
butConnecter.setAlignmentX(Component.CENTER_ALIGNMENT);
this.panPrinc.add(Box.createVerticalStrut(180));
this.panPrinc.add(labIdentifiant);
this.panPrinc.add(this.fieldName);
this.panPrinc.add(Box.createVerticalStrut(10));
this.panPrinc.add(labMdp);
this.panPrinc.add(this.fieldPassword);
this.panPrinc.add(Box.createVerticalStrut(40));
this.panPrinc.add(butConnecter);
}
示例5: AboutWindow
import javax.swing.JLabel; //导入方法依赖的package包/类
public AboutWindow(Window w, BufferedImage img, String text) {
super(w);
getContentPane().setBackground(Color.black);
setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
final JLabel l1 = new JLabel(new ImageIcon(img));
l1.setAlignmentX(0.5F);
add(l1);
final JLabel l2 = new JLabel(text);
l2.setBackground(Color.blue);
l2.setForeground(Color.white);
l2.setHorizontalAlignment(JLabel.CENTER);
l2.setAlignmentX(0.5F);
add(l2);
pack();
final Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
setLocation(d.width / 2 - getWidth() / 2,
d.height / 2 -getHeight() / 2);
addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent evt) {
setVisible(false);
dispose();
}
});
}
示例6: DragFileHandle
import javax.swing.JLabel; //导入方法依赖的package包/类
private void DragFileHandle(final JPanel myPanel) {
new FileDrop(myPanel, new FileDrop.Listener() {
public void filesDropped(java.io.File[] files) {
for (int i = 0; i < files.length; i++) {
Icon ico = FileSystemView.getFileSystemView().getSystemIcon(files[i]);
FindFiles(myPanel.getName(), files[i]);
Image image = ((ImageIcon) ico).getImage();
ImageIcon icon = new ImageIcon(getScaledImage(image, 45, 45));
myPanel.removeAll();
myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.Y_AXIS));
JLabel label = new JLabel();
label.setIcon(icon);
label.setAlignmentX(CENTER_ALIGNMENT);
myPanel.add(Box.createRigidArea(new Dimension(0, 60)));
myPanel.add(label, BorderLayout.CENTER);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
JLabel labe2 = new JLabel(files[i].getName(), SwingConstants.CENTER);
labe2.setBackground(new Color(240, 240, 240));
labe2.setForeground(new Color(0, 0, 0));
labe2.setFont(new Font("Segoe UI Light", Font.PLAIN, 14));
labe2.setAlignmentX(CENTER_ALIGNMENT);
myPanel.add(labe2, BorderLayout.LINE_START);
}
}
});
}
示例7: getAnimationPanel
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* Returns the frames-per-second slider for the animation dialog.
*/
final JPanel getAnimationPanel() {
// lazily create the label
if (this.animationPanel == null) {
JLabel label = new JLabel("Animation Speed");
label.setAlignmentX(Component.CENTER_ALIGNMENT);
final JSlider slider = new JSlider(SwingConstants.HORIZONTAL, 1, 10, 2) {
@Override
public void updateUI() {
setUI(BasicSliderUI.createUI(this));
}
};
slider.setMajorTickSpacing(9);
slider.setMinorTickSpacing(1);
slider.setSnapToTicks(true);
slider.setPaintTicks(true);
slider.setPaintLabels(true);
slider.setFocusable(false);
slider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int speed = slider.getValue();
setSpeed(speed);
}
});
slider.setAlignmentX(Component.CENTER_ALIGNMENT);
this.animationPanel = new JPanel();
this.animationPanel.setLayout(new BoxLayout(this.animationPanel, BoxLayout.Y_AXIS));
this.animationPanel.add(label);
this.animationPanel.add(slider);
}
return this.animationPanel;
}
示例8: SourceControl
import javax.swing.JLabel; //导入方法依赖的package包/类
/** Add a source controller that changes the packet source streams upon selection */
public SourceControl(final ArrayList<PacketStream> sources, final ProcessingNetwork.Node f, final String name, final int sourceIndex) {
super();
filter = f;
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
setAlignmentX(LEFT_ALIGNMENT);
final JLabel label = new JLabel(name);
label.setAlignmentX(LEFT_ALIGNMENT);
label.setFont(label.getFont().deriveFont(fontSize));
// addTip(f, label);
add(label);
String[] names=new String[sources.size()];
for (int i=0; i<sources.size();i++)
names[i]=sources.get(i).getName();
control = new JComboBox(names);
control.setFont(control.getFont().deriveFont(fontSize));
// control.setHorizontalAlignment(SwingConstants.LEADING);
control.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
try {
node.setSource(sourceIndex, sources.get(control.getSelectedIndex()));
} catch (Exception ex) {
node.setEnabled(false);
Logger.getLogger(MultiInputPanel.class.getName()).log(Level.SEVERE, "Source index higher than number of sources", ex);
}
}
});
add(label);
add(control);
}
示例9: EnumControl
import javax.swing.JLabel; //导入方法依赖的package包/类
public EnumControl(final Class<? extends Enum> c, final Object f, PropertyDescriptor p) {
super();
final String name = p.getName();
final Method r = p.getReadMethod(), w = p.getWriteMethod();
setterMap.put(name, this);
clazz = f;
write = w;
read = r;
setLayout(new GridLayout(1, 0));
// setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
setAlignmentX(ALIGNMENT);
final JLabel label = new JLabel(name);
label.setAlignmentX(ALIGNMENT);
label.setFont(label.getFont().deriveFont(fontSize));
addTip(p, label);
add(label);
control = new JComboBox(c.getEnumConstants());
control.setFont(control.getFont().deriveFont(fontSize));
// control.setHorizontalAlignment(SwingConstants.LEADING);
add(label);
add(control);
refresh();
control.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
w.invoke(clazz, control.getSelectedItem());
} catch (Exception e2) {
e2.printStackTrace();
}
}
});
}
示例10: StringControl
import javax.swing.JLabel; //导入方法依赖的package包/类
public StringControl(final Object f, PropertyDescriptor p) {
super();
final String name = p.getName();
final Method r = p.getReadMethod(), w = p.getWriteMethod();
setterMap.put(name, this);
clazz = f;
write = w;
read = r;
setLayout(new GridLayout(1, 0));
// setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
setAlignmentX(ALIGNMENT);
final JLabel label = new JLabel(name);
label.setAlignmentX(ALIGNMENT);
label.setFont(label.getFont().deriveFont(fontSize));
addTip(p, label);
add(label);
textField = new JTextField(name);
textField.setFont(textField.getFont().deriveFont(fontSize));
textField.setHorizontalAlignment(SwingConstants.LEADING);
textField.setColumns(10);
add(label);
add(textField);
refresh();
textField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
w.invoke(clazz, textField.getText());
} catch (Exception e2) {
e2.printStackTrace();
}
}
});
}
示例11: BoardSlot
import javax.swing.JLabel; //导入方法依赖的package包/类
public BoardSlot(BoardPicker bp, String prompt) {
this.prompt = prompt;
picker = bp;
boards = new JComboBox();
boards.addItem(prompt);
final String lbn[] = picker.getAllowableLocalizedBoardNames();
for (String s : lbn) {
boards.addItem(s);
}
boards.setSelectedIndex(lbn.length == 1 ? 1 : 0);
boards.addActionListener(this);
reverseCheckBox =
new JCheckBox(Resources.getString("BoardPicker.flip")); //$NON-NLS-1$
reverseCheckBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (getBoard() != null) {
getBoard().setReversed(reverseCheckBox.isSelected());
picker.repaint();
}
}
});
reverseCheckBox.setVisible(false);
setLayout(new OverlayLayout(this));
final JPanel p = new JPanel();
final Box b = Box.createHorizontalBox();
b.add(boards);
b.add(reverseCheckBox);
p.add(b);
p.setOpaque(false);
p.setAlignmentX(0.5F);
final JLabel l = new JLabel(this);
l.setAlignmentX(0.5F);
add(p);
add(l);
actionPerformed(null);
}
示例12: getNameControls
import javax.swing.JLabel; //导入方法依赖的package包/类
protected JComponent getNameControls(final WizardController controller, final Map settings) {
if (nameControls == null) {
Box box = Box.createVerticalBox();
box.add(Box.createVerticalGlue());
controller.setProblem(Resources.getString("WizardSupport.EnterNameAndPassword")); //$NON-NLS-1$
final StringConfigurer nameConfig = new StringConfigurer(null, Resources.getString("WizardSupport.RealName")); //$NON-NLS-1$
final StringConfigurer pwd = new PasswordConfigurer(null, Resources.getString("WizardSupport.Password")); //$NON-NLS-1$
final StringConfigurer pwd2 = new PasswordConfigurer(null, Resources.getString("WizardSupport.ConfirmPassword")); //$NON-NLS-1$
PropertyChangeListener pl = new PropertyChangeListener() {
@SuppressWarnings("unchecked")
public void propertyChange(PropertyChangeEvent evt) {
settings.put(GameModule.REAL_NAME, nameConfig.getValue());
settings.put(GameModule.SECRET_NAME, pwd.getValue());
if (nameConfig.getValue() == null || "".equals(nameConfig.getValue())) { //$NON-NLS-1$
controller.setProblem(Resources.getString("WizardSupport.EnterYourName")); //$NON-NLS-1$
}
else if (pwd.getValue() == null || "".equals(pwd.getValue())) { //$NON-NLS-1$
controller.setProblem(Resources.getString("WizardSupport.EnterYourPassword")); //$NON-NLS-1$
}
else if (!pwd.getValue().equals(pwd2.getValue())) {
controller.setProblem(Resources.getString("WizardSupport.PasswordsDontMatch")); //$NON-NLS-1$
}
else {
final Prefs p = GameModule.getGameModule().getPrefs();
p.getOption(GameModule.REAL_NAME)
.setValue(nameConfig.getValueString());
p.getOption(GameModule.SECRET_NAME)
.setValue(pwd.getValueString());
try {
p.save();
controller.setProblem(null);
}
// FIXME: review error message
catch (IOException e) {
String msg = e.getMessage();
if (msg == null) {
msg = Resources.getString("Prefs.unable_to_save");
}
controller.setProblem(msg);
}
}
}
};
nameConfig.addPropertyChangeListener(pl);
pwd.addPropertyChangeListener(pl);
pwd2.addPropertyChangeListener(pl);
box.add(nameConfig.getControls());
box.add(pwd.getControls());
box.add(pwd2.getControls());
JLabel l = new JLabel(Resources.getString("WizardSupport.NameAndPasswordDetails"));
l.setAlignmentX(Box.CENTER_ALIGNMENT);
box.add(l);
box.add(Box.createVerticalGlue());
nameControls = box;
}
return nameControls;
}
示例13: createAnimationControls
import javax.swing.JLabel; //导入方法依赖的package包/类
private void createAnimationControls() {
Font sliderFont = new Font("Arial", Font.PLAIN, 12);
animationControls = new JPanel();
animationControls.setLayout(new BoxLayout(animationControls,
BoxLayout.PAGE_AXIS));
JLabel manualLabel = new JLabel("Frame #");
manualLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
manualSlider = new JSlider(JSlider.HORIZONTAL);
manualSlider.setPaintTicks(true);
manualSlider.setPaintLabels(true);
manualSlider.setFont(sliderFont);
manualSlider.addChangeListener(manualSliderListener);
manualSlider.addMouseListener(manualSliderClickListener);
manualSlider.setMinorTickSpacing(1);
manualSlider.addComponentListener(resizeListener);
JLabel framerateLabel = new JLabel("Framerate");
framerateLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
framerateSlider = new JSlider(JSlider.HORIZONTAL, FRAMERATE_MIN,
FRAMERATE_MAX, FRAMERATE_INIT);
framerateSlider.setMajorTickSpacing(10);
framerateSlider.setMinorTickSpacing(1);
framerateSlider.setPaintTicks(true);
framerateSlider.setPaintLabels(true);
framerateSlider.setLabelTable(framerateSlider.createStandardLabels(10,
10));
framerateSlider.setFont(sliderFont);
framerateSlider.addChangeListener(framerateListener);
JPanel frameratePanel = new JPanel();
frameratePanel.setLayout(new BoxLayout(frameratePanel,
BoxLayout.PAGE_AXIS));
frameratePanel.add(framerateLabel);
frameratePanel.add(Box.createRigidArea(new Dimension(0, 2)));
frameratePanel.add(framerateSlider);
playPauseButton = new JButton(playIcon);
playPauseButton.addActionListener(playPauseListener);
stopButton = new JButton(stopIcon);
stopButton.addActionListener(stopListener);
animationControls.add(new JSeparator(JSeparator.HORIZONTAL));
animationControls.add(Box.createRigidArea(new Dimension(0, 2)));
animationControls.add(manualLabel);
animationControls.add(Box.createRigidArea(new Dimension(0, 2)));
animationControls.add(manualSlider);
animationControls.add(Box.createRigidArea(new Dimension(0, 5)));
JPanel p2 = new JPanel();
p2.setLayout(new BoxLayout(p2, BoxLayout.LINE_AXIS));
p2.add(playPauseButton);
p2.add(Box.createRigidArea(new Dimension(10, 0)));
p2.add(stopButton);
p2.add(frameratePanel);
animationControls.add(p2);
animationControls.setVisible(false);
animationControls.setBorder(BorderFactory.createEmptyBorder(0, 10, 5,
10));
container.add(animationControls, BorderLayout.SOUTH);
}
示例14: ProgressPanel
import javax.swing.JLabel; //导入方法依赖的package包/类
public ProgressPanel() {
super();
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
progressTotal = new SafeJProgressBar();
progressTotal.setAlignmentX(CENTER_ALIGNMENT);
progressTotal.setMaximumSize(new Dimension(250, progressTotal
.getPreferredSize().height));
progressTotal.setIndeterminate(true);
progressSingle = new SafeJProgressBar();
progressSingle.setAlignmentX(CENTER_ALIGNMENT);
progressSingle.setMaximumSize(new Dimension(250, progressTotal
.getPreferredSize().height));
progressSingle.setIndeterminate(true);
progressSingle.setVisible(false);
progressSingle.setMinimum(0);
progressSingle.setMaximum(100);
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);
add(Box.createVerticalGlue());
add(message);
add(Box.createVerticalStrut(5));
add(progressTotal);
add(Box.createVerticalStrut(10));
add(dlMsg);
add(Box.createVerticalStrut(5));
add(progressSingle);
add(Box.createVerticalGlue());
addComponentListener(this);
}
示例15: BooleanControl
import javax.swing.JLabel; //导入方法依赖的package包/类
public BooleanControl(final Object f, PropertyDescriptor p) {
super();
final String name = p.getName();
final Method r = p.getReadMethod(), w = p.getWriteMethod();
setterMap.put(name, this);
clazz = f;
write = w;
read = r;
setLayout(new GridLayout(1, 0));
// setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
setAlignmentX(ALIGNMENT);
// setLayout(new FlowLayout(FlowLayout.LEADING));
JLabel label=new JLabel(name);
label.setAlignmentX(ALIGNMENT);
label.setHorizontalTextPosition(SwingConstants.LEFT);
label.setFont(label.getFont().deriveFont(fontSize));
add(label);
addTip(p,label);
checkBox = new JCheckBox();
refresh();
checkBox.setAlignmentX(ALIGNMENT);
checkBox.setHorizontalAlignment(SwingConstants.LEFT);
checkBox.setHorizontalTextPosition(SwingConstants.LEFT);
// checkBox.setBorder(new EmptyBorder(0,0,0,0));
// Border border=checkBox.getBorder();
// Insets insets=border.getBorderInsets(this);
// insets.left=0;
addTip(p, checkBox);
add(checkBox);
checkBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
w.invoke(clazz, checkBox.isSelected());
} catch (InvocationTargetException ite) {
ite.printStackTrace();
} catch (Exception iae) {
iae.printStackTrace();
}
}
});
}