当前位置: 首页>>代码示例>>Java>>正文


Java JTextField.setHorizontalAlignment方法代码示例

本文整理汇总了Java中javax.swing.JTextField.setHorizontalAlignment方法的典型用法代码示例。如果您正苦于以下问题:Java JTextField.setHorizontalAlignment方法的具体用法?Java JTextField.setHorizontalAlignment怎么用?Java JTextField.setHorizontalAlignment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTextField的用法示例。


在下文中一共展示了JTextField.setHorizontalAlignment方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dataPanel

import javax.swing.JTextField; //导入方法依赖的package包/类
protected Component dataPanel() {
	JPanel panel = new JPanel(new GridLayout(1, 2, 0, 8));
	panel.setBorder(BorderFactory.createEmptyBorder(20, 5, 20, 30));

	JLabel label = new JLabel("Record tittle:");
	label.setFont(new Font("Arial", Font.BOLD, 20));
	label.setHorizontalAlignment(JTextField.CENTER);

	textField = new JTextField();
	textField.setFont(new Font("Arial", Font.BOLD, 20));
	textField.setHorizontalAlignment(JTextField.RIGHT);
	textField.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			accept.requestFocusInWindow();
		}
	});

	panel.add(label);
	panel.add(textField);

	return panel;
}
 
开发者ID:AitorB,项目名称:POPBL_V,代码行数:24,代码来源:RecordDialog.java

示例2: JTextFieldDemo1

import javax.swing.JTextField; //导入方法依赖的package包/类
public static void JTextFieldDemo1() {

		jf = new JFrame("TextField����");

		final Container contentPane = jf.getContentPane();
		contentPane.setLayout(new BorderLayout());

		jp = new JPanel();

		jtf1 = new JTextField();
		jtf2 = new JTextField(10);
		jtf3 = new JTextField("ָ���ı�����");
		jtf4 = new JTextField("ָ������+ָ������(ֻ��״̬)", 30);

		jtf3.setEnabled(false); // true���Ա༭
		jtf4.setFont(new Font("����", Font.BOLD | Font.ITALIC, 16)); // ���壬�Ƿ�Ӵ֡�б�壬�ֺ�
		// �����ı���ˮƽ���뷽ʽ
		jtf4.setHorizontalAlignment(SwingConstants.CENTER);

		jp.add(jtf1);
		jp.add(jtf2);
		jp.add(jtf3);
		jp.add(jtf4);

		contentPane.add(jp);

		jf.pack();
		jf.setLocation(400, 200);
		jf.setVisible(true);
		jf.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});
	}
 
开发者ID:zylo117,项目名称:SpotSpotter,代码行数:37,代码来源:TextField.java

示例3: StringControl

import javax.swing.JTextField; //导入方法依赖的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();
                    }
                }
            });
        }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:38,代码来源:ParameterControlPanel.java

示例4: init

import javax.swing.JTextField; //导入方法依赖的package包/类
private void init() {
        textField = new JTextField("");
        textField.setFont(new java.awt.Font("",0,15));
        textField.setHorizontalAlignment(JTextField.CENTER);
        gbLayout = new GridBagLayout();
        gbConst = new GridBagConstraints();    
        panel = new JPanel();  
//        panel.setBorder(new javax.swing.border.TitledBorder("JPST")); //JPanel of Slider and TextField
        setLabel("");
        panel.setLayout(gbLayout);
        column = 5;
        slider = new DecimalSlider();
        slider.setSize(200,40);
        slider.setPaintTicks(true);
        slider.setPaintLabels(true);
        slider.setDecimalSliderValue(300);
        setMinimum(0);
        setMaximum(500);
        slider.addChangeListener(new SliderListener());
        slider.setDecimalSliderMajorTickSpacing(100);
        slider.setDecimalSliderMinorTickSpacing(50);

        gbConst.gridx = 0; gbConst.gridy = 0;
        gbLayout.setConstraints(slider, gbConst);
        panel.add(slider);

        showSlider = true;
        setShowValues(false); // default is false to show values of slider
        setEditValues(false); // default is false to edit values of slider thru textField
    }
 
开发者ID:etomica,项目名称:etomica,代码行数:31,代码来源:DeviceSlider.java

