Java Code Examples for javax.swing.JTextField#setDocument()

The following examples show how to use javax.swing.JTextField#setDocument() . 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 File: HiscoresPanel.java    From osrsclient with GNU General Public License v2.0 7 votes vote down vote up
private void setup() {
       this.setLayout(new MigLayout("ins 5,center"));
       this.setBackground(Color.BLACK);
       usernameField = new JTextField();
       usernameField.setDocument(new LengthRestrictedDocument(12));
       usernameField.setBackground(new Color(101, 101, 101));
       usernameField.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));

       xpDisplay = new JLabel();
       rsnLabel = new JLabel("RSN:");
       rsnLabel.setForeground(Color.white);
       rsnLabel.setFont(new Font(rsnLabel.getFont().getFontName(), Font.BOLD, rsnLabel.getFont().getSize()));

       levelsDisplayPanel = new LevelsPanel();
       levelsDisplayPanel.setRolloverListener(this);

       levelInfoPanel = new LevelInfoPanel();

       searchButton = new JButton();
       searchButton.setIcon(new javax.swing.ImageIcon(getClass().getClassLoader().getResource("resources/searchiconsquare3.png")));
       //searchButton.setIcon(new javax.swing.ImageIcon(getClass().getClassLoader().getResource("resources/bwsearch2.png")));
searchButton.setBorderPainted(false);
       searchButton.setFocusPainted(false);
       searchButton.setContentAreaFilled(false);

       add(rsnLabel, "cell 0 0, gap 0, align left");
       add(usernameField, "width 60%, cell 1 0,align left, ");
       add(searchButton, "cell 2 0,align right ");
       add(levelsDisplayPanel, "width 100%, height 20%, cell 0 1, center,spanx");
       add(levelInfoPanel, "width 100%, height 15%, cell 0 2, center, spanx");
   }
 
Example 2
Source File: StoreGroupTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testString() throws Exception {

        // Test values
        String PROP_NAME = "testText";
        String ORIGINAL_VALUE = "originalValue";
        String NEW_VALUE = "newValue";
        
        // Needed objects
        EditableProperties ep = new EditableProperties(false);
        PropertyEvaluator evaluator = new PlainPropertyEvaluator( ep );
        StoreGroup sg = new StoreGroup();

        // Test correct value of the model
        ep.setProperty( PROP_NAME, ORIGINAL_VALUE );
        Document doc = sg.createStringDocument( evaluator, PROP_NAME );
        JTextField jtf = new JTextField();
        jtf.setDocument( doc );        
        assertEquals( "JTextField has to have correct value", ORIGINAL_VALUE, jtf.getText() );
        
        // Test value is stored
        jtf.setText( NEW_VALUE );        
        sg.store( ep );        
        assertEquals( "Value has to be set into the properties", NEW_VALUE, ep.getProperty( PROP_NAME ) );
        
    }
 
Example 3
Source File: StoreGroupTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 *#57797:dist.jar changed to hardcode 'dist' rather than '${dist.dir}'
 */
public void testIssue57797 () throws Exception {
    String PROP_NAME_A = "propertyA";
    String PROP_NAME_B = "propertyB";
    String ORIGINAL_A_VALUE = "original_A_Value";
    String ORIGINAL_B_VALUE = "original_B_Value";
    String NEW_A_VALUE = "new_A_Value";
    
    EditableProperties ep = new EditableProperties(false);
    PropertyEvaluator evaluator = new PlainPropertyEvaluator( ep );
    StoreGroup sg = new StoreGroup();

    ep.setProperty( PROP_NAME_A, ORIGINAL_A_VALUE );
    ep.setProperty( PROP_NAME_B, ORIGINAL_B_VALUE );
    Document doc1 = sg.createStringDocument( evaluator, PROP_NAME_A );
    Document doc2 = sg.createStringDocument( evaluator, PROP_NAME_B );
    JTextField jtf1 = new JTextField ();        
    jtf1.setDocument ( doc1 );        
    JTextField jtf2 = new JTextField ();
    jtf2.setDocument ( doc2 );               
    jtf1.setText( NEW_A_VALUE );     
    EditableProperties newEp = new EditableProperties(false);
    sg.store( newEp );        
    assertEquals( "Expected one new propery", 1, newEp.size());
    assertEquals( "Value has to be set into the properties", NEW_A_VALUE, newEp.getProperty( PROP_NAME_A ) );
}
 
Example 4
Source File: ValueResultItemTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Test
public void testValueReplacement() throws Exception {
    JTextField textField = new JTextField();
    BaseDocument doc = getDocument("/org/netbeans/modules/xml/text/completion/res/ValueReplacement.xml");
    BaseDocument referenceDoc = getDocument("/org/netbeans/modules/xml/text/completion/res/ValueReplacement.golden.xml");
    Finder ip1Finder = new FinderFactory.StringFwdFinder("##IP1##", true);
    int insertPos1 = doc.find(ip1Finder, doc.getStartPosition().getOffset(), doc.getEndPosition().getOffset());
    doc.replace(insertPos1, 7, "", null);
    textField.setDocument(doc);
    MockGrammarResult mgr = new MockGrammarResult("Middle", "Mid");
    ValueResultItem vri1 = new ValueResultItem(insertPos1, mgr, 0, null);
    textField.setCaretPosition(insertPos1);
    vri1.defaultAction(textField);

    Finder ip2Finder = new FinderFactory.StringFwdFinder("##IP2##", true);
    int insertPos2 = doc.find(ip2Finder, doc.getStartPosition().getOffset(), doc.getEndPosition().getOffset());
    doc.replace(insertPos2, 7, "", null);
    ValueResultItem vri2 = new ValueResultItem(insertPos2, mgr, 7, null);
    textField.setCaretPosition(insertPos2);
    vri2.defaultAction(textField);

    MockGrammarResult mgr2 = new MockGrammarResult("Middle", "");
    Finder ip3Finder = new FinderFactory.StringFwdFinder("##IP3##", true);
    int insertPos3 = doc.find(ip3Finder, doc.getStartPosition().getOffset(), doc.getEndPosition().getOffset());
    doc.replace(insertPos3, 7, "", null);
    ValueResultItem vri3 = new ValueResultItem(insertPos3, mgr2, 7, null);
    textField.setCaretPosition(insertPos3);
    vri3.defaultAction(textField);

    assertTrue("Result did not match reference", compare(referenceDoc, doc));
}
 
Example 5
Source File: AutoCompleteDocument.java    From Spark with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a auto completing JTextField.
 *
 * @param dictionary an array of words to use when trying auto completion.
 * @return a JTextField that is initialized as using an auto
 *         completing textfield.
 */
public static JTextField createAutoCompleteTextField(String[] dictionary) {
    JTextField field = new JTextField();
    AutoCompleteDocument doc = new AutoCompleteDocument(field,
        dictionary);
    field.setDocument(doc);
    return field;
}
 
Example 6
Source File: SampleAnalysisWorkflowManagerLAICPMS.java    From ET_Redux with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param tableRows
 * @param max
 * @return
 */
public JTextField insertTableTextField(
        final ArrayList<JComponent> tableRows, final int max) {

    final JTextField tableTextField = new JTextField();
    tableTextField.setDocument(new UnDoAbleDocument(tableTextField, true));
    tableTextField.setHorizontalAlignment(JTextField.LEFT);
    tableRows.add(tableTextField);

    modifyComponentKeyMapForTable(tableTextField, tableRows, max);

    return tableTextField;
}
 
Example 7
Source File: SampleAnalysisWorkflowManagerLAICPMS.java    From ET_Redux with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param tableRows
 * @param max
 * @return
 */
public JTextField insertTableTextFieldForDoubles(
        final ArrayList<JComponent> tableRows, final int max) {

    final JTextField tableTextField = new JTextField();
    tableTextField.setDocument(new BigDecimalDocument(tableTextField, true));
    tableTextField.setHorizontalAlignment(JTextField.RIGHT);

    tableRows.add(tableTextField);

    modifyComponentKeyMapForTable(tableTextField, tableRows, max);

    return tableTextField;
}
 
Example 8
Source File: SampleAnalysisWorkflowManagerIDTIMS.java    From ET_Redux with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param tableRows
 * @param max
 * @return
 */
public JTextField insertTableTextField(
        final ArrayList<JComponent> tableRows, final int max) {

    final JTextField tableTextField = new JTextField();
    tableTextField.setDocument(new UnDoAbleDocument(tableTextField, true));
    tableTextField.setHorizontalAlignment(JTextField.LEFT);
    tableRows.add(tableTextField);

    modifyComponentKeyMapForTable(tableTextField, tableRows, max);

    return tableTextField;
}
 
Example 9
Source File: SampleAnalysisWorkflowManagerIDTIMS.java    From ET_Redux with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param tableRows
 * @param max
 * @return
 */
public JTextField insertTableTextFieldForDoubles(
        final ArrayList<JComponent> tableRows, final int max) {

    final JTextField tableTextField = new JTextField();
    tableTextField.setDocument(new BigDecimalDocument(tableTextField, true));
    tableTextField.setHorizontalAlignment(JTextField.RIGHT);

    tableRows.add(tableTextField);

    modifyComponentKeyMapForTable(tableTextField, tableRows, max);

    return tableTextField;
}
 
Example 10
Source File: SharedFunctions.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
public static JTextField createTextField(
        JPanel pnl, String str, String tip, Boolean bool, int limit) {
    JTextField txt = new JTextField();
    if (limit > -1) {
        txt.setDocument(new JTextFieldLimit(limit));
    }
    txt.setText(str);
    txt.setEditable(bool);
    txt.setToolTipText(tip);
    pnl.add(txt);
    return txt;
}
 
Example 11
Source File: EditorHelper.java    From javamoney-examples with Apache License 2.0 5 votes vote down vote up
private
static
JTextField
createTextField(TextConstrainer constrainer)
{
  JTextField textField = new JTextField();

  textField.setDocument(constrainer);

  return textField;
}
 
Example 12
Source File: StringPropertyCellEditor.java    From openAGV with Apache License 2.0 5 votes vote down vote up
@Override
public Component getTableCellEditorComponent(
    JTable table, Object value, boolean isSelected, int row, int column) {

  setValue(value);
  JTextField textField = (JTextField) getComponent();
  if (value instanceof StringProperty) {
    textField.setDocument(new PlainDocument());
  }
  textField.setText(property().getText());

  return fComponent;
}
 
Example 13
Source File: BSAddIFrame.java    From LibraryManagementSystem with MIT License 4 votes vote down vote up
public BSAddIFrame() {
	super();
	setIconifiable(true);							// ���ô������С������������
	setClosable(true);								// ���ô���ɹرգ���������
	setTitle("������");						// ���ô�����⣭��������
	setBounds(100, 50, 500, 225);

	//������ͷͼƬ
	final JLabel logoLabel = new JLabel();
	ImageIcon readerAddIcon=CreateIcon.add("tback.jpg");
	logoLabel.setIcon(readerAddIcon);
	logoLabel.setOpaque(true);
	logoLabel.setBackground(Color.white);
	logoLabel.setPreferredSize(new Dimension(400, 60));
	getContentPane().add(logoLabel, BorderLayout.NORTH);

	//����һ�������������
	final JPanel panel = new JPanel();
	panel.setLayout(new FlowLayout());
	getContentPane().add(panel);

	//�������������Ƕ�����1,���ڷ��÷ǰ�ť���
	final JPanel panel_1 = new JPanel();
	final GridLayout gridLayout = new GridLayout(2, 2);
	gridLayout.setVgap(20);
	panel_1.setLayout(gridLayout);
	panel.add(panel_1);

	final JLabel label_2 = new JLabel();
	label_2.setText("��ܱ�ţ�");
	panel_1.add(label_2);
	id = new JTextField(10);
	id.setDocument(new MyDocument(256));
	panel_1.add(id);
	
	final JLabel label_3 = new JLabel();
	label_3.setText("���λ�ã�");
	panel_1.add(label_3);
	position = new JTextField(10);
	position.setDocument(new MyDocument(256));
	panel_1.add(position);
	
	//����������Ƕ��һ�����ڷ��Ű�ť�����
	final JPanel panel_2 = new JPanel();
	panel_2.setPreferredSize(new Dimension(450, 100));
	panel.add(panel_2);
	
	final JRadioButton radioButton1 = new JRadioButton();

	//�����������
	final JButton submit = new JButton();
	panel_2.add(submit);
	submit.setText("�ύ");
	submit.addActionListener((ActionListener) new ButtonAddListener(radioButton1));
	
	//�����������
	final JButton back = new JButton();
	panel_2.add(back);
	back.setText("����");
	back.addActionListener(new CloseActionListener());

	setVisible(true);
}
 
Example 14
Source File: BorrowIFrame.java    From LibraryManagementSystem with MIT License 4 votes vote down vote up
public BorrowIFrame() {
	super();
	setIconifiable(true);							// ���ô������С������������
	setClosable(true);								// ���ô���ɹرգ���������
	setTitle("������Ϣ���");						// ���ô�����⣭��������
	setBounds(100, 30, 500, 250);

	//������ͷͼƬ
	final JLabel logoLabel = new JLabel();
	ImageIcon readerAddIcon=CreateIcon.add("tback.jpg");
	logoLabel.setIcon(readerAddIcon);
	logoLabel.setOpaque(true);
	logoLabel.setBackground(Color.white);
	logoLabel.setPreferredSize(new Dimension(400, 60));
	getContentPane().add(logoLabel, BorderLayout.NORTH);

	//����һ�������������
	final JPanel panel = new JPanel();
	panel.setLayout(new FlowLayout());
	getContentPane().add(panel);

	//�������������Ƕ�����1,���ڷ��÷ǰ�ť���
	final JPanel panel_1 = new JPanel();
	final GridLayout gridLayout = new GridLayout(0, 4);
	gridLayout.setVgap(15);
	gridLayout.setHgap(10);
	panel_1.setLayout(gridLayout);
	panel_1.setPreferredSize(new Dimension(450, 100));
	panel.add(panel_1);

	final JLabel label_2 = new JLabel();
	label_2.setText("�������ڣ�");
	panel_1.add(label_2);
	borrowDate = new JFormattedTextField();
	borrowDate.setValue("XXXX-XX-XX");
	borrowDate.addKeyListener(new DateListener());
	panel_1.add(borrowDate);
	
	final JLabel label_3 = new JLabel();
	label_3.setText("��     �ţ�");
	panel_1.add(label_3);
	id = new JTextField();
	id.setDocument(new MyDocument(256));
	panel_1.add(id);
	
	final JLabel label_4 = new JLabel();
	label_4.setText("�鱾��� ��");
	panel_1.add(label_4);
	bid = new JTextField();
	bid.setDocument(new MyDocument(256));
	panel_1.add(bid);
	
	final JLabel label_5 = new JLabel();
	label_5.setText("���߱�ţ�");
	panel_1.add(label_5);
	rid = new JTextField();
	rid.setDocument(new MyDocument(256));
	panel_1.add(rid);
	
	final JLabel label_6 = new JLabel();
	label_6.setText("����Ա���֣�");
	panel_1.add(label_6);
	name = new JTextField();
	name.setDocument(new MyDocument(256));
	panel_1.add(name);

	//����������Ƕ��һ�����ڷ��Ű�ť�����
	final JPanel panel_2 = new JPanel();
	panel_2.setPreferredSize(new Dimension(450, 100));
	panel.add(panel_2);
	
	final JRadioButton radioButton1 = new JRadioButton();

	//�����������
	final JButton submit = new JButton();
	panel_2.add(submit);
	submit.setText("�ύ");
	submit.addActionListener((ActionListener) new ButtonAddListener(radioButton1));
	
	//�����������
	final JButton back = new JButton();
	panel_2.add(back);
	back.setText("����");
	back.addActionListener(new CloseActionListener());

	setVisible(true);
}
 
Example 15
Source File: ReturnIFrame.java    From LibraryManagementSystem with MIT License 4 votes vote down vote up
public ReturnIFrame() {
	super();
	setIconifiable(true);							// ���ô������С������������
	setClosable(true);								// ���ô���ɹرգ���������
	setTitle("��ӹ黹��Ϣ");						// ���ô�����⣭��������
	setBounds(100, 50, 500, 225);

	//������ͷͼƬ
	final JLabel logoLabel = new JLabel();
	ImageIcon readerAddIcon=CreateIcon.add("tback.jpg");
	logoLabel.setIcon(readerAddIcon);
	logoLabel.setOpaque(true);
	logoLabel.setBackground(Color.white);
	logoLabel.setPreferredSize(new Dimension(400, 60));
	getContentPane().add(logoLabel, BorderLayout.NORTH);

	//����һ�������������
	final JPanel panel = new JPanel();
	panel.setLayout(new FlowLayout());
	getContentPane().add(panel);

	//�������������Ƕ�����1,���ڷ��÷ǰ�ť���
	final JPanel panel_1 = new JPanel();
	final GridLayout gridLayout = new GridLayout(2, 2);
	gridLayout.setVgap(20);
	panel_1.setLayout(gridLayout);
	panel.add(panel_1);

	final JLabel label_2 = new JLabel();
	label_2.setText("���ļ�¼��ţ�");
	panel_1.add(label_2);
	id = new JTextField(10);
	id.setDocument(new MyDocument(256));
	panel_1.add(id);
	
	final JLabel label_3 = new JLabel();
	label_3.setText("�黹���ڣ�");
	panel_1.add(label_3);
	return_date = new JFormattedTextField();
	return_date.setValue("XXXX-XX-XX");
	return_date.addKeyListener(new DateListener());
	panel_1.add(return_date);
	
	//����������Ƕ��һ�����ڷ��Ű�ť�����
	final JPanel panel_2 = new JPanel();
	panel_2.setPreferredSize(new Dimension(450, 100));
	panel.add(panel_2);
	
	final JRadioButton radioButton1 = new JRadioButton();

	//�����������
	final JButton submit = new JButton();
	panel_2.add(submit);
	submit.setText("�ύ");
	submit.addActionListener((ActionListener) new ButtonAddListener(radioButton1));
	
	//�����������
	final JButton back = new JButton();
	panel_2.add(back);
	back.setText("����");
	back.addActionListener(new CloseActionListener());

	setVisible(true);
}
 
Example 16
Source File: BookPriceIFrame.java    From LibraryManagementSystem with MIT License 4 votes vote down vote up
public BookPriceIFrame() {
	super();
	setIconifiable(true);							// ���ô������С������������
	setClosable(true);								// ���ô���ɹرգ���������
	setTitle("�޸�ͼ��۸�");						// ���ô�����⣭��������
	setBounds(100, 50, 500, 225);

	//������ͷͼƬ
	final JLabel logoLabel = new JLabel();
	ImageIcon userAddIcon=CreateIcon.add("tback.jpg");
	logoLabel.setIcon(userAddIcon);
	logoLabel.setOpaque(true);
	logoLabel.setBackground(Color.white);
	logoLabel.setPreferredSize(new Dimension(400, 60));
	getContentPane().add(logoLabel, BorderLayout.NORTH);

	//����һ�������������
	final JPanel panel = new JPanel();
	panel.setLayout(new FlowLayout());
	getContentPane().add(panel);

	//�������������Ƕ�����1,���ڷ��÷ǰ�ť���
	final JPanel panel_1 = new JPanel();
	final GridLayout gridLayout = new GridLayout(2, 2);
	gridLayout.setVgap(20);
	panel_1.setLayout(gridLayout);
	panel.add(panel_1);

	final JLabel label_2 = new JLabel();
	label_2.setText("ͼ��id��");
	panel_1.add(label_2);
	id = new JTextField(10);
	id.setDocument(new MyDocument(20));
	panel_1.add(id);
	
	final JLabel label_3 = new JLabel();
	label_3.setText("���ļ۸�Ϊ ��");
	panel_1.add(label_3);
	money = new JTextField(10);
	money.setDocument(new MyDocument(15));
	panel_1.add(money);
	
	//����������Ƕ��һ�����ڷ��Ű�ť�����
	final JPanel panel_2 = new JPanel();
	panel_2.setPreferredSize(new Dimension(450, 100));
	panel.add(panel_2);
	
	final JRadioButton radioButton1 = new JRadioButton();

	//�����������
	final JButton submit = new JButton();
	panel_2.add(submit);
	submit.setText("�ύ");
	submit.addActionListener((ActionListener) new ButtonAddListener(radioButton1));
	
	//�����������
	final JButton back = new JButton();
	panel_2.add(back);
	back.setText("����");
	back.addActionListener(new CloseActionListener());

	setVisible(true);
}
 
Example 17
Source File: UserAddIFrame.java    From LibraryManagementSystem with MIT License 4 votes vote down vote up
public UserAddIFrame() {
	super();
	setIconifiable(true);							// ���ô������С������������
	setClosable(true);								// ���ô���ɹرգ���������
	setTitle("��ӹ���Ա");						// ���ô�����⣭��������
	setBounds(100, 50, 500, 225);

	//������ͷͼƬ
	final JLabel logoLabel = new JLabel();
	ImageIcon userAddIcon=CreateIcon.add("tback.jpg");
	logoLabel.setIcon(userAddIcon);
	logoLabel.setOpaque(true);
	logoLabel.setBackground(Color.white);
	logoLabel.setPreferredSize(new Dimension(400, 60));
	getContentPane().add(logoLabel, BorderLayout.NORTH);

	//����һ�������������
	final JPanel panel = new JPanel();
	panel.setLayout(new FlowLayout());
	getContentPane().add(panel);

	//�������������Ƕ�����1,���ڷ��÷ǰ�ť���
	final JPanel panel_1 = new JPanel();
	final GridLayout gridLayout = new GridLayout(2, 2);
	gridLayout.setVgap(20);
	panel_1.setLayout(gridLayout);
	panel.add(panel_1);

	final JLabel label_2 = new JLabel();
	label_2.setText("�û�����");
	panel_1.add(label_2);
	name = new JTextField(10);
	name.setDocument(new MyDocument(20));
	panel_1.add(name);
	
	final JLabel label_3 = new JLabel();
	label_3.setText("���룺");
	panel_1.add(label_3);
	password = new JTextField(10);
	password.setDocument(new MyDocument(15));
	panel_1.add(password);
	
	//����������Ƕ��һ�����ڷ��Ű�ť�����
	final JPanel panel_2 = new JPanel();
	panel_2.setPreferredSize(new Dimension(450, 100));
	panel.add(panel_2);
	
	final JRadioButton radioButton1 = new JRadioButton();

	//�����������
	final JButton submit = new JButton();
	panel_2.add(submit);
	submit.setText("�ύ");
	submit.addActionListener((ActionListener) new ButtonAddListener(radioButton1));
	
	//�����������
	final JButton back = new JButton();
	panel_2.add(back);
	back.setText("����");
	back.addActionListener(new CloseActionListener());

	setVisible(true);
}
 
