java jpanel_Java JPanel.setAutoscrolls方法代码示例

import javax.swing.JPanel; //导入方法依赖的package包/类

/**

* 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);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值