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

The following examples show how to use javax.swing.JLabel#setAutoscrolls() . 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: Main_CustomersFrame.java    From Hotel-Properties-Management-System with GNU General Public License v2.0 4 votes vote down vote up
public Main_CustomersFrame() {

        this.setAutoscrolls(true);
        this.setMinimumSize(new Dimension(800, 600));
        /*make it default size of frame maximized */
        this.setMaximumSize(new Dimension(1000, 900));
        this.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
        setLayout(new BorderLayout(0, 0));

        bean = LocaleBean.getInstance();
        loggingEngine = LoggingEngine.getInstance();
        componentOrientation = new ChangeComponentOrientation();
        componentOrientation.setThePanel(this);

        searchPanel.setDoubleBuffered(false);
        searchPanel.setAutoscrolls(true);
        add(searchPanel, BorderLayout.NORTH);
        searchPanel.setPreferredSize(new Dimension(10, 30));

        lblTableFilter = new JLabel("Type to search : ");
        lblTableFilter.setForeground(new Color(178, 34, 34));
        lblTableFilter.setSize(new Dimension(130, 25));
        lblTableFilter.setPreferredSize(new Dimension(130, 22));
        lblTableFilter.setHorizontalTextPosition(SwingConstants.CENTER);
        lblTableFilter.setAutoscrolls(true);
        lblTableFilter.setHorizontalAlignment(SwingConstants.LEFT);
        lblTableFilter.setFont(new Font("Dialog", Font.BOLD, 15));

        searchFilterField = new JTextField();
        searchFilterField.setDragEnabled(true);
        searchFilterField.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, new Color(0, 191, 255), null, null, null));
        searchFilterField.setPreferredSize(new Dimension(200, 22));
        searchFilterField.setIgnoreRepaint(true);
        searchFilterField.setColumns(10);
        searchFilterField.setFont(new Font("Dialog", Font.BOLD, 13));
        searchFilterField.setHorizontalAlignment(SwingConstants.LEFT);
        GroupLayout gl_searchPanel = new GroupLayout(searchPanel);
        gl_searchPanel.setHorizontalGroup(
                gl_searchPanel.createParallelGroup(Alignment.LEADING)
                        .addGroup(gl_searchPanel.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(lblTableFilter, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(ComponentPlacement.RELATED)
                                .addComponent(searchFilterField, GroupLayout.DEFAULT_SIZE, 208, Short.MAX_VALUE)
                                .addGap(118))
        );
        gl_searchPanel.setVerticalGroup(
                gl_searchPanel.createParallelGroup(Alignment.LEADING)
                        .addGroup(gl_searchPanel.createSequentialGroup()
                                .addGap(5)
                                .addGroup(gl_searchPanel.createParallelGroup(Alignment.BASELINE)
                                        .addComponent(lblTableFilter, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                        .addComponent(searchFilterField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                                .addContainerGap())
        );
        searchPanel.setLayout(gl_searchPanel);

        searchFilterField.addKeyListener(new KeyAdapter() {
            @Override
            public void keyTyped(KeyEvent e) {

                final String searchedWord = searchFilterField.getText();
                filter(searchedWord);

            }
        });

        scrollPane = new JScrollPane();
        add(scrollPane);

        //populate main table model with custom method
        populateMainTable(model);

        customerTable = new JTable(model);
        customerTable.setFillsViewportHeight(true);
        customerTable.setRowSelectionAllowed(true);

        THR.setHorizontalAlignment(SwingConstants.CENTER);

        customerTable.setDefaultRenderer(Object.class, renderer);
        customerTable.getTableHeader().setDefaultRenderer(THR);
        customerTable.setFont(new Font("Dialog", Font.PLAIN, 14));
        customerTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        customerTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
        customerTable.setBackground(new Color(245, 245, 245));
        customerTable.addMouseListener(openCustomerListener());
        scrollPane.setViewportView(customerTable);

        //change component orientation with locale.
        if (bean.getLocale().toString().equals("ar_IQ")) {
            componentOrientation.changeOrientationOfJPanelToRight();
        } else {
            componentOrientation.changeOrientationOfJPanelToLeft();
        }
        //inject action event to Customers detail window to save all changes
        custWindow.setActionListener(saveChanges());
        this.setVisible(true);
    }
 
Example 2
Source File: ReadLogsWindow.java    From Hotel-Properties-Management-System with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create the frame.
 */
public ReadLogsWindow() {
	
	setTitle("Coder HPMSA - [Read Logs]");
	setBounds(100, 100, 660, 550);
	setBackground(Color.decode("#066d95"));
	setLocationRelativeTo(null);
	setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	
	this.setIconImage(Toolkit.getDefaultToolkit().
			getImage(getClass().getResource(LOGOPATH)));
	
	final JScrollPane scrollPane = new JScrollPane();
	scrollPane.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
	getContentPane().add(scrollPane, BorderLayout.CENTER);
	
	editorPane = new JTextPane();
	editorPane.setBackground(new Color(255, 255, 240));
	editorPane.setFont(new Font("Verdana", Font.PLAIN, 13));
	editorPane.setBorder(new EtchedBorder(EtchedBorder.RAISED, null, null));
	editorPane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
	editorPane.setEditable(false);
	scrollPane.setViewportView(editorPane);
	
	final JPanel filesPanel = new JPanel();
	filesPanel.setPreferredSize(new Dimension(200, 10));
	getContentPane().add(filesPanel, BorderLayout.EAST);
	filesPanel.setLayout(new BorderLayout(0, 0));
	
	final JScrollPane listScrollPane = new JScrollPane();
	listScrollPane.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
	listScrollPane.setViewportView(logFilesList());
	filesPanel.add(listScrollPane, BorderLayout.CENTER);
	
	final JPanel titlePanel = new JPanel();
	titlePanel.setPreferredSize(new Dimension(10, 40));
	titlePanel.setBackground(Color.decode("#066d95"));
	titlePanel.setAutoscrolls(true);
	getContentPane().add(titlePanel, BorderLayout.NORTH);
	titlePanel.setLayout(new BorderLayout(0, 0));
	
	final JLabel lblTitle = new JLabel("SYSTEM LOG RECORDS");
	lblTitle.setHorizontalTextPosition(SwingConstants.CENTER);
	lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
	lblTitle.setAutoscrolls(true);
	lblTitle.setFont(new Font("Verdana", Font.BOLD, 25));
	lblTitle.setForeground(UIManager.getColor("Button.highlight"));
	titlePanel.add(lblTitle, BorderLayout.CENTER);
	
	final StyledDocument doc = editorPane.getStyledDocument();
	final SimpleAttributeSet center = new SimpleAttributeSet();
	StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
	doc.setParagraphAttributes(0, doc.getLength(), center, false);
	
	setVisible(true);
}