下面列出了javax.swing.JLabel#setHorizontalTextPosition ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public TitleLabel(String text, final boolean showCloseIcon) {
setLayout(new GridBagLayout());
label = new JLabel(text);
label.setFont(new Font("Dialog", Font.BOLD, 11));
label.setHorizontalTextPosition(JLabel.RIGHT);
label.setHorizontalAlignment(JLabel.LEFT);
add(label, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
closeButton = new RolloverButton(SparkRes.getImageIcon(SparkRes.CLOSE_IMAGE));
if (showCloseIcon) {
add(closeButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
}
setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.lightGray));
}
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
Component c = tableCellRenderer.getTableCellRendererComponent(table,
value, isSelected, hasFocus, row, column);
SortableTableModel model = (SortableTableModel) table.getModel();
AstrosoftTableColumn modelColumn = model.getColumn(table
.convertColumnIndexToModel(column));
SortInfo sortInfo = model.getSortInfo();
if (sortInfo != null && sortInfo.getSortBy() == modelColumn) {
if (c instanceof JLabel) {
JLabel l = (JLabel) c;
l.setHorizontalTextPosition(JLabel.LEFT);
l.setIcon(((SortableTable) table).getSortImageIcon());
return l;
}
} else {
((JLabel) c).setIcon(null);
}
return c;
}
private static void addLabelComponent(String text,Component comp,Container container) {
JLabel label = new JLabel(text);
label.setAlignmentX(Component.LEFT_ALIGNMENT);
label.setHorizontalTextPosition(JLabel.LEFT);
container.add(label);
container.add(comp);
}
public JPanel getToaster() {
JPanel toaster = new JPanel();
toaster.setLayout(new GridBagLayout());
toaster.setBackground(Color.white);
JLabel newVoiceMail = new JLabel();
JLabel oldVoiceMail = new JLabel();
newVoiceMail.setFont(new Font("Dialog", Font.BOLD, 15));
newVoiceMail.setHorizontalAlignment(JLabel.CENTER);
newVoiceMail.setText("New: " + this.getUnread());
oldVoiceMail.setFont(new Font("Dialog", Font.PLAIN, 15));
oldVoiceMail.setHorizontalAlignment(JLabel.CENTER);
oldVoiceMail.setText("Old: " + this.getRead());
final JLabel phoneImage = new JLabel(SparkRes
.getImageIcon(SparkRes.MAIL_IMAGE_32x32));
phoneImage.setHorizontalAlignment(JLabel.CENTER);
phoneImage.setVerticalTextPosition(JLabel.BOTTOM);
phoneImage.setHorizontalTextPosition(JLabel.CENTER);
phoneImage.setText("Voice Mails");
phoneImage.setFont(new Font("Dialog", Font.BOLD, 16));
toaster.add(phoneImage, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(5, 10, 0, 10), 0, 0));
toaster.add(newVoiceMail, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0,
GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
new Insets(2, 0, 0, 0), 0, 0));
toaster.add(oldVoiceMail, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
new Insets(2, 0, 10, 0), 0, 0));
return toaster;
}
public OnPhone() {
setLayout(new BorderLayout());
final JPanel imagePanel = new JPanel();
imagePanel.setLayout(new GridBagLayout());
imagePanel.setBackground(Color.white);
// Handle Icon Label
iconLabel = new JLabel(SparkRes.getImageIcon(SparkRes.TELEPHONE_24x24));
iconLabel.setHorizontalAlignment(JLabel.CENTER);
iconLabel.setVerticalTextPosition(JLabel.BOTTOM);
iconLabel.setHorizontalTextPosition(JLabel.CENTER);
iconLabel.setFont(new Font("Dialog", Font.BOLD, 14));
iconLabel.setText(Res.getString("title.on.the.phone"));
// Handle Time Tracker
timeLabel = new TimeTrackingLabel(new Date(), this);
timeLabel.setOpaque(false);
timeLabel.setHorizontalAlignment(JLabel.CENTER);
timeLabel.setHorizontalTextPosition(JLabel.CENTER);
timeLabel.setFont(new Font("Dialog", Font.BOLD, 14));
// Add Icon Label
imagePanel.add(iconLabel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.7, GridBagConstraints.SOUTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
// Add Time Label
imagePanel.add(timeLabel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.3, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
add(imagePanel, BorderLayout.CENTER);
}
public ChatStatePanel(ChatState state, CharSequence nickname) {
setLayout(new FlowLayout(FlowLayout.LEFT, 1, 1));
JLabel label = new JLabel( Res.getString( state.name(), nickname.toString() ) );
label.setFont(new Font("Courier New", Font.PLAIN, 9));
label.setForeground(Color.gray);
label.setHorizontalTextPosition(JLabel.LEFT);
label.setVerticalTextPosition(JLabel.BOTTOM);
add( label );
}
private JPanel initBrowseDocsBar() {
JPanel panel = new JPanel(new GridLayout(1, 2));
panel.setOpaque(false);
panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 5));
JPanel left = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 2));
left.setOpaque(false);
JLabel label = new JLabel(FontUtils.elegantIconHtml("h", MessageUtils.getLocalizedMessage("documents.label.browse_doc_by_idx")));
label.setHorizontalTextPosition(JLabel.LEFT);
left.add(label);
docNumSpnr.setPreferredSize(new Dimension(100, 25));
docNumSpnr.addChangeListener(listeners::showCurrentDoc);
left.add(docNumSpnr);
maxDocsLbl.setText("in ? docs");
left.add(maxDocsLbl);
panel.add(left);
JPanel right = new JPanel(new FlowLayout(FlowLayout.TRAILING));
right.setOpaque(false);
copyDocValuesBtn.setText(FontUtils.elegantIconHtml("", MessageUtils.getLocalizedMessage("documents.buttont.copy_values")));
copyDocValuesBtn.setMargin(new Insets(5, 0, 5, 0));
copyDocValuesBtn.addActionListener(listeners::copySelectedOrAllStoredValues);
right.add(copyDocValuesBtn);
mltBtn.setText(FontUtils.elegantIconHtml("", MessageUtils.getLocalizedMessage("documents.button.mlt")));
mltBtn.setMargin(new Insets(5, 0, 5, 0));
mltBtn.addActionListener(listeners::mltSearch);
right.add(mltBtn);
addDocBtn.setText(FontUtils.elegantIconHtml("Y", MessageUtils.getLocalizedMessage("documents.button.add")));
addDocBtn.setMargin(new Insets(5, 0, 5, 0));
addDocBtn.addActionListener(listeners::showAddDocumentDialog);
right.add(addDocBtn);
panel.add(right);
return panel;
}
public PlayerDisplay(Mark myself, EntityFullJid opponent) {
_currentplayer = new JLabel(" | "+TTTRes.getString("ttt.display.current"));
_currentplayer.setHorizontalTextPosition(JLabel.LEFT);
setCurrentPlayer(Mark.X);
setLayout(new FlowLayout(FlowLayout.CENTER));
JLabel mylabel = new JLabel(TTTRes.getString("ttt.display.me"));
mylabel.setIcon(new ImageIcon(myself.getImage().getImage()
.getScaledInstance(16, 16, Image.SCALE_SMOOTH)));
mylabel.setHorizontalTextPosition(JLabel.LEFT);
Mark you;
if (myself == Mark.X)
you = Mark.O;
else
you = Mark.X;
Localpart name = opponent.getLocalpart();
JLabel yourlabel = new JLabel(" | "+name);
yourlabel.setIcon(new ImageIcon(you.getImage().getImage()
.getScaledInstance(16, 16, Image.SCALE_SMOOTH)));
yourlabel.setHorizontalTextPosition(JLabel.LEFT);
add(mylabel);
add(yourlabel);
add(_currentplayer);
}
private JLabel getCaptionLabel(final String text) {
final ImageIcon ii = MagicImages.getIcon(MagicIcon.BUSY16);
final JLabel lbl = new JLabel(ii);
lbl.setText(text);
lbl.setHorizontalAlignment(SwingConstants.LEFT);
lbl.setHorizontalTextPosition(SwingConstants.LEADING);
lbl.setOpaque(false);
lbl.setFont(lbl.getFont().deriveFont(Font.BOLD));
return lbl;
}
@Override
public void installUI(JComponent c) {
super.installUI(c);
c.addComponentListener(repaintComponentListener);
JLabel label = (JLabel) c;
label.setHorizontalTextPosition(SwingConstants.CENTER);
label.setIconTextGap(3);
}
protected void setupInstance(JLabel instance) {
super.setupInstance(instance);
instance.setText(text);
if (defaultIcon != null) instance.setIcon(defaultIcon.createInstance());
instance.setVerticalAlignment(verticalAlignment);
instance.setHorizontalAlignment(horizontalAlignment);
instance.setVerticalTextPosition(verticalTextPosition);
instance.setHorizontalTextPosition(horizontalTextPosition);
instance.setIconTextGap(iconTextGap);
}
private void addDetails(boolean repeatHost) {
if (repeatHost) {
addLabel(getString("Host"));
final JLabel hostLabel = new JLabel(javaInformations.getHost());
hostLabel.setFont(hostLabel.getFont().deriveFont(Font.BOLD));
addJLabel(hostLabel);
}
addLabel(getString("OS"));
final String osIconName = HtmlJavaInformationsReport
.getOSIconName(javaInformations.getOS());
final JLabel osLabel = new JLabel(javaInformations.getOS() + " ("
+ javaInformations.getAvailableProcessors() + ' ' + getString("coeurs") + ')');
if (osIconName != null) {
osLabel.setIcon(ImageIconCache.getImageIcon("servers/" + osIconName));
}
addJLabel(osLabel);
addLabel(getString("Java"));
addValue(javaInformations.getJavaVersion());
addLabel(getString("JVM"));
final JLabel jvmVersionLabel = new JLabel(javaInformations.getJvmVersion());
if (javaInformations.getJvmVersion().contains("Client")) {
jvmVersionLabel.setIcon(ImageIconCache.getImageIcon("alert.png"));
jvmVersionLabel.setHorizontalTextPosition(SwingConstants.LEFT);
jvmVersionLabel.setToolTipText(getString("Client_JVM"));
}
addJLabel(jvmVersionLabel);
addLabel(getString("PID"));
addValue(javaInformations.getPID());
final long unixOpenFileDescriptorCount = javaInformations.getUnixOpenFileDescriptorCount();
if (unixOpenFileDescriptorCount >= 0) {
final long unixMaxFileDescriptorCount = javaInformations
.getUnixMaxFileDescriptorCount();
addLabel(getString("nb_fichiers"));
addJLabel(toBarWithAlert(
integerFormat.format(unixOpenFileDescriptorCount) + " / "
+ integerFormat.format(unixMaxFileDescriptorCount),
javaInformations.getUnixOpenFileDescriptorPercentage(), null));
// writeGraph("fileDescriptors", integerFormat.format(unixOpenFileDescriptorCount));
}
writeServerInfoAndContextPath();
addLabel(getString("Demarrage"));
addValue(I18N.createDateAndTimeFormat().format(javaInformations.getStartDate()));
addLabel(getString("Arguments_JVM"));
addValue(javaInformations.getJvmArguments());
if (javaInformations.getSessionCount() >= 0) {
addLabel(getString("httpSessionsMeanAge"));
// writeGraph("httpSessionsMeanAge", integerFormat.format(javaInformations.getSessionMeanAgeInMinutes()));
addValue(integerFormat.format(javaInformations.getSessionMeanAgeInMinutes()));
}
writeTomcatInformations(javaInformations.getTomcatInformationsList());
writeMemoryInformations(javaInformations.getMemoryInformations());
// on considère que l'espace libre sur le disque dur est celui sur la partition du répertoire temporaire
addLabel(getString("Free_disk_space"));
addValue(integerFormat.format(javaInformations.getFreeDiskSpaceInTemp() / 1024 / 1024) + ' '
+ getString("Mo"));
addLabel(getString("Usable_disk_space"));
addValue(integerFormat.format(javaInformations.getUsableDiskSpaceInTemp() / 1024 / 1024)
+ ' ' + getString("Mo"));
writeDatabaseVersionAndDataSourceDetails();
addLabel(getString("Dependencies"));
writeDependencies();
makeGrid();
}
private JPanel createToolbar() {
JPanel p = new JPanel(new BorderLayout());
Box toolBox = Box.createHorizontalBox();
toolBox.add(Box.createRigidArea(new Dimension(scale(20), scale(60))));
toolBox.setBackground(ColorResource.getTitleColor());
toolBox.setOpaque(true);
JButton btn1 = createToolButton("ADD_URL", "tool_add.png");
btn1.setToolTipText(StringResource.get("MENU_ADD_URL"));
toolBox.add(btn1);
toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10))));
JButton btn2 = createToolButton("DELETE", "tool_del.png");
btn2.setToolTipText(StringResource.get("MENU_DELETE_DWN"));
toolBox.add(btn2);
toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10))));
JButton btn3 = createToolButton("PAUSE", "tool_pause.png");
btn3.setToolTipText(StringResource.get("MENU_PAUSE"));
toolBox.add(btn3);
toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10))));
JButton btn4 = createToolButton("RESUME", "tool_resume.png");
btn4.setToolTipText(StringResource.get("MENU_RESUME"));
toolBox.add(btn4);
toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10))));
JButton btn5 = createToolButton("OPTIONS", "tool_settings.png");
btn5.setToolTipText(StringResource.get("TITLE_SETTINGS"));
toolBox.add(btn5);
toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10))));
JButton btn6 = createToolButton("MENU_VIDEO_DWN", "tool_video.png");
btn6.setToolTipText(StringResource.get("MENU_VIDEO_DWN"));
toolBox.add(btn6);
toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10))));
JButton btn7 = createToolButton("MENU_MEDIA_CONVERTER", "tool_convert.png");
btn7.setToolTipText(StringResource.get("MENU_MEDIA_CONVERTER"));
toolBox.add(btn7);
toolBox.add(Box.createHorizontalGlue());
btnMonitoring = new JLabel(ImageResource.getIcon("on.png", 85, 21));
// btnMonitoring.setForeground(Color.WHITE);
btnMonitoring.setIconTextGap(scale(15));
btnMonitoring.putClientProperty("xdmbutton.norollover", "true");
// btnMonitoring.setBackground(ColorResource.getTitleColor());
btnMonitoring.setName("BROWSER_MONITORING");
btnMonitoring.setText(StringResource.get("BROWSER_MONITORING"));
btnMonitoring.setHorizontalTextPosition(JButton.LEADING);
btnMonitoring.setFont(FontResource.getBigFont());
btnMonitoring
.setIcon(Config.getInstance().isBrowserMonitoringEnabled() ? ImageResource.getIcon("on.png", 85, 21)
: ImageResource.getIcon("off.png", 85, 21));
btnMonitoring.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
toggleMonitoring((JLabel) e.getSource());
}
});
toolBox.add(btnMonitoring);
toolBox.add(Box.createRigidArea(new Dimension(scale(25), scale(10))));
p.add(toolBox);
return p;
}
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);
}
public Main_BottomToolbar() {
toolBar = new JToolBar();
toolBar.setAlignmentX(Component.LEFT_ALIGNMENT);
toolBar.setAlignmentY(Component.BOTTOM_ALIGNMENT);
toolBar.setPreferredSize(new Dimension(1200, 25));
toolBar.setMinimumSize(new Dimension(800, 25));
toolBar.setAutoscrolls(true);
toolBar.setFloatable(false);
toolBar.setRollover(true);
userIconLabel = new JLabel(new ImageIcon(getClass().getResource("/com/coder/hms/icons/main_user.png")));
toolBar.add(userIconLabel);
//initialize weather api for use.
liveWeather = new GetLiveWeather();
userLabel = new JLabel();
userLabel.setMaximumSize(new Dimension(160, 19));
userLabel.setFont(new Font("Microsoft Sans Serif", Font.PLAIN, 13));
userLabel.setHorizontalTextPosition(SwingConstants.CENTER);
userLabel.setHorizontalAlignment(SwingConstants.LEFT);
toolBar.add(userLabel);
toolBar.addSeparator();
dateIconLabel = new JLabel(new ImageIcon(getClass().getResource("/com/coder/hms/icons/main_calendar.png")));
toolBar.add(dateIconLabel);
dateLabel = new JLabel("");
dateLabel.setMaximumSize(new Dimension(160, 19));
dateLabel.setHorizontalTextPosition(SwingConstants.CENTER);
dateLabel.setHorizontalAlignment(SwingConstants.LEFT);
dateLabel.setFont(new Font("Microsoft Sans Serif", Font.PLAIN, 13));
toolBar.add(dateLabel);
toolBar.addSeparator();
currencyUsdIcon = new JLabel(new ImageIcon(getClass().getResource("/com/coder/hms/icons/main_currency.png")));
toolBar.add(currencyUsdIcon);
currencyUsdLabel = new JLabel("");
currencyUsdLabel.setMaximumSize(new Dimension(160, 19));
currencyUsdLabel.setHorizontalTextPosition(SwingConstants.CENTER);
currencyUsdLabel.setHorizontalAlignment(SwingConstants.LEFT);
currencyUsdLabel.setFont(new Font("Microsoft Sans Serif", Font.PLAIN, 13));
toolBar.add(currencyUsdLabel);
toolBar.addSeparator();
currencyEuroIcon = new JLabel(new ImageIcon(getClass().getResource("/com/coder/hms/icons/main_currency_euro.png")));
toolBar.add(currencyEuroIcon);
currencyEuroLabel = new JLabel("");
currencyEuroLabel.setMaximumSize(new Dimension(160, 19));
currencyEuroLabel.setHorizontalTextPosition(SwingConstants.CENTER);
currencyEuroLabel.setHorizontalAlignment(SwingConstants.LEFT);
currencyEuroLabel.setFont(new Font("Microsoft Sans Serif", Font.PLAIN, 13));
toolBar.add(currencyEuroLabel);
toolBar.addSeparator();
currencyPoundIcon = new JLabel(new ImageIcon(getClass().getResource("/com/coder/hms/icons/main_currency_pound.png")));
toolBar.add(currencyPoundIcon);
currencyPoundLabel = new JLabel("");
currencyPoundLabel.setMaximumSize(new Dimension(160, 19));
currencyPoundLabel.setHorizontalTextPosition(SwingConstants.CENTER);
currencyPoundLabel.setHorizontalAlignment(SwingConstants.LEFT);
currencyPoundLabel.setFont(new Font("Microsoft Sans Serif", Font.PLAIN, 13));
toolBar.add(currencyPoundLabel);
toolBar.addSeparator();
hotelIconLabel = new JLabel(new ImageIcon(getClass().getResource("/com/coder/hms/icons/login_hotel.png")));
toolBar.add(hotelIconLabel);
hotelNameLabel = new JLabel("");
hotelNameLabel.setMaximumSize(new Dimension(160, 19));
hotelNameLabel.setHorizontalTextPosition(SwingConstants.CENTER);
hotelNameLabel.setHorizontalAlignment(SwingConstants.LEFT);
hotelNameLabel.setFont(new Font("Microsoft Sans Serif", Font.PLAIN, 13));
toolBar.add(hotelNameLabel);
toolBar.addSeparator();
checkBox = new JCheckBox("");
checkBox.setToolTipText("Enable local weather");
checkBox.addItemListener(showWeather());
toolBar.add(checkBox);
weatherIconLabel = new JLabel(new ImageIcon(getClass().getResource("/com/coder/hms/icons/toolbar_weather.png")));
toolBar.add(weatherIconLabel);
weatherLabel = new JLabel("");
weatherLabel.setPreferredSize(new Dimension(160, 19));
weatherLabel.setHorizontalTextPosition(SwingConstants.CENTER);
weatherLabel.setHorizontalAlignment(SwingConstants.LEFT);
weatherLabel.setFont(new Font("Microsoft Sans Serif", Font.PLAIN, 13));
weatherLabel.setEnabled(false);
toolBar.add(weatherLabel);
}
/**
* Creates a panel which displays the process animation and a stop button.
*
* @return the created panel
*/
private JPanel createProgressPanel() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 0.0;
gbc.weighty = 0.0;
gbc.insets = new Insets(0, 5, 5, 5);
ImageIcon animation = SwingTools
.createImage(I18N.getGUILabel("io.dataimport.step.store_data_to_repository.animation"));
animationLabel = new JLabel(animation);
animationLabel.setHorizontalTextPosition(JLabel.CENTER);
animationLabel.setVerticalTextPosition(JLabel.BOTTOM);
gbc.gridy += 1;
panel.add(animationLabel, gbc);
stopButton = new JButton(
new ResourceAction(true, "io.dataimport.step.store_data_to_repository.stop_data_import_progress") {
private static final long serialVersionUID = 1L;
@Override
public void loggedActionPerformed(ActionEvent e) {
if (backgroundJob != null) {
setEnabled(false);
backgroundJob.cancel();
isImportCancelled = true;
}
}
});
gbc.insets = new Insets(40, 5, 5, 5);
gbc.gridy += 1;
panel.add(stopButton, gbc);
return panel;
}
public ProgressPanel() {
super();
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
int width = 400;
progressTotal = new SafeJProgressBar();
progressTotal.setAlignmentX(CENTER_ALIGNMENT);
progressTotal.setMaximumSize(
new Dimension(width, progressTotal.getPreferredSize().height));
progressTotal.setIndeterminate(true);
message = new JLabel("");
message.setIcon(new ProgressIcon(48, 48));
message.setHorizontalTextPosition(SwingConstants.RIGHT);
message.setHorizontalAlignment(SwingConstants.CENTER);
message.setAlignmentX(CENTER_ALIGNMENT);
dlMsg = new JLabel("Downloading CREOLE Plugin...");
dlMsg.setIcon(new DownloadIcon(48, 48));
dlMsg.setHorizontalTextPosition(SwingConstants.RIGHT);
dlMsg.setHorizontalAlignment(SwingConstants.CENTER);
dlMsg.setAlignmentX(CENTER_ALIGNMENT);
dlMsg.setVisible(false);
partProgress = new JPanel();
partProgress.setLayout(new BoxLayout(partProgress, BoxLayout.Y_AXIS));
scroller = new JScrollPane(partProgress);
scroller.setAlignmentX(CENTER_ALIGNMENT);
scroller.setMaximumSize(
new Dimension(width, progressTotal.getPreferredSize().height*6));
scroller.setPreferredSize(
new Dimension(width, progressTotal.getPreferredSize().height*6));
add(Box.createVerticalGlue());
add(message);
add(Box.createVerticalStrut(5));
add(progressTotal);
add(Box.createVerticalStrut(10));
add(dlMsg);
add(Box.createVerticalStrut(5));
add(scroller);
add(Box.createVerticalGlue());
addComponentListener(this);
}
private JPanel initSearchResultsHeaderPane() {
JPanel panel = new JPanel(new GridLayout(1, 2));
panel.setOpaque(false);
JLabel label = new JLabel(FontUtils.elegantIconHtml("", MessageUtils.getLocalizedMessage("search.label.results")));
label.setHorizontalTextPosition(JLabel.LEFT);
label.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
panel.add(label);
JPanel resultsInfo = new JPanel(new FlowLayout(FlowLayout.TRAILING));
resultsInfo.setOpaque(false);
resultsInfo.setOpaque(false);
JLabel totalLabel = new JLabel(MessageUtils.getLocalizedMessage("search.label.total"));
resultsInfo.add(totalLabel);
totalHitsLbl.setText("?");
resultsInfo.add(totalHitsLbl);
prevBtn.setText(FontUtils.elegantIconHtml("D"));
prevBtn.setMargin(new Insets(5, 0, 5, 0));
prevBtn.setPreferredSize(new Dimension(30, 20));
prevBtn.setEnabled(false);
prevBtn.addActionListener(listeners::prevPage);
resultsInfo.add(prevBtn);
startLbl.setText("0");
resultsInfo.add(startLbl);
resultsInfo.add(new JLabel(" ~ "));
endLbl.setText("0");
resultsInfo.add(endLbl);
nextBtn.setText(FontUtils.elegantIconHtml("E"));
nextBtn.setMargin(new Insets(3, 0, 3, 0));
nextBtn.setPreferredSize(new Dimension(30, 20));
nextBtn.setEnabled(false);
nextBtn.addActionListener(listeners::nextPage);
resultsInfo.add(nextBtn);
JSeparator sep = new JSeparator(JSeparator.VERTICAL);
sep.setPreferredSize(new Dimension(5, 1));
resultsInfo.add(sep);
delBtn.setText(FontUtils.elegantIconHtml("", MessageUtils.getLocalizedMessage("search.button.del_all")));
delBtn.setMargin(new Insets(5, 0, 5, 0));
delBtn.setEnabled(false);
delBtn.addActionListener(listeners::confirmDeletion);
resultsInfo.add(delBtn);
panel.add(resultsInfo, BorderLayout.CENTER);
return panel;
}
/**
* Constructs a panel.
*
* @param application the application name.
* @param version the version.
* @param copyright the copyright statement.
* @param info other info.
* @param logo an optional logo.
*/
public AboutPanel(final String application,
final String version,
final String copyright,
final String info,
final Image logo) {
setLayout(new BorderLayout());
final JPanel textPanel = new JPanel(new GridLayout(4, 1, 0, 4));
final JPanel appPanel = new JPanel();
final Font f1 = new Font("Dialog", Font.BOLD, 14);
final JLabel appLabel = RefineryUtilities.createJLabel(application, f1, Color.black);
appLabel.setHorizontalTextPosition(SwingConstants.CENTER);
appPanel.add(appLabel);
final JPanel verPanel = new JPanel();
final Font f2 = new Font("Dialog", Font.PLAIN, 12);
final JLabel verLabel = RefineryUtilities.createJLabel(version, f2, Color.black);
verLabel.setHorizontalTextPosition(SwingConstants.CENTER);
verPanel.add(verLabel);
final JPanel copyrightPanel = new JPanel();
final JLabel copyrightLabel = RefineryUtilities.createJLabel(copyright, f2, Color.black);
copyrightLabel.setHorizontalTextPosition(SwingConstants.CENTER);
copyrightPanel.add(copyrightLabel);
final JPanel infoPanel = new JPanel();
final JLabel infoLabel = RefineryUtilities.createJLabel(info, f2, Color.black);
infoLabel.setHorizontalTextPosition(SwingConstants.CENTER);
infoPanel.add(infoLabel);
textPanel.add(appPanel);
textPanel.add(verPanel);
textPanel.add(copyrightPanel);
textPanel.add(infoPanel);
add(textPanel);
if (logo != null) {
final JPanel imagePanel = new JPanel(new BorderLayout());
imagePanel.add(new javax.swing.JLabel(new javax.swing.ImageIcon(logo)));
imagePanel.setBorder(BorderFactory.createLineBorder(Color.black));
final JPanel imageContainer = new JPanel(new BorderLayout());
imageContainer.add(imagePanel, BorderLayout.NORTH);
add(imageContainer, BorderLayout.WEST);
}
}
public DialPanel() {
setLayout(new GridBagLayout());
JPanel imagePanel = new JPanel();
imagePanel.setLayout(new BorderLayout());
imagePanel.setBackground(Color.white);
iconLabel = new JLabel(SparkRes.getImageIcon(SparkRes.TELEPHONE_24x24));
iconLabel.setHorizontalAlignment(JLabel.CENTER);
iconLabel.setVerticalTextPosition(JLabel.BOTTOM);
iconLabel.setHorizontalTextPosition(JLabel.CENTER);
imagePanel.add(iconLabel, BorderLayout.CENTER);
iconLabel.setFont(new Font("Dialog", Font.BOLD, 14));
dialPanel.setLayout(new GridBagLayout());
JLabel dialLabel = new JLabel();
dialPanel.add(dialLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.WEST, new Insets(5, 5, 5, 5), 0, 0));
dialField = new JTextField();
dialPanel.add(dialField, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
dialButton = new JButton("");
dialPanel.add(dialButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.WEST, new Insets(5, 5, 5, 5), 0, 0));
add(imagePanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
add(dialPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
iconLabel.setText(Res.getString("title.waiting.to.call"));
ResourceUtils.resButton(dialButton, Res.getString("label.dial"));
ResourceUtils.resLabel(dialLabel, dialField, Res.getString("label.number") + ":");
}