📄 codegenerationstatusdialog.java
字号:
package org.jawin.browser.dialog;
import javax.swing.*;
import java.awt.*;
import javax.swing.border.Border;
import org.jawin.browser.codegen.CodeGenerator;
import java.awt.event.*;
/**
* Show a progress status of the code generation, called from anotehr thread
* that is actually doing the work.
*
* <p>Title: Jawin Code Generation GUI</p>
* <p>Description: GUI for exploring type libraries and generating Java code</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: Open Source Incentive</p>
*
* @author Josh Passenger
* @version 1.0
*/
public class CodeGenerationStatusDialog extends CenteredDialog
{
public static final Color PROGRESS_COLOR = new Color(197, 223, 118);
private JPanel rootPanel = new JPanel();
private BorderLayout borderLayout = new BorderLayout();
private JPanel topPanel = new JPanel();
private JPanel buttonPanel = new JPanel();
private JButton cancelButton = new JButton();
private FlowLayout flowLayout = new FlowLayout();
private BorderLayout topPanelBorderLayout = new BorderLayout();
private JProgressBar progressBar = new JProgressBar();
private JLabel statusLabel = new JLabel();
private StringBuffer labelBuffer = new StringBuffer();
private String baseText = "";
private CodeGenerator codeGenerator = null;
public CodeGenerationStatusDialog(Frame owner, String title, boolean modal)
{
super(owner, title, modal);
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public CodeGenerationStatusDialog()
{
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
private void jbInit() throws Exception
{
setResizable(false);
setSize(new Dimension(507, 122));
rootPanel.setLayout(borderLayout);
cancelButton.setText("Cancel");
buttonPanel.setLayout(flowLayout);
flowLayout.setAlignment(FlowLayout.RIGHT);
topPanel.setLayout(topPanelBorderLayout);
progressBar.setFont(new java.awt.Font("Dialog", 0, 10));
// progressBar.setForeground(PROGRESS_COLOR);
progressBar.setString("");
progressBar.setStringPainted(true);
statusLabel.setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
getContentPane().add(rootPanel, BorderLayout.CENTER);
rootPanel.add(topPanel, BorderLayout.CENTER);
rootPanel.add(buttonPanel, BorderLayout.SOUTH);
buttonPanel.add(cancelButton, null);
topPanel.add(progressBar, BorderLayout.SOUTH);
topPanel.add(statusLabel, BorderLayout.CENTER);
registerListeners();
}
private void registerListeners()
{
cancelButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
cancel();
}
});
}
public void setText(String newLabel)
{
labelBuffer.setLength(0);
labelBuffer.append(baseText).append(newLabel);
statusLabel.setText(labelBuffer.toString());
}
public void setBaseText(String newBaseText)
{
baseText = newBaseText;
}
public void tickProgressBar()
{
progressBar.setValue(progressBar.getValue() + 1);
StringBuffer buffer = new StringBuffer();
buffer.append(progressBar.getValue()).append(" of ").append(progressBar.getMaximum());
progressBar.setString(buffer.toString());
}
public void setMaximumAndReset(int newMaximum)
{
progressBar.setValue(0);
progressBar.setMaximum(newMaximum);
}
/**
* Asjk the code geenrator to stop, this will cause
* the dialog to close as well
*/
private void cancel()
{
codeGenerator.pleaseStop();
}
public void show(CodeGenerator newCodeGenerator)
{
codeGenerator = newCodeGenerator;
codeGenerator.setStatusDialog(this);
new Thread(codeGenerator).start();
super.show();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -