本文整理汇总了Java中javax.swing.JProgressBar.setForeground方法的典型用法代码示例。如果您正苦于以下问题:Java JProgressBar.setForeground方法的具体用法?Java JProgressBar.setForeground怎么用?Java JProgressBar.setForeground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JProgressBar
的用法示例。
在下文中一共展示了JProgressBar.setForeground方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SendFileFrame
import javax.swing.JProgressBar; //导入方法依赖的package包/类
/**
* Create the frame.
*/
public SendFileFrame()
{
//this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 510, 196);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
lbl = new JLabel("进度条");
lbl.setBounds(42, 35, 74, 33);
contentPane.add(lbl);
progressBar = new JProgressBar();
progressBar.setForeground(Color.BLUE);
progressBar.setBounds(96, 35, 332, 33);
contentPane.add(progressBar);
lblProgress = new JLabel("");
lblProgress.setBounds(64, 82, 386, 58);
contentPane.add(lblProgress);
}
示例2: createWholeProgress
import javax.swing.JProgressBar; //导入方法依赖的package包/类
private JProgressBar createWholeProgress(int total)
{
whole = new JProgressBar(0, total);
whole.setValue(0);
whole.setStringPainted(true);
whole.setForeground(new Color(153, 153, 204));
whole.setBackground(Color.white);
return whole;
}
示例3: createCurrentProgress
import javax.swing.JProgressBar; //导入方法依赖的package包/类
private JProgressBar createCurrentProgress()
{
current = new JProgressBar(0, 0);
current.setValue(0);
current.setStringPainted(true);
current.setForeground(new Color(153, 153, 204));
current.setBackground(Color.white);
return current;
}
示例4: Downloading
import javax.swing.JProgressBar; //导入方法依赖的package包/类
public void Downloading(int n) {
MAX = n;
JPanel labelPanel = new JPanel(new FlowLayout());
JLabel label = new JLabel("Downloading...");
label.setFont(new Font("Sans Serif", Font.PLAIN, 15));
labelPanel.add(label);
labelPanel.setBorder(new EmptyBorder(4, 0, 4, 0));
labelPanel.setBackground(Color.WHITE);
JPanel progressPanel = new JPanel(new BorderLayout());
progress = new JProgressBar(0, MAX);
progress.setStringPainted(true);
progress.setForeground(Value.TRUE_COLOR);
progressPanel.add(progress);
progressPanel.setBorder(new EmptyBorder(0, 10, 4, 10));
progressPanel.setBackground(Color.WHITE);
JPanel buttonPanel = new JPanel(new FlowLayout());
buttonPanel.add(cancel);
buttonPanel.setBackground(Color.WHITE);
JPanel updatePanel = new JPanel(new BorderLayout());
updatePanel.add(labelPanel, BorderLayout.NORTH);
updatePanel.add(progressPanel, BorderLayout.CENTER);
updatePanel.add(buttonPanel, BorderLayout.SOUTH);
this.getContentPane().add(updatePanel, BorderLayout.CENTER);
}
示例5: initGUI
import javax.swing.JProgressBar; //导入方法依赖的package包/类
/**
* Initialize all gui related stuff
*/
private void initGUI() {
// Sets default title, close operation and dimensions
this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
this.setIconImage(JMTImageLoader.loadImage("Results").getImage());
this.centerWindow(CommonConstants.MAX_GUI_WIDTH_JSIM_RESULTS, CommonConstants.MAX_GUI_HEIGHT_JSIM_RESULTS);
// Creates all tabs
JTabbedPane mainPanel = new JTabbedPane();
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(mainPanel, BorderLayout.CENTER);
addTabPane(mainPanel, SimulationDefinition.MEASURE_QL, DESCRIPTION_QUEUE_LENGTH, results.getQueueLengthMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_QT, DESCRIPTION_QUEUE_TIME, results.getQueueTimeMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_RP, DESCRIPTION_RESPONSE_TIME, results.getResponseTimeMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_RD, DESCRIPTION_RESIDENCE_TIME, results.getResidenceTimeMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_U, DESCRIPTION_UTILIZATION, results.getUtilizationMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_X, DESCRIPTION_THROUGHPUT, results.getThroughputMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_DR, DESCRIPTION_DROP_RATE, results.getDropRateMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_S_CN, DESCRIPTION_SYSTEM_CUSTOMER_NUMBER, results.getSystemCustomerNumberMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_S_RP, DESCRIPTION_SYSTEM_RESPONSE_TIME, results.getSystemResponseTimeMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_S_X, DESCRIPTION_SYSTEM_THROUGHPUT, results.getSystemThroughputMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_S_DR, DESCRIPTION_SYSTEM_DROP_RATE, results.getSystemDropRateMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_S_P, DESCRIPTION_SYSTEM_POWER, results.getSystemPowerMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_RP_PER_SINK, DESCRIPTION_RESPONSE_TIME_PER_SINK, results.getResponsetimePerSinkMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_X_PER_SINK, DESCRIPTION_THROUGHPUT_PER_SINK, results.getThroughputPerSinkMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_FCR_TW, DESCRIPTION_FCR_TOTAL_WEIGHT, results.getFCRTotalWeightMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_FCR_MO, DESCRIPTION_FCR_MEMORY_OCCUPATION, results.getFCRMemoryOccupationMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_FJ_CN, DESCRIPTION_FJ_CUSTOMER_NUMBER, results.getFJCustomerNumberMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_FJ_RP, DESCRIPTION_FJ_RESPONSE_TIME, results.getFJResponseTimeMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_FX, DESCRIPTION_FIRING_THROUGHPUT, results.getFiringThroughputMeasures());
// Creates bottom toolbar
JToolBar toolbar = new JToolBar();
toolbar.setFloatable(false);
toolbar.setRollover(true);
start = new JButton();
toolbar.add(start);
start.setVisible(false);
pause = new JButton();
toolbar.add(pause);
pause.setVisible(false);
stop = new JButton();
toolbar.add(stop);
stop.setVisible(false);
// Adds a progress bar
progressBar = new JProgressBar();
progressBar.setStringPainted(true);
progressBar.setForeground(Color.BLUE);
UIManager.put("ProgressBar.selectionForeground", Color.WHITE);
setProgressBar(results.getProgress(), results.getElapsedTime());
toolbar.add(progressBar);
// Add close window button
JButton close = new JButton();
close.setIcon(JMTImageLoader.loadImage("Close"));
close.setFocusPainted(false);
close.setContentAreaFilled(false);
close.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
close.setRolloverIcon(JMTImageLoader.loadImage("CloseRO"));
close.setPressedIcon(JMTImageLoader.loadImage("CloseP"));
close.setVisible(true);
close.setToolTipText("Closes this window");
close.addActionListener(new ActionListener() {
// Fires a window closing event
public void actionPerformed(ActionEvent e) {
ResultsWindow.this.dispatchEvent(new WindowEvent(ResultsWindow.this, WindowEvent.WINDOW_CLOSING));
}
});
toolbar.add(close);
// Adds toolbar
this.getContentPane().add(toolbar, BorderLayout.SOUTH);
// Adds listener for progressBar
results.setProgressListener(new MeasureDefinition.ProgressListener() {
public void progressChanged(double progress, long elapsedTime) {
setProgressBar(progress, elapsedTime);
}
});
}
示例6: initGUI
import javax.swing.JProgressBar; //导入方法依赖的package包/类
/**
* Initialize allgui related stuff
*/
private void initGUI() {
// Sets default title, close operation and dimensions
this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
this.setTitle("Simulation Results...");
this.setIconImage(JMTImageLoader.loadImage("Results").getImage());
int width = 800, height = 500;
this.centerWindow(width, height);
// Creates all tabs
JTabbedPane mainPanel = new JTabbedPane();
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(mainPanel, BorderLayout.CENTER);
addTabPane(mainPanel, "Number of Customers", DESCRIPTION_QUEUELENGTHS, results.getQueueLengthMeasures());
addTabPane(mainPanel, "Queue Time", DESCRIPTION_QUEUETIMES, results.getQueueTimeMeasures());
addTabPane(mainPanel, "Residence Time", DESCRIPTION_RESIDENCETIMES, results.getResidenceTimeMeasures());
addTabPane(mainPanel, "Response Time", DESCRIPTION_RESPONSETIMES, results.getResponseTimeMeasures());
addTabPane(mainPanel, "Utilization", DESCRIPTION_UTILIZATIONS, results.getUtilizationMeasures());
addTabPane(mainPanel, "Throughput", DESCRIPTION_THROUGHPUTS, results.getThroughputMeasures());
addTabPane(mainPanel, "Drop Rate", DESCRIPTION_DROPRATE, results.getDropRateMeasures());
addTabPane(mainPanel, "System Response Time", DESCRIPTION_SYSTEMRESPONSETIMES, results.getSystemResponseTimeMeasures());
addTabPane(mainPanel, "System Throughput", DESCRIPTION_SYSTEMTHROUGHPUTS, results.getSystemThroughputMeasures());
addTabPane(mainPanel, "System Drop Rate", DESCRIPTION_DROPRATE, results.getSystemDropRateMeasures());
addTabPane(mainPanel, "System Number of Customers", DESCRIPTION_CUSTOMERNUMBERS, results.getCustomerNumberMeasures());
//Added by ASHANKA START
//Adds the System Power panel in the results window
addTabPane(mainPanel, "System Power", DESCRIPTION_SYSTEMPOWER, results.getSystemPowerMeasures());
//Added by ASHANKA STOP
addTabPane(mainPanel, SimulationDefinition.MEASURE_R_PER_SINK, DESCRIPTION_RESPONSETIME_SINK, results.getResponsetimePerSinkMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_X_PER_SINK, DESCRIPTION_THROUGHPUT_SINK, results.getThroughputPerSinkMeasures());
// Creates bottom toolbar
JToolBar toolbar = new JToolBar();
toolbar.setFloatable(false);
toolbar.setRollover(true);
start = new JButton();
toolbar.add(start);
start.setVisible(false);
pause = new JButton();
toolbar.add(pause);
pause.setVisible(false);
stop = new JButton();
toolbar.add(stop);
stop.setVisible(false);
// Adds a progress bar
progressBar = new JProgressBar();
progressBar.setStringPainted(true);
progressBar.setForeground(Color.BLUE);
setProgressBar(results.getProgressTime());
toolbar.add(progressBar);
// Add close window button
JButton close = new JButton();
close.setIcon(JMTImageLoader.loadImage("Close"));
close.setFocusPainted(false);
close.setContentAreaFilled(false);
close.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
close.setRolloverIcon(JMTImageLoader.loadImage("CloseRO"));
close.setPressedIcon(JMTImageLoader.loadImage("CloseP"));
close.setVisible(true);
close.setToolTipText("Closes this window");
close.addActionListener(new ActionListener() {
// Fires a window closing event
public void actionPerformed(ActionEvent e) {
ResultsWindow.this.dispatchEvent(new WindowEvent(ResultsWindow.this, WindowEvent.WINDOW_CLOSING));
}
});
toolbar.add(close);
// Adds toolbar
this.getContentPane().add(toolbar, BorderLayout.SOUTH);
// Adds listener for progressBar
results.setProgressTimeListener(new MeasureDefinition.ProgressTimeListener() {
public void timeChanged(double time) {
setProgressBar(time);
}
});
}
示例7: run
import javax.swing.JProgressBar; //导入方法依赖的package包/类
/**
* thread run method
*/
public void run() {
System.out.println("[ReceiveFileThread] :: started on port " + port + "file size : " + fileSize);
int progress = 0;
try {
ServerSocket ssock = new ServerSocket(port);
Socket socket = ssock.accept();
int size = 10000;
byte[] contents = new byte[size];
//Initialize the FileOutputStream to the output file's full path.
FileOutputStream fos = new FileOutputStream(filePath);
BufferedOutputStream bos = new BufferedOutputStream(fos);
InputStream is = socket.getInputStream();
//No of bytes read in one read() call
int bytesRead = 0;
//receiving file Message dialog window
JFrame recFileMessFrame = new JFrame("Recieving File");
recFileMessFrame.setBounds(500, 300, 350, 200);
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(9, 1));
//progress bar for recieved data
JProgressBar progressbar = new JProgressBar(0, 100);
progressbar.setSize(new Dimension(100, 15));
progressbar.setBackground(Color.white);
progressbar.setForeground(Color.gray);
//adding blank frame
for(int i = 0; i <= 2; i++){
panel.add(new JPanel());
}
JPanel progressPanel = new JPanel(new BorderLayout(5, 5));
JLabel progressLabel = new JLabel();
//adding progress label to progress panel
progressPanel.add(progressLabel);
panel.add(progressPanel);
//adding progress panel to main panel
panel.add(progressbar);
recFileMessFrame.add(panel);
recFileMessFrame.setVisible(true);
long recFileSize = 0;
while((bytesRead=is.read(contents))!=-1){
recFileSize += bytesRead;
//change the progressbar value
progressbar.setValue((progress = (int)((recFileSize*100)/fileSize)));
progressLabel.setText("File Recieved......." + progress + "%");
bos.write(contents, 0, bytesRead);
}
bos.flush();
recFileMessFrame.setVisible(false);
JOptionPane.showMessageDialog(null, "File recieved ! " + Paths.get(filePath).getFileName() );
socket.close();
ssock.close();
} catch(Exception e) {
System.out.println("[ReceiveFileThread] exception :: " + e);
e.printStackTrace();
}
System.out.println("[ReceiveFileThread] :: File saved successfully!");
}