下面列出了javax.swing.JProgressBar#HORIZONTAL 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public Dimension getPreferredSize( JComponent c ) {
Dimension size = super.getPreferredSize( c );
if( progressBar.isStringPainted() || clientPropertyBoolean( c, PROGRESS_BAR_LARGE_HEIGHT, false ) ) {
// recalculate progress height/width to make it smaller
Insets insets = progressBar.getInsets();
FontMetrics fm = progressBar.getFontMetrics( progressBar.getFont() );
if( progressBar.getOrientation() == JProgressBar.HORIZONTAL )
size.height = Math.max( fm.getHeight() + insets.top + insets.bottom, getPreferredInnerHorizontal().height );
else
size.width = Math.max( fm.getHeight() + insets.left + insets.right, getPreferredInnerVertical().width );
}
return size;
}
@Override
protected void paintDeterminate(Graphics g, JComponent c) {
Insets b = progressBar.getInsets(); // area for border
int barRectWidth = progressBar.getWidth() - (b.right + b.left);
int barRectHeight = progressBar.getHeight() - (b.top + b.bottom);
if (barRectWidth <= 0 || barRectHeight <= 0) {
return;
}
// amount of progress to draw
int amountFull = getAmountFull(b, barRectWidth, barRectHeight);
Graphics2D g2 = (Graphics2D) g;
g2.setColor(ColorResource.getSelectionColor());
if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
g2.fillRect(0, 0, amountFull, c.getHeight());
} else { // VERTICAL
}
// Deal with possible text painting
// if (progressBar.isStringPainted()) {
// paintString(g, b.left, b.top, barRectWidth, barRectHeight,
// amountFull, b);
// }
}
@Override
public int getBaseline(JComponent c, int width, int height) {
super.getBaseline(c, width, height);
if (progressBar.isStringPainted() && progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
SeaGlassContext context = getContext(c);
Font font = context.getStyle().getFont(context);
FontMetrics metrics = progressBar.getFontMetrics(font);
context.dispose();
return (height - metrics.getAscent() - metrics.getDescent()) / 2 + metrics.getAscent();
}
return -1;
}
private Rectangle calcBounds(JProgressBar pBar) {
boundsRect.x = 0;
boundsRect.y = 0;
boundsRect.width = pBar.getWidth();
boundsRect.height = pBar.getHeight();
if (pBar.getOrientation() == JProgressBar.HORIZONTAL) {
boundsRect.y = (boundsRect.height - trackThickness) / 2;
boundsRect.height = Math.min(boundsRect.height, trackThickness);
} else {
boundsRect.x = (boundsRect.width - trackThickness) / 2;
boundsRect.width = Math.min(boundsRect.width, trackThickness);
}
return boundsRect;
}
@Override
public void paint( Graphics g, JComponent c ) {
Insets insets = progressBar.getInsets();
int x = insets.left;
int y = insets.top;
int width = progressBar.getWidth() - (insets.right + insets.left);
int height = progressBar.getHeight() - (insets.top + insets.bottom);
if( width <= 0 || height <= 0 )
return;
boolean horizontal = (progressBar.getOrientation() == JProgressBar.HORIZONTAL);
int arc = clientPropertyBoolean( c, PROGRESS_BAR_SQUARE, false )
? 0
: Math.min( UIScale.scale( this.arc ), horizontal ? height : width );
FlatUIUtils.setRenderingHints( (Graphics2D) g );
// paint track
RoundRectangle2D.Float trackShape = new RoundRectangle2D.Float( x, y, width, height, arc, arc );
g.setColor( progressBar.getBackground() );
((Graphics2D)g).fill( trackShape );
// paint progress
if( progressBar.isIndeterminate() ) {
boxRect = getBox( boxRect );
if( boxRect != null ) {
g.setColor( progressBar.getForeground() );
((Graphics2D)g).fill( new RoundRectangle2D.Float( boxRect.x, boxRect.y,
boxRect.width, boxRect.height, arc, arc ) );
}
if( progressBar.isStringPainted() )
paintString( g, x, y, width, height, 0, insets );
} else {
int amountFull = getAmountFull( insets, width, height );
RoundRectangle2D.Float progressShape = horizontal
? new RoundRectangle2D.Float( c.getComponentOrientation().isLeftToRight() ? x : x + (width - amountFull),
y, amountFull, height, arc, arc )
: new RoundRectangle2D.Float( x, y + (height - amountFull), width, amountFull, arc, arc );
g.setColor( progressBar.getForeground() );
if( amountFull < (horizontal ? height : width) ) {
// special painting for low amounts to avoid painting outside of track
Area area = new Area( trackShape );
area.intersect( new Area( progressShape ) );
((Graphics2D)g).fill( area );
} else
((Graphics2D)g).fill( progressShape );
if( progressBar.isStringPainted() )
paintString( g, x, y, width, height, amountFull, insets );
}
}
@Override
protected void paintIndeterminate(Graphics g, JComponent c)
{
if (!(g instanceof Graphics2D))
{
return;
}
// area for border
Insets b = progressBar.getInsets();
int barRectWidth = progressBar.getWidth() - (b.right + b.left);
int barRectHeight = progressBar.getHeight() - (b.top + b.bottom);
if (barRectWidth <= 0 || barRectHeight <= 0)
{
return;
}
boolean isHorizontal = (progressBar.getOrientation() == JProgressBar.HORIZONTAL);
Graphics2D g2 = (Graphics2D)g;
paintProgressBarBg(g2, 0, 0, progressBar.getWidth(), progressBar.getHeight(), isHorizontal);
// Paint the bouncing box.
boxRect = getBox(boxRect);
if (boxRect != null)
{
paintProgressBarCell(g2, boxRect.x, boxRect.y, boxRect.width, boxRect.height, isHorizontal);
}
// 父类中该处调用的是私有的paintString方法。
// 通读方法后发现实际上有做兼容处理,所以这样调用并不会影响原有效果
// The parent class calls the private paintString method.
// Read through the method and found that in fact do compatible
// processing, so this call will not affect the original effect
if (progressBar.isStringPainted())
{
if (progressBar.getOrientation() == JProgressBar.HORIZONTAL)
{
paintString(g2, b.left, b.top, barRectWidth, barRectHeight, 0, b);
}
else
{
paintString(g2, b.left, b.top, barRectWidth, barRectHeight, 0, b);
}
}
}
@Override
protected void paintDeterminate(Graphics g, JComponent c)
{
if (!(g instanceof Graphics2D))
{
return;
}
// area for border
Insets b = progressBar.getInsets();
int barRectWidth = progressBar.getWidth() - (b.right + b.left);
int barRectHeight = progressBar.getHeight() - (b.top + b.bottom);
if (barRectWidth <= 0 || barRectHeight <= 0)
{
return;
}
// Progress of the current progress bar loading, if the horizontal
// progress bar, return the width value, otherwise the height value
int amountFull = getAmountFull(b, barRectWidth, barRectHeight);
Graphics2D g2 = (Graphics2D) g;
boolean isHorizontal = (progressBar.getOrientation() == JProgressBar.HORIZONTAL);
paintProgressBarBg(g2, b.left, b.top, barRectWidth, barRectHeight, isHorizontal);
// 以下的处理主要是为了让单元进度和背景保持一定的间距,这样比较美观
// The following is mainly to deal with the progress of the unit and the
// background to maintain a certain distance, so beautiful
int cellWidth = barRectWidth;
int cellHeight = barRectHeight;
int startx = b.left;
int starty = b.top;
if (progressBar.getOrientation() == JProgressBar.HORIZONTAL)
{
cellWidth = cellWidth - cellBarInsets.left - cellBarInsets.right;
cellHeight = cellHeight - cellBarInsets.top - cellBarInsets.bottom;
// 因为起始坐标和背景的起始坐标不一样,如果仍按原宽度绘制,会导进度条超出背景宽度
// Because the starting coordinates and the coordinates of the background is not the same.
// if still drawing the original width,will lead the progress bar beyond the background width.
amountFull = (amountFull < cellWidth ? amountFull : cellWidth);
cellWidth = amountFull;
// 重新计算起始坐标
// Recalculate start coordinates
startx = b.left + cellBarInsets.left;
starty = b.top + cellBarInsets.top;
}
else
{
cellWidth = cellWidth - cellBarInsets.top - cellBarInsets.bottom;
cellHeight = cellHeight - cellBarInsets.left - cellBarInsets.right;
amountFull = (amountFull < cellHeight ? amountFull : cellHeight);
cellHeight = amountFull;
startx = b.left + cellBarInsets.top;
starty = b.top + barRectHeight - amountFull - cellBarInsets.top;
}
if(amountFull > 0)
{
paintProgressBarCell(g2, startx, starty, cellWidth, cellHeight, isHorizontal);
}
// Deal with possible text painting
if (progressBar.isStringPainted())
{
paintString(g, b.left, b.top, barRectWidth, barRectHeight, amountFull, b);
}
}
/**
* Creates the progress panel.
*/
public void createProgressPanel() {
getDemoPanel().setLayout(new BorderLayout());
JPanel textWrapper = new JPanel(new BorderLayout());
// textWrapper.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
textWrapper.setAlignmentX(LEFT_ALIGNMENT);
progressTextArea = new MyTextArea();
progressTextArea.getAccessibleContext().setAccessibleName(getString("ProgressBarDemo.accessible_text_area_name"));
progressTextArea.getAccessibleContext().setAccessibleName(getString("ProgressBarDemo.accessible_text_area_description"));
textWrapper.add(new JScrollPane(progressTextArea), BorderLayout.CENTER);
getDemoPanel().add(textWrapper, BorderLayout.CENTER);
JPanel progressPanel = new JPanel();
getDemoPanel().add(progressPanel, BorderLayout.SOUTH);
progressBar = new JProgressBar(JProgressBar.HORIZONTAL, 0, text.length()) {
public Dimension getPreferredSize() {
return new Dimension(270, super.getPreferredSize().height);
// return new Dimension(super.getPreferredSize().width,300 );
}
};
// progressBar.setForeground(Color.red);
// progressBar.setBackground(Color.pink);
// progressBar.setOrientation(JProgressBar.VERTICAL);//* add by Jack Jiang for test
progressBar.getAccessibleContext().setAccessibleName(getString("ProgressBarDemo.accessible_text_loading_progress"));
progressBar.setStringPainted(true);//* add by Jack Jiang for test
// progressBar.setPreferredSize(new Dimension(800,25));
// progressPanel.add(progressBar);
// progressPanel.add(createLoadButton());
// progressPanel.add(createStopButton());
JPanel p1 = new JPanel();
p1.add(progressBar);
p1.add(createLoadButton());
p1.add(createStopButton());
progressPanel.add(p1);
JProgressBar pbIndeterminate = new JProgressBar()
{
public Dimension getPreferredSize() {
// return new Dimension(15,300 );
return new Dimension(200, 15);
}
}
;
// pbIndeterminate.setForeground(Color.black);
//when the task of (initially) unknown length begins:
pbIndeterminate.setIndeterminate(true);
// pbIndeterminate.setOrientation(JProgressBar.VERTICAL);//* add by Jack Jiang for test
progressPanel.add(pbIndeterminate);
}
/**
* All purpose paint method that should do the right thing for almost all
* linear, determinate progress bars. By setting a few values in the
* defaults table, things should work just fine to paint your progress bar.
* Naturally, override this if you are making a circular or semi-circular
* progress bar.
*
* @param g the g
* @param c the c
* @see #paintIndeterminate
* @since 1.4
*/
protected void paintDeterminate(Graphics g, JComponent c)
{
if (!(g instanceof Graphics2D))
{
return;
}
//* 如果用户作了自定义颜色设置则使用父类方法来实现绘制,否则BE LNF中没法支持这些设置哦
if(isUseParentPaint())
{
super.paintDeterminate(g, c);
return;
}
Insets b = progressBar.getInsets(); // area for border
int barRectWidth = progressBar.getWidth() - (b.right + b.left);
int barRectHeight = progressBar.getHeight() - (b.top + b.bottom);
//* add by Jack Jiang 2012-06-20 START
//绘制进度条的背景
paintProgressBarBgImpl(progressBar.getOrientation() == JProgressBar.HORIZONTAL
, g, b, barRectWidth, barRectHeight);
//* add by Jack Jiang 2012-06-20 END
if (barRectWidth <= 0 || barRectHeight <= 0)
{
return;
}
int amountFull = getAmountFull(b, barRectWidth, barRectHeight);
Graphics2D g2 = (Graphics2D) g;
g2.setColor(progressBar.getForeground());//在BE LNF中本属性设置目前没有意义哦,因为用的都是n9图
if (progressBar.getOrientation() == JProgressBar.HORIZONTAL)
{
if (WinUtils.isLeftToRight(c))
{
paintProgressBarContentImpl(true, g,b.left, b.top
,amountFull, barRectHeight, -1);
}
// TODO 以下代码未经测试
else
{
paintProgressBarContentImpl(true, g,barRectWidth+b.left, b.top
, barRectWidth + b.left - amountFull, barRectHeight, -1);
}
}
else
{ // VERTICAL
paintProgressBarContentImpl(false, g, b.left, b.top + barRectHeight - amountFull
, barRectWidth, amountFull, barRectHeight);
}
// Deal with possible text painting
if (progressBar.isStringPainted())
{
paintString(g, b.left, b.top, barRectWidth, barRectHeight,amountFull, b);
}
}
/**
* All purpose paint method that should do the right thing for all
* linear bouncing-box progress bars.
* Override this if you are making another kind of
* progress bar.
*
* @param g the g
* @param c the c
* @see #paintDeterminate
* @since 1.4
*/
protected void paintIndeterminate(Graphics g, JComponent c)
{
if (!(g instanceof Graphics2D))
{
return;
}
//* 如果用户作了自定义颜色设置则使用父类方法来实现绘制,否则BE LNF中没法支持这些设置哦
if(isUseParentPaint())
{
super.paintIndeterminate(g, c);
return;
}
Insets b = progressBar.getInsets(); // area for border
int barRectWidth = progressBar.getWidth() - (b.right + b.left);
int barRectHeight = progressBar.getHeight() - (b.top + b.bottom);
if (barRectWidth <= 0 || barRectHeight <= 0) {
return;
}
//* add by Jack Jiang 2012-06-20 START
//绘制进度条的背景
paintProgressBarBgImpl(progressBar.getOrientation() == JProgressBar.HORIZONTAL, g,b,barRectWidth, barRectHeight);
//* add by Jack Jiang 2012-06-20 END
Graphics2D g2 = (Graphics2D)g;
// Paint the bouncing box.
boxRect = getBox(boxRect);
if (boxRect != null)
{
g2.setColor(progressBar.getForeground());//BE LNF中,目前本颜色设置无意义哦,因使用的都是N9图
//由Jack Jiang修改
// g2.fillRect(boxRect.x, boxRect.y, boxRect.width, boxRect.height);
paintProgressBarContentImpl(progressBar.getOrientation() == JProgressBar.HORIZONTAL
, g,boxRect.x, boxRect.y, boxRect.width, boxRect.height, boxRect.height);//水平时最后一个参数无意义哦
}
// Deal with possible text painting
if (progressBar.isStringPainted())
{
if (progressBar.getOrientation() == JProgressBar.HORIZONTAL)
{
paintString(g2, b.left, b.top, barRectWidth, barRectHeight,boxRect.x, boxRect.width, b);
}
else
{
paintString(g2, b.left, b.top, barRectWidth, barRectHeight,boxRect.y, boxRect.height, b);
}
}
}
public TiledHorizontalImageProgressBar(int min, int max, ImageIds imageId, ImageInfoReader imageInfoReader) {
super(JProgressBar.HORIZONTAL, min, max);
this.tileImage = getTiledImage(imageId, imageInfoReader);
changeUI();
}
protected void paint(SeaGlassContext context, Graphics g) {
JProgressBar pBar = (JProgressBar) context.getComponent();
Insets pBarInsets = pBar.getInsets();
Rectangle bounds = calcBounds(pBar);
// Save away the track bounds.
savedRect.setBounds(bounds);
// Subtract out any insets for the progress indicator.
bounds.x += pBarInsets.left + progressPadding;
bounds.y += pBarInsets.top + progressPadding;
bounds.width -= pBarInsets.left + pBarInsets.right + progressPadding + progressPadding;
bounds.height -= pBarInsets.top + pBarInsets.bottom + progressPadding + progressPadding;
int size = 0;
boolean isFinished = false;
if (!pBar.isIndeterminate()) {
double percentComplete = pBar.getPercentComplete();
if (percentComplete == 1.0) {
isFinished = true;
} else if (percentComplete > 0.0) {
if (pBar.getOrientation() == JProgressBar.HORIZONTAL) {
size = (int) (percentComplete * bounds.width);
} else { // JProgressBar.VERTICAL
size = (int) (percentComplete * bounds.height);
}
}
}
// Create a translucent intermediate image in which we can perform soft
// clipping.
GraphicsConfiguration gc = ((Graphics2D) g).getDeviceConfiguration();
BufferedImage img = gc.createCompatibleImage(bounds.width, bounds.height, Transparency.TRANSLUCENT);
Graphics2D g2d = img.createGraphics();
// Clear the image so all pixels have zero alpha
g2d.setComposite(AlphaComposite.Clear);
g2d.fillRect(0, 0, bounds.width, bounds.height);
// Render our clip shape into the image. Enable antialiasing to achieve
// a soft clipping effect.
g2d.setComposite(AlphaComposite.Src);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(bgFillColor);
CornerSize cornerSize = pBar.getOrientation() == JProgressBar.HORIZONTAL ? CornerSize.ROUND_HEIGHT : CornerSize.ROUND_WIDTH;
g2d.fill(shapeGenerator.createRoundRectangle(0, 0, bounds.width, bounds.height, cornerSize));
// Use SrcAtop, which effectively uses the alpha value as a coverage
// value for each pixel stored in the destination. At the edges, the
// antialiasing of the rounded rectangle gives us the desired soft
// clipping effect.
g2d.setComposite(AlphaComposite.SrcAtop);
// We need to redraw the background, otherwise the interior is
// completely white.
context.getPainter().paintProgressBarBackground(context, g2d, savedRect.x - bounds.x, savedRect.y - bounds.y, savedRect.width,
savedRect.height, pBar.getOrientation());
paintProgressIndicator(context, g2d, bounds.width, bounds.height, size, isFinished);
// Dispose of the image graphics and copy our intermediate image to the
// main graphics.
g2d.dispose();
g.drawImage(img, bounds.x, bounds.y, null);
if (pBar.isStringPainted()) {
paintText(context, g, pBar.getString());
}
}
/**
* Construct the emote loading/caching progress panel that sits on the bottom of the Emoji tab of the Control Window
*
* @param chat
* The chat panel, for repainting after a load
* @param emojiControlPanel
* Used by the reload button
*/
public EmojiLoadProgressPanel(ChatPanel chatPanel, final ControlPanelEmoji emojiControlPanel)
{
this.chat = chatPanel;
this.emojiControlPanel = emojiControlPanel;
this.workerTaskListLoad = new ConcurrentLinkedQueue<EmojiWorker>();
this.workerTaskListCache = new ConcurrentLinkedQueue<EmojiWorker>();
this.currentWorker = null;
this.emojiLogBox = new LogBox();
this.bar = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
this.percentValue = new JLabel(EMPTY_VALUE_TEXT);
this.percentValue.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
this.cancelButton = new JButton("Cancel");
this.cancelButton.setToolTipText("Cancel any emoji or badge loading or caching currently running or queued to run");
this.manualButton = new JButton("Load/Cache");
this.manualButton.setToolTipText("Manually load and or cache all emoji and badges");
this.resetButton = new JButton("Reset");
this.resetButton.setToolTipText("Reset all work done loading and or caching emoji and badges");
handleButtonEnables();
ActionListener bal = new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
JButton source = (JButton) e.getSource();
if (cancelButton.equals(source))
{
if (currentWorker != null)
{
reset();
}
}
else if (resetButton.equals(source))
{
workerTaskListLoad.clear();
workerTaskListCache.clear();
emojiConfig.resetWorkCompleted();
log("Reset all loaded and or cached emoji");
chat.repaint();
}
else if (manualButton.equals(source))
{
reset();
emojiControlPanel.loadAndRunEmojiWork();
}
handleButtonEnables();
}
};
this.cancelButton.addActionListener(bal);
this.resetButton.addActionListener(bal);
this.manualButton.addActionListener(bal);
setLayout(new GridBagLayout());
GridBagConstraints gbc = ControlPanelBase.getGbc();
gbc.fill = GridBagConstraints.NONE;
gbc.gridx = 0;
gbc.gridy = 0;
JPanel workPanel = new JPanel(new GridBagLayout());
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 1.0;
workPanel.add(this.bar, gbc);
gbc.gridx++;
gbc.weightx = 0.0;
gbc.fill = GridBagConstraints.VERTICAL;
workPanel.add(percentValue, gbc);
gbc.gridx++;
workPanel.add(this.cancelButton, gbc);
gbc.gridx++;
workPanel.add(this.manualButton, gbc);
gbc.gridx++;
workPanel.add(this.resetButton, gbc);
gbc = ControlPanelBase.getGbc();
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
add(emojiLogBox, gbc);
gbc.gridy++;
gbc.weighty = 0.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
add(workPanel, gbc);
}
@Override
public void stateChanged(ChangeEvent e) {
SubstanceCoreUtilities.testComponentStateChangeThreadingViolation(progressBar);
//if (displayTimeline != null) { //Main Change - this should be first
// displayTimeline.abort();
//}
int currValue = progressBar.getValue();
int span = progressBar.getMaximum() - progressBar.getMinimum();
int barRectWidth = progressBar.getWidth() - 2 * margin;
int barRectHeight = progressBar.getHeight() - 2 * margin;
int totalPixels = (progressBar.getOrientation() == JProgressBar.HORIZONTAL) ? barRectWidth
: barRectHeight;
int pixelDelta = (span <= 0) ? 0 : (currValue - displayedValue)
* totalPixels / span;
/*displayTimeline = new Timeline(progressBar);
displayTimeline.addPropertyToInterpolate(Timeline
.<Integer>property("displayedValue").from(displayedValue)
.to(currValue).setWith(new TimelinePropertyBuilder.PropertySetter<Integer>() {
@Override
public void set(Object obj, String fieldName,
Integer value) {
displayedValue = value;
progressBar.repaint();
}
}));
displayTimeline.setEase(new Spline(0.4f));
AnimationConfigurationManager.getInstance().configureTimeline(
displayTimeline);*/
boolean isInCellRenderer = (SwingUtilities.getAncestorOfClass(
CellRendererPane.class, progressBar) != null);
//if (false) {//currValue > 0 && !isInCellRenderer && Math.abs(pixelDelta) > 5) {
// displayTimeline.play();
//} else {
displayedValue = currValue;
progressBar.repaint();
//}
}
public void generalInit(Container c) {
c.setLayout(new BorderLayout());
main = new JPanel();
bkd = new ImageBackgroundPanel();
c.add(bkd, "Center");
//c.add(main, "Center");
//main.add(bckgd);
jbLoadImage = new JButton("Load Images");
jbLoadImage.addActionListener(this);
jbCropImage = new JButton("Crop Images");
jbCropImage.addActionListener(this);
jbCropImage.setEnabled(false);
jbTrain = new JButton("Compute Eigen Vectors");
jbTrain.setEnabled(false);
jbTrain.addActionListener(this);
jbProbe = new JButton("Identify Face");
jbProbe.addActionListener(this);
jbProbe.setEnabled(false);
jbDisplayFeatureSpace = new JButton("Display Result Chart");
jbDisplayFeatureSpace.addActionListener(this);
jbDisplayFeatureSpace.setEnabled(false);
//jlClassthreshold = new JLabel("Factor");
// jtfClassthreshold = new JTextField(""+classthreshold);
//jbClassthreshold = new JButton("Update Threshold");
// jbClassthreshold.addActionListener(this);
faceCandidate = new FaceItem();
faceCandidate.setBorder(BorderFactory.createRaisedBevelBorder());
jlAverageFace = new JLabel();
jlAverageFace.setVerticalTextPosition(JLabel.BOTTOM);
jlAverageFace.setHorizontalTextPosition(JLabel.CENTER);
jlStatus = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
jlStatus.setBorder(BorderFactory.createEtchedBorder());
jlStatus.setStringPainted(true);
jlist = new JList();
main.setLayout(new BorderLayout());
JPanel right = new JPanel();
jbLoadImage.setFont(new Font("Verdana", 30, 18));
//jbCropImage.setFont(new Font("Cambria", 20, 28));
jbTrain.setFont(new Font("Verdana", 30, 18));
jbProbe.setFont(new Font("Verdana", 30, 18));
jbDisplayFeatureSpace.setFont(new Font("Verdana", 30, 18));
right.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.PAGE_START;
gbc.gridy = 1;
gbc.gridwidth = 4;
gbc.ipady = 30;
gbc.ipadx = 110;
gbc.insets = new Insets(10, 20, 10, 20);
//JLabel myp = new JLabel("Project ID: PW13A01");
//myp.setFont(new Font("Tahoma", 20, 20));
//right.add(myp);
//gbc.gridy = 3;
try {
String imPath = System.getProperty("user.dir");
imPath = imPath.replace('\\', '/');
BufferedImage myPicture = ImageIO.read(new File(imPath + "/src/src/face.png"));
JLabel picLabel = new JLabel(new ImageIcon(myPicture));
//picLabel.setSize(250, 220);
right.add(picLabel);
} catch (IOException ex) {
System.out.println("Image face.png missing\n" + ex);
}
right.add(jbLoadImage, gbc);
//gbc.gridy = 1; right.add(jbCropImage, gbc);
gbc.gridy = 4;
right.add(jbTrain, gbc);
gbc.gridy = 6;
right.add(jbProbe, gbc);
gbc.gridy = 8;
right.add(jbDisplayFeatureSpace, gbc);
//gbc.gridy = 5; gbc.gridwidth = 1; right.add(jlClassthreshold, gbc);
// gbc.gridy = 5; gbc.gridwidth = 1; right.add(jtfClassthreshold, gbc);
// gbc.gridy = 6; gbc.gridwidth = 2; right.add(jbClassthreshold, gbc);
/* gbc.gridy = 7;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.VERTICAL | GridBagConstraints.HORIZONTAL;
right.add(jlAverageFace, gbc); */
c.add(right, BorderLayout.EAST);
//Mark
}