Example 18
Source File: Main.java    From blog with Apache License 2.0 4 votes vote down vote up
public void createAndShowUI() {
	BoundedRangeModel progressModel = new DefaultBoundedRangeModel();
	BoundedRangeProgress progressAdapter = new BoundedRangeProgress(progressModel);
	Document resultDocument = new PlainDocument();

	ComponentVisibility progressBarVisibility = new ComponentVisibility("enabled", false);
	progressBarVisibility.setInvisibleDelay(1, TimeUnit.SECONDS);

	ProgressCancelAction cancelAction = new ProgressCancelAction();
	cancelAction.putValue(Action.NAME, "Cancel");

	ProgressSimulationAction progressAction = new ProgressSimulationAction();
	progressAction.addProgressAware(progressAdapter);
	progressAction.addProgressAware(cancelAction);
	progressAction.addPropertyChangeListener(progressBarVisibility);
	progressAction.putValue(Action.NAME, "Start");
	progressAction.setResultDocument(resultDocument);

	JFrame mainFrame = new JFrame("Progress Object Pattern with Java Swing");
	mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
	mainFrame.setMinimumSize(new Dimension(600, 120));

	JProgressBar progressBar = new JProgressBar(progressModel);
	progressBar.setVisible(false);
	progressBar.setStringPainted(true);
	progressBarVisibility.setComponent(progressBar);

	JButton startProgressButton = new JButton(progressAction);
	JButton cancelButton = new JButton(cancelAction);
	JTextField resultTextField = new JTextField(40);
	resultTextField.setEditable(false);
	resultTextField.setDocument(resultDocument);

	JPanel mainPanel = new JPanel();
	mainPanel.add(startProgressButton);
	mainPanel.add(cancelButton);
	mainPanel.add(resultTextField);

	Container contentPane = mainFrame.getContentPane();
	contentPane.add(mainPanel);
	contentPane.add(progressBar, BorderLayout.SOUTH);

	mainFrame.pack();
	mainFrame.setLocationRelativeTo(null);
	mainFrame.setVisible(true);
}
 
Example 19
Source File: ReaderAddIFrame.java    From LibraryManagementSystem with MIT License 4 votes vote down vote up
public ReaderAddIFrame() {
	super();
	setIconifiable(true);							// ���ô������С������������
	setClosable(true);								// ���ô���ɹرգ���������
	setTitle("������Ϣ���");						// ���ô�����⣭��������
	setBounds(100, 30, 500, 250);

	//������ͷͼƬ
	final JLabel logoLabel = new JLabel();
	ImageIcon readerAddIcon=CreateIcon.add("tback.jpg");
	logoLabel.setIcon(readerAddIcon);
	logoLabel.setOpaque(true);
	logoLabel.setBackground(Color.white);
	logoLabel.setPreferredSize(new Dimension(400, 60));
	getContentPane().add(logoLabel, BorderLayout.NORTH);

	//����һ�������������
	final JPanel panel = new JPanel();
	panel.setLayout(new FlowLayout());
	getContentPane().add(panel);

	//�������������Ƕ�����1,���ڷ��÷ǰ�ť���
	final JPanel panel_1 = new JPanel();
	final GridLayout gridLayout = new GridLayout(0, 4);
	gridLayout.setVgap(15);
	gridLayout.setHgap(10);
	panel_1.setLayout(gridLayout);
	panel_1.setPreferredSize(new Dimension(450, 100));
	panel.add(panel_1);

	final JLabel label_2 = new JLabel();
	label_2.setText("��ַ��");
	panel_1.add(label_2);
	address = new JTextField();
	address.setDocument(new MyDocument(256));
	panel_1.add(address);
	
	final JLabel label_3 = new JLabel();
	label_3.setText("��     �ţ�");
	panel_1.add(label_3);
	id = new JTextField();
	id.setDocument(new MyDocument(256));
	panel_1.add(id);
	
	final JLabel label_4 = new JLabel();
	label_4.setText("���� ��");
	panel_1.add(label_4);
	name = new JTextField();
	name.setDocument(new MyDocument(256));
	panel_1.add(name);
	
	final JLabel label_5 = new JLabel();
	label_5.setText("Ƿ�");
	panel_1.add(label_5);
	own = new JTextField();
	own.setDocument(new MyDocument(256));
	panel_1.add(own);
	
	final JLabel label_6 = new JLabel();
	label_6.setText("�绰��");
	panel_1.add(label_6);
	phone = new JTextField();
	phone.setDocument(new MyDocument(256));
	panel_1.add(phone);
	
	final JLabel label_7 = new JLabel();
	label_7.setText("�Ա�");
	panel_1.add(label_7);
	sex = new JTextField();
	sex.setDocument(new MyDocument(256));
	panel_1.add(sex);

	//����������Ƕ��һ�����ڷ��Ű�ť�����
	final JPanel panel_2 = new JPanel();
	panel_2.setPreferredSize(new Dimension(450, 100));
	panel.add(panel_2);
	
	final JRadioButton radioButton1 = new JRadioButton();

	//�����������
	final JButton submit = new JButton();
	panel_2.add(submit);
	submit.setText("�ύ");
	submit.addActionListener((ActionListener) new ButtonAddListener(radioButton1));
	
	//�����������
	final JButton back = new JButton();
	panel_2.add(back);
	back.setText("����");
	back.addActionListener(new CloseActionListener());

	setVisible(true);
}
 