示例5: Gestiones

import javax.swing.JTextField; //导入方法依赖的package包/类
/**
 * Create the frame.
 **/
public Gestiones() {
	setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	setBounds(100, 100, 403, 359);
	setLocationRelativeTo(null);
	contentPane = new JPanel();
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);
	
	btnPrimero = new JButton("<<");
	btnPrimero.setBounds(14, 215, 54, 23);
	contentPane.add(btnPrimero);
	btnPrimero.addActionListener(this);
	
	btnAnterior = new JButton("<");
	btnAnterior.setBounds(82, 215, 54, 23);
	contentPane.add(btnAnterior);
	btnAnterior.addActionListener(this);
	
	btnSiguiente = new JButton(">");
	btnSiguiente.setBounds(250, 215, 54, 23);
	contentPane.add(btnSiguiente);
	btnSiguiente.addActionListener(this);
	
	btnUltimo = new JButton(">>");
	btnUltimo.setBounds(318, 215, 54, 23);
	contentPane.add(btnUltimo);
	btnUltimo.addActionListener(this);
	
	txtEstado = new JTextField();
	txtEstado.setHorizontalAlignment(SwingConstants.CENTER);
	txtEstado.setEditable(false);
	txtEstado.setBounds(150, 216, 86, 20);
	contentPane.add(txtEstado);
	txtEstado.setColumns(10);
	
	btnModificar = new JButton("Modificar");
	btnModificar.setBounds(30, 273, 89, 23);
	contentPane.add(btnModificar);
	btnModificar.addActionListener(this);
	
	btnNuevo = new JButton("Nuevo");
	btnNuevo.setBounds(149, 273, 89, 23);
	contentPane.add(btnNuevo);
	btnNuevo.addActionListener(this);
	
	btnEliminar = new JButton("Eliminar");
	btnEliminar.setBounds(268, 273, 89, 23);
	contentPane.add(btnEliminar);
	btnEliminar.addActionListener(this);
	
	setVisible(true);
	addWindowListener(this);
}
 
开发者ID:JuandeLS3,项目名称:Library-app,代码行数:58,代码来源:Gestiones.java

示例6: GestionRevistas

import javax.swing.JTextField; //导入方法依赖的package包/类
public GestionRevistas(Connection conn,JFrame principal) {
	super();
	this.conn=conn;		// Recibimos la conexi�n de Biblioteca
	this.principal=principal;
	this.principal.setEnabled(false);
	this.principal.setVisible(false);
	setTitle("Gesti�n de revistas");
	
	txtCodigo = new JTextField();
	txtCodigo.setEditable(false);
	txtCodigo.setHorizontalAlignment(SwingConstants.CENTER);
	txtCodigo.setBounds(58, 67, 106, 20);
	getContentPane().add(txtCodigo);
	txtCodigo.setColumns(10);
	
	txtSignatura = new JTextField();
	txtSignatura.setEditable(false);
	txtSignatura.setHorizontalAlignment(SwingConstants.CENTER);
	txtSignatura.setBounds(222, 67, 106, 20);
	getContentPane().add(txtSignatura);
	txtSignatura.setColumns(10);
	
	txtNombre = new JTextField();
	txtNombre.setEditable(false);
	txtNombre.setHorizontalAlignment(SwingConstants.CENTER);
	txtNombre.setBounds(58, 136, 106, 20);
	getContentPane().add(txtNombre);
	txtNombre.setColumns(10);
	
	txtMateria = new JTextField();
	txtMateria.setEditable(false);
	txtMateria.setHorizontalAlignment(SwingConstants.CENTER);
	txtMateria.setBounds(222, 136, 106, 20);
	getContentPane().add(txtMateria);
	txtMateria.setColumns(10);
	
	lblCodigo = new JLabel("Codigo");
	lblCodigo.setHorizontalAlignment(SwingConstants.CENTER);
	lblCodigo.setBounds(81, 42, 60, 14);
	getContentPane().add(lblCodigo);
	
	lblNombre = new JLabel("Nombre");
	lblNombre.setHorizontalAlignment(SwingConstants.CENTER);
	lblNombre.setBounds(245, 42, 60, 14);
	getContentPane().add(lblNombre);
	
	lblSignatura = new JLabel("Signatura");
	lblSignatura.setHorizontalAlignment(SwingConstants.CENTER);
	lblSignatura.setBounds(81, 111, 60, 14);
	getContentPane().add(lblSignatura);
	
	lblMateria = new JLabel("Materia");
	lblMateria.setHorizontalAlignment(SwingConstants.CENTER);
	lblMateria.setBounds(245, 111, 60, 14);
	getContentPane().add(lblMateria);
	
	lblGestinDeRevistas = new JLabel("Gesti\u00F3n de revistas");
	lblGestinDeRevistas.setForeground(Color.BLUE);
	lblGestinDeRevistas.setHorizontalAlignment(SwingConstants.CENTER);
	lblGestinDeRevistas.setBounds(142, 11, 114, 14);
	getContentPane().add(lblGestinDeRevistas);
	

}
 
开发者ID:JuandeLS3,项目名称:Library-app,代码行数:65,代码来源:GestionRevistas.java

示例7: GestionUsuarios

import javax.swing.JTextField; //导入方法依赖的package包/类
public GestionUsuarios(Connection conn,JFrame principal) {
	super();
	this.conn=conn;		// Recibimos la conexi�n de Biblioteca
	this.principal=principal;
	this.principal.setEnabled(false);
	this.principal.setVisible(false);
	setTitle("Gesti�n de usuarios");
	
	txtApellido1 = new JTextField();
	txtApellido1.setEditable(false);
	txtApellido1.setHorizontalAlignment(SwingConstants.CENTER);
	txtApellido1.setBounds(14, 78, 110, 20);
	getContentPane().add(txtApellido1);
	txtApellido1.setColumns(10);
	
	txtApellido2 = new JTextField();
	txtApellido2.setEditable(false);
	txtApellido2.setHorizontalAlignment(SwingConstants.CENTER);
	txtApellido2.setBounds(138, 78, 110, 20);
	getContentPane().add(txtApellido2);
	txtApellido2.setColumns(10);
	
	txtNombre = new JTextField();
	txtNombre.setEditable(false);
	txtNombre.setHorizontalAlignment(SwingConstants.CENTER);
	txtNombre.setBounds(262, 78, 110, 20);
	getContentPane().add(txtNombre);
	txtNombre.setColumns(10);
	
	JLabel lblApellido = new JLabel("Apellido 1");
	lblApellido.setHorizontalAlignment(SwingConstants.CENTER);
	lblApellido.setBounds(41, 53, 56, 14);
	getContentPane().add(lblApellido);
	
	JLabel lblApellido_1 = new JLabel("Apellido 2");
	lblApellido_1.setHorizontalAlignment(SwingConstants.CENTER);
	lblApellido_1.setBounds(165, 53, 56, 14);
	getContentPane().add(lblApellido_1);
	
	JLabel lblNombre = new JLabel("Nombre");
	lblNombre.setHorizontalAlignment(SwingConstants.CENTER);
	lblNombre.setBounds(289, 53, 56, 14);
	getContentPane().add(lblNombre);
	
	txtCodigoUser = new JTextField();
	txtCodigoUser.setEditable(false);
	txtCodigoUser.setHorizontalAlignment(SwingConstants.CENTER);
	txtCodigoUser.setBounds(153, 136, 86, 20);
	getContentPane().add(txtCodigoUser);
	txtCodigoUser.setColumns(10);
	
	lblCodigo = new JLabel("Codigo");
	lblCodigo.setHorizontalAlignment(SwingConstants.CENTER);
	lblCodigo.setBounds(173, 111, 46, 14);
	getContentPane().add(lblCodigo);
	
	lblGestinDeUsuario = new JLabel("Gesti\u00F3n de usuario");
	lblGestinDeUsuario.setHorizontalAlignment(SwingConstants.CENTER);
	lblGestinDeUsuario.setForeground(Color.BLUE);
	lblGestinDeUsuario.setBounds(137, 11, 111, 14);
	getContentPane().add(lblGestinDeUsuario);
}
 
开发者ID:JuandeLS3,项目名称:Library-app,代码行数:63,代码来源:GestionUsuarios.java

示例8: GestionArticulos

import javax.swing.JTextField; //导入方法依赖的package包/类
public GestionArticulos(Connection conn,JFrame principal) {
	super();
	this.conn=conn;		// Recibimos la conexi�n de Biblioteca
	this.principal=principal;
	this.principal.setEnabled(false);
	this.principal.setVisible(false);
	setTitle("Gesti�n de art�culos");
	
	txtCodigo = new JTextField();
	txtCodigo.setHorizontalAlignment(SwingConstants.CENTER);
	txtCodigo.setEditable(false);
	txtCodigo.setBounds(59, 68, 105, 20);
	getContentPane().add(txtCodigo);
	txtCodigo.setColumns(10);
	
	txtTitulo = new JTextField();
	txtTitulo.setHorizontalAlignment(SwingConstants.CENTER);
	txtTitulo.setEditable(false);
	txtTitulo.setBounds(223, 68, 105, 20);
	getContentPane().add(txtTitulo);
	txtTitulo.setColumns(10);
	
	txtAutor = new JTextField();
	txtAutor.setHorizontalAlignment(SwingConstants.CENTER);
	txtAutor.setEditable(false);
	txtAutor.setBounds(59, 131, 105, 20);
	getContentPane().add(txtAutor);
	txtAutor.setColumns(10);
	
	txtNumpaginas = new JTextField();
	txtNumpaginas.setHorizontalAlignment(SwingConstants.CENTER);
	txtNumpaginas.setEditable(false);
	txtNumpaginas.setBounds(223, 131, 105, 20);
	getContentPane().add(txtNumpaginas);
	txtNumpaginas.setColumns(10);
	
	JLabel lblCdigo = new JLabel("C\u00F3digo");
	lblCdigo.setHorizontalAlignment(SwingConstants.CENTER);
	lblCdigo.setBounds(88, 43, 46, 14);
	getContentPane().add(lblCdigo);
	
	JLabel lblTitulo = new JLabel("Titulo");
	lblTitulo.setHorizontalAlignment(SwingConstants.CENTER);
	lblTitulo.setBounds(252, 43, 46, 14);
	getContentPane().add(lblTitulo);
	
	JLabel lblAutor = new JLabel("Autor");
	lblAutor.setHorizontalAlignment(SwingConstants.CENTER);
	lblAutor.setBounds(88, 106, 46, 14);
	getContentPane().add(lblAutor);
	
	JLabel lblNumPginas = new JLabel("Num. p\u00E1ginas");
	lblNumPginas.setHorizontalAlignment(SwingConstants.CENTER);
	lblNumPginas.setBounds(228, 106, 95, 14);
	getContentPane().add(lblNumPginas);
	
	JLabel lblGestinDeArtculos = new JLabel("Gesti\u00F3n de art\u00EDculos");
	lblGestinDeArtculos.setForeground(Color.BLUE);
	lblGestinDeArtculos.setHorizontalAlignment(SwingConstants.CENTER);
	lblGestinDeArtculos.setBounds(141, 11, 117, 14);
	getContentPane().add(lblGestinDeArtculos);
	

}
 
开发者ID:JuandeLS3,项目名称:Library-app,代码行数:65,代码来源:GestionArticulos.java

示例9: setRightAlign

import javax.swing.JTextField; //导入方法依赖的package包/类
private void setRightAlign(ArrayList<JTextField> txtFieldList) {
    for (JTextField txt : txtFieldList) {
        txt.setHorizontalAlignment(SwingConstants.RIGHT);
    }
}
 
开发者ID:Zephyr-Koo,项目名称:java-gui-practical-demo,代码行数:6,代码来源:P3Q5.java

示例10: stylizeTextField

import javax.swing.JTextField; //导入方法依赖的package包/类
public void stylizeTextField(JTextField t){
	t.setFont(font_14_bold);
	t.setForeground(Color.BLACK);
	t.setBackground(Color.WHITE);
	t.setHorizontalAlignment(JTextField.CENTER);
}
 
开发者ID:kevingilboy,项目名称:COE1186,代码行数:7,代码来源:SimulatorGui.java


注:本文中的javax.swing.JTextField.setHorizontalAlignment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。