Example 20
Source File: CSVTableExportDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Initializes the Swing components of this dialog.
 */
private void initialize() {

  rbSeparatorTab = new JRadioButton( getResources().getString( "csvexportdialog.separator.tab" ) ); //$NON-NLS-1$
  rbSeparatorColon = new JRadioButton( getResources().getString( "csvexportdialog.separator.colon" ) ); //$NON-NLS-1$
  rbSeparatorSemicolon = new JRadioButton( getResources().getString( "csvexportdialog.separator.semicolon" ) ); //$NON-NLS-1$
  rbSeparatorOther = new JRadioButton( getResources().getString( "csvexportdialog.separator.other" ) ); //$NON-NLS-1$

  getFormValidator().registerButton( rbSeparatorColon );
  getFormValidator().registerButton( rbSeparatorOther );
  getFormValidator().registerButton( rbSeparatorSemicolon );
  getFormValidator().registerButton( rbSeparatorTab );

  final ButtonGroup btg = new ButtonGroup();
  btg.add( rbSeparatorTab );
  btg.add( rbSeparatorColon );
  btg.add( rbSeparatorSemicolon );
  btg.add( rbSeparatorOther );

  final Action selectAction = new CSVTableExportDialog.ActionSelectSeparator();
  rbSeparatorTab.addActionListener( selectAction );
  rbSeparatorColon.addActionListener( selectAction );
  rbSeparatorSemicolon.addActionListener( selectAction );
  rbSeparatorOther.addActionListener( selectAction );

  txSeparatorOther = new JTextField();
  txSeparatorOther.setDocument( new LengthLimitingDocument( 1 ) );
  txSeparatorOther.setColumns( 5 );
  getFormValidator().registerTextField( txSeparatorOther );

  cbxStrictLayout = new JCheckBox( getResources().getString( "csvexportdialog.strict-layout" ) ); //$NON-NLS-1$
  getFormValidator().registerButton( cbxStrictLayout );

  txFilename = new JTextField();
  txFilename.setColumns( 30 );
  encodingModel = EncodingComboBoxModel.createDefaultModel( Locale.getDefault() );
  encodingModel.sort();
  cbEncoding = new JComboBox( encodingModel );

  final JPanel exportPane = createExportPane();

  final JTabbedPane tabbedPane = new JTabbedPane();
  tabbedPane.add( getResources().getString( "csvexportdialog.export-settings" ), exportPane ); //$NON-NLS-1$
  tabbedPane.add( getResources().getString( "csvexportdialog.parameters" ), getParametersPanel() );

  // button panel
  final Configuration config = ClassicEngineBoot.getInstance().getGlobalConfig();
  if ( "true"
      .equals( config
          .getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.gui.csv.table.AdvancedSettingsAvailable" ) ) ) {
    final JPanel advancedOptionsPane = createAdvancedOptionsPanel();
    tabbedPane.add( getResources().getString( "csvexportdialog.advanced-settings" ), advancedOptionsPane ); //$NON-NLS-1$

  }
  setContentPane( createContentPane( tabbedPane ) );

  getFormValidator().registerTextField( txFilename );
  getFormValidator().registerComboBox( cbEncoding );
}