KLALB3.2
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package org.kne.cloud.klalb.uitool;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.font.TextAttribute;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JTextField;
|
||||
import java.awt.BorderLayout;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import org.kne.cloud.network.klalb.ui.UIEnv;
|
||||
|
||||
public class ButtonSettingItem extends SettingItem {
|
||||
protected JButton button;
|
||||
|
||||
|
||||
public JButton getButton() {
|
||||
return button;
|
||||
}
|
||||
public ButtonSettingItem(String text,int w,int h) {
|
||||
this(text,UIEnv.getFont().deriveFont((float) 15.0),w,h);
|
||||
}
|
||||
/**
|
||||
* @wbp.parser.constructor
|
||||
*/
|
||||
public ButtonSettingItem(String text, Font deriveFont,int w,int h) {
|
||||
super(text,deriveFont,w,h);
|
||||
button = new JButton(UIEnv.getRsb().getString("clicktoopen")+">>");
|
||||
button.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
button.setFont(button.getFont().deriveFont(Map.of(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON)));
|
||||
getPanel().add(button, BorderLayout.EAST);
|
||||
button.setBorder(null);
|
||||
button.setOpaque(false);
|
||||
button.setBackground(new Color(0,0,0,0));
|
||||
label.setForeground(Color.GRAY);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.kne.cloud.klalb.uitool;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import org.kne.cloud.klalb.uitool.SettingItem;
|
||||
import org.kne.cloud.network.klalb.ui.UIEnv;
|
||||
|
||||
public class CheckBoxSettingItem extends SettingItem {
|
||||
protected JCheckBox button;
|
||||
|
||||
|
||||
public JCheckBox getCheckBox() {
|
||||
return button;
|
||||
}
|
||||
public CheckBoxSettingItem(String text,int w,int h) {
|
||||
this(text,UIEnv.getFont().deriveFont((float) 15.0),w,h);
|
||||
}
|
||||
/**
|
||||
* @wbp.parser.constructor
|
||||
*/
|
||||
public CheckBoxSettingItem(String text, Font deriveFont,int w,int h) {
|
||||
super(text,deriveFont,w,h);
|
||||
button = new JCheckBox();
|
||||
button.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
getPanel().add(button, BorderLayout.CENTER);
|
||||
button.setBorder(null);
|
||||
button.setOpaque(false);
|
||||
button.setBackground(new Color(0,0,0,0));
|
||||
label.setForeground(Color.GRAY);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.kne.cloud.klalb.uitool;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import javax.swing.JTextField;
|
||||
import java.awt.BorderLayout;
|
||||
import javax.swing.SwingConstants;
|
||||
import org.kne.cloud.network.klalb.ui.UIEnv;
|
||||
import javax.swing.JComboBox;
|
||||
|
||||
public class ComboSettingItem extends SettingItem {
|
||||
|
||||
|
||||
private JComboBox comboBox;
|
||||
public JComboBox getComboBox() {
|
||||
return comboBox;
|
||||
}
|
||||
public ComboSettingItem(String text,int w,int h) {
|
||||
this(text,UIEnv.getFont().deriveFont((float) 15.0),w, h);
|
||||
}
|
||||
/**
|
||||
* @wbp.parser.constructor
|
||||
*/
|
||||
public ComboSettingItem(String text, Font deriveFont,int w,int h) {
|
||||
super(text,deriveFont,w,h);
|
||||
label.setForeground(Color.GRAY);
|
||||
|
||||
comboBox = new JComboBox();
|
||||
comboBox.setOpaque(false);
|
||||
getPanel().add(comboBox, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package org.kne.cloud.klalb.uitool;
|
||||
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFrame;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.TextArea;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Panel;
|
||||
import java.awt.Window;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import org.kne.cloud.network.klalb.ui.UIEnv;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import java.awt.Label;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.TextField;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Random;
|
||||
|
||||
public class CrashReport extends JDialog{
|
||||
private JLabel name;
|
||||
private TextField type;
|
||||
private JTextArea stack;
|
||||
public CrashReport(Window parent ,boolean modal) {
|
||||
super(parent);
|
||||
setModal(modal);
|
||||
setTitle("错误");
|
||||
setIconImage(UIEnv.getIcon());
|
||||
setSize(500, 400);
|
||||
setLocationRelativeTo(null);
|
||||
stack = new JTextArea();
|
||||
stack.setEditable(false);
|
||||
getContentPane().add(new JScrollPane(stack), BorderLayout.CENTER);
|
||||
|
||||
Panel panel = new Panel();
|
||||
panel.setPreferredSize(new Dimension(500, 100));
|
||||
getContentPane().add(panel, BorderLayout.NORTH);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("");
|
||||
lblNewLabel.setIcon(new ImageIcon(CrashReport.class.getResource("/assets/error.jpg")));
|
||||
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel.setBounds(10, 10, 80, 80);
|
||||
panel.add(lblNewLabel);
|
||||
|
||||
name = new JLabel("");
|
||||
name.setFont(new Font("宋体", Font.PLAIN, 30));
|
||||
name.setForeground(Color.RED);
|
||||
name.setBounds(96, 10, 378, 33);
|
||||
panel.add(name);
|
||||
|
||||
type = new TextField();
|
||||
type.setEditable(false);
|
||||
type.setBounds(96, 67, 378, 23);
|
||||
panel.add(type);
|
||||
|
||||
fny = new JLabel("...?");
|
||||
fny.setFont(new Font("MS Song", Font.PLAIN, 10));
|
||||
getContentPane().add(fny, BorderLayout.SOUTH);
|
||||
}
|
||||
String []s=new String[]{"鎴戜滑鍥㈤槦鍙湁涓�涓▼搴忓憳",
|
||||
"鎯虫洿鏂帮紝娌¢棬",
|
||||
"鎴戜滑鐨勬湇鍔″櫒鐪熺殑鏄笓涓氣�滃埌瀹垛�濅簡",
|
||||
"杩炴帴宸蹭涪澶憋細涓嶅幓鍋氬惎鍔ㄥ櫒灏卞幓濂宠锛屼笉鍘诲コ瑁呭氨鍘诲仛鍚姩鍣�",
|
||||
"鍦熻眴鏈嶅姟鍣ㄥ張鍙戣娊浜�"
|
||||
};
|
||||
private JLabel fny;
|
||||
public void report(Throwable e,String t){
|
||||
e.printStackTrace();
|
||||
name.setText(t);
|
||||
type.setText(e.getClass().getName());
|
||||
StringWriter sw=new StringWriter();
|
||||
PrintWriter pw=new PrintWriter(sw);
|
||||
e.printStackTrace(pw);
|
||||
pw.close();
|
||||
stack.setText(sw.toString());fny.setText(s[new Random().nextInt(s.length)]);
|
||||
setVisible(true);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
package org.kne.cloud.klalb.uitool;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* The Metal implementation of ProgressBarUI.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is
|
||||
* appropriate for short term storage or RMI between applications running
|
||||
* the same version of Swing. As of 1.4, support for long term storage
|
||||
* of all JavaBeans™
|
||||
* has been added to the <code>java.beans</code> package.
|
||||
* Please see {@link java.beans.XMLEncoder}.
|
||||
*
|
||||
* @author Michael C. Albers
|
||||
*/
|
||||
public class KNEProgressBarUI extends BasicProgressBarUI {
|
||||
|
||||
// private Rectangle innards;
|
||||
// private Rectangle box;
|
||||
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new KNEProgressBarUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a bit of special highlighting on the progress bar.
|
||||
* The core painting is deferred to the BasicProgressBar's
|
||||
* <code>paintDeterminate</code> method.
|
||||
* @since 1.4
|
||||
*/
|
||||
public void paintDeterminate(Graphics g, JComponent c) {
|
||||
super.paintDeterminate(g,c);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a bit of special highlighting on the progress bar
|
||||
* and bouncing box.
|
||||
* The core painting is deferred to the BasicProgressBar's
|
||||
* <code>paintIndeterminate</code> method.
|
||||
* @since 1.4
|
||||
*/
|
||||
public void paintIndeterminate(Graphics g, JComponent c) {
|
||||
super.paintIndeterminate(g, c);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package org.kne.cloud.klalb.uitool;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Image;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.ListModel;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import javax.swing.SwingConstants;
|
||||
import org.kne.cloud.network.klalb.ui.UIEnv;
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
public abstract class ListSettingItem<T> extends SettingItem {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected JList<T> list;
|
||||
|
||||
private Consumer<T> storeRecall;
|
||||
public JList<T> getList() {
|
||||
return list;
|
||||
}
|
||||
public ListSettingItem(String text,int w,int h,XDefaultListModel<T>lm) {
|
||||
this(text,UIEnv.getFont().deriveFont((float) 15.0),w,h,lm);
|
||||
}
|
||||
/**
|
||||
* @wbp.parser.constructor
|
||||
*/
|
||||
public ListSettingItem(String text, Font deriveFont,int w,int h,XDefaultListModel<T> lm) {
|
||||
super(text,deriveFont,w,h);
|
||||
list = new JList<T>(lm);
|
||||
JScrollPane js=new JScrollPane(list);
|
||||
js.getViewport().setOpaque(false);
|
||||
js.setOpaque(false);
|
||||
js.setBackground(new Color(0,0,0,0));
|
||||
getPanel().add(js, BorderLayout.CENTER);
|
||||
list.setBorder(null);
|
||||
list.setOpaque(false);
|
||||
list.setBackground(new Color(0,0,0,0));
|
||||
label.setForeground(Color.GRAY);
|
||||
|
||||
Dimension dss=new Dimension(25,25);
|
||||
JButton jbt3x=new JButton();
|
||||
jbt3x.setToolTipText(UIEnv.getRsb().getString("add"));
|
||||
try {
|
||||
jbt3x.setIcon(new ImageIcon(ImageIO .read(ListSettingItem.class.getResourceAsStream("/assets/add.png")).getScaledInstance(dss.width-2, dss.height-2, Image.SCALE_SMOOTH)));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
jbt3x.setSize(dss);
|
||||
jbt3x.setPreferredSize(dss);
|
||||
jbt3x.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
T x=createEmpty();
|
||||
runEdit(x);
|
||||
}
|
||||
});
|
||||
JButton jbedit=new JButton();
|
||||
jbedit.setToolTipText(UIEnv.getRsb().getString("edit"));
|
||||
try {
|
||||
jbedit.setIcon(new ImageIcon(ImageIO .read(ListSettingItem.class.getResourceAsStream("/assets/edit-fill.png")).getScaledInstance(dss.width-2, dss.height-2, Image.SCALE_SMOOTH)));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
jbedit.setSize(dss);
|
||||
jbedit.setPreferredSize(dss);
|
||||
jbedit.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
T val=list.getSelectedValue();
|
||||
if(val!=null)
|
||||
runEdit(val);
|
||||
}
|
||||
});
|
||||
|
||||
JButton jbt4x=new JButton();
|
||||
jbt4x.setToolTipText(UIEnv.getRsb().getString("remove"));
|
||||
try {
|
||||
jbt4x.setIcon(new ImageIcon(ImageIO .read(ListSettingItem.class.getResourceAsStream("/assets/delete-bin-fill.png")).getScaledInstance(dss.width-2, dss.height-2, Image.SCALE_SMOOTH)));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
jbt4x.setSize(dss);
|
||||
jbt4x.setPreferredSize(dss);
|
||||
jbt4x.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int v=list.getSelectedIndex();
|
||||
if(v>=0) {
|
||||
lm.remove(v);
|
||||
if(storeRecall!=null)
|
||||
storeRecall.accept(list.getSelectedValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
JPanel jp=new JPanel();
|
||||
jp.setPreferredSize(new Dimension(30, h));
|
||||
FlowLayout flowLayout = (FlowLayout) jp.getLayout();
|
||||
flowLayout.setAlignment(FlowLayout.TRAILING);
|
||||
jp.setOpaque(false);
|
||||
getPanel().add(jp,BorderLayout.EAST);
|
||||
jp.add(jbt3x);
|
||||
jp.add(jbedit);
|
||||
jp.add(jbt4x);
|
||||
}
|
||||
abstract protected void runEdit(T val) ;
|
||||
abstract protected T createEmpty() ;
|
||||
public void doAdd(T v) {
|
||||
boolean b=true;
|
||||
for (int i = 0; i < list.getModel().getSize(); i++) {
|
||||
if(list.getModel().getElementAt(i)==v) {
|
||||
b=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(b)
|
||||
((XDefaultListModel<T>) list.getModel()).addElement(v);
|
||||
repaint();
|
||||
if(storeRecall!=null)
|
||||
storeRecall.accept(list.getSelectedValue());
|
||||
}
|
||||
public Consumer<T> getStoreRecall() {
|
||||
return storeRecall;
|
||||
}
|
||||
public void setStoreRecall(Consumer<T> storeRecall) {
|
||||
this.storeRecall = storeRecall;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package org.kne.cloud.klalb.uitool;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import javax.swing.*;
|
||||
|
||||
import org.kne.cloud.network.klalb.ui.UIEnv;
|
||||
|
||||
public class PathInput extends JDialog {
|
||||
private JTextField textField;
|
||||
private boolean checkfile=true;
|
||||
private boolean isdir=false;
|
||||
protected JFileChooser jfc;
|
||||
private Consumer<File> al;
|
||||
public Consumer<File> getAl() {
|
||||
return al;
|
||||
}
|
||||
|
||||
public void setAl(Consumer<File> al) {
|
||||
this.al = al;
|
||||
}
|
||||
|
||||
public PathInput(Window d){
|
||||
super(d);
|
||||
setResizable(false);
|
||||
setModal(true);
|
||||
setSize(500, 110);
|
||||
setLocationRelativeTo(d);
|
||||
|
||||
setIconImage(UIEnv.getIcon());
|
||||
|
||||
textField = new JTextField();
|
||||
textField.setPreferredSize(new Dimension(400,80));
|
||||
textField.setFont(new Font("微软雅黑", Font.PLAIN, 12));
|
||||
getContentPane().add(textField, BorderLayout.CENTER);
|
||||
textField.setColumns(10);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
getContentPane().add(panel, BorderLayout.SOUTH);
|
||||
|
||||
JButton btnok = new JButton(UIEnv.getRsb().getString("ok"));
|
||||
UIEnv.defbut(btnok);
|
||||
panel.add(btnok);
|
||||
btnok.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
File x=new File(textField.getText());
|
||||
if(!checkfile){
|
||||
if(isdir){
|
||||
x.mkdirs();
|
||||
}else{
|
||||
try {
|
||||
x.createNewFile();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
al.accept(x);
|
||||
setVisible(false);
|
||||
return;
|
||||
}
|
||||
if(x.exists()){
|
||||
al.accept(x);
|
||||
setVisible(false);
|
||||
}else{
|
||||
JOptionPane.showMessageDialog(PathInput.this, UIEnv.getRsb().getString("filenotexist"), UIEnv.getRsb().getString("error"), JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
});
|
||||
JButton btnNewButton_1 = new JButton(UIEnv.getRsb().getString("browse"));
|
||||
UIEnv.defbut(btnNewButton_1);
|
||||
panel.add(btnNewButton_1);
|
||||
btnNewButton_1.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(jfc.showOpenDialog(PathInput.this)==jfc.APPROVE_OPTION){
|
||||
textField.setText(jfc.getSelectedFile().toString());
|
||||
}
|
||||
/*File f=choose.get();
|
||||
if(f!=null){
|
||||
textField.setText(f.toString());
|
||||
}*/
|
||||
}
|
||||
});
|
||||
JButton button = new JButton(UIEnv.getRsb().getString("cancel"));
|
||||
UIEnv.defbut(button);
|
||||
panel.add(button);
|
||||
button.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setVisible(false);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
jfc=new JFileChooser();
|
||||
jfc.setMultiSelectionEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
public JTextField getTextField() {
|
||||
return textField;
|
||||
}
|
||||
|
||||
public JFileChooser getJfc() {
|
||||
return jfc;
|
||||
}
|
||||
|
||||
public boolean isCheckfile() {
|
||||
return checkfile;
|
||||
}
|
||||
public void setCheckfile(boolean checkfile) {
|
||||
this.checkfile = checkfile;
|
||||
}
|
||||
public boolean isIsdir() {
|
||||
return isdir;
|
||||
}
|
||||
public void setIsdir(boolean isdir) {
|
||||
this.isdir = isdir;
|
||||
if(isdir) {
|
||||
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
}else {
|
||||
jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.kne.cloud.klalb.uitool;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import org.kne.cloud.klalb.uitool.SettingItem;
|
||||
import org.kne.cloud.network.klalb.ui.UIEnv;
|
||||
|
||||
public class RadioButtonSettingItem extends SettingItem {
|
||||
protected JRadioButton button;
|
||||
|
||||
|
||||
public JRadioButton getRadioButton() {
|
||||
return button;
|
||||
}
|
||||
public RadioButtonSettingItem(String text,int w,int h) {
|
||||
this(text,UIEnv.getFont().deriveFont((float) 15.0),w,h);
|
||||
}
|
||||
/**
|
||||
* @wbp.parser.constructor
|
||||
*/
|
||||
public RadioButtonSettingItem(String text, Font deriveFont,int w,int h) {
|
||||
super(text,deriveFont,w,h);
|
||||
button = new JRadioButton();
|
||||
button.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
getPanel().add(button, BorderLayout.CENTER);
|
||||
button.setBorder(null);
|
||||
button.setOpaque(false);
|
||||
button.setBackground(new Color(0,0,0,0));
|
||||
label.setForeground(Color.GRAY);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package org.kne.cloud.klalb.uitool;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
import org.kne.cloud.network.klalb.ui.UIEnv;
|
||||
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
public class SettingItem extends JPanel {
|
||||
protected JLabel label;
|
||||
private JPanel sub;
|
||||
|
||||
public JLabel getLabel() {
|
||||
return label;
|
||||
}
|
||||
public SettingItem(String text,int w,int h){
|
||||
this(text,UIEnv.getFont().deriveFont(15.0f),w,h);
|
||||
}
|
||||
public JPanel getPanel(){
|
||||
return sub;
|
||||
}
|
||||
/**
|
||||
* @wbp.parser.constructor
|
||||
*/
|
||||
public SettingItem(String text,Font f,int w,int h){
|
||||
setSize(w, h);
|
||||
setPreferredSize(new Dimension(w, h));
|
||||
setBackground(UIEnv.getHalfTransparentDefaultColor());
|
||||
SpringLayout springLayout = new SpringLayout();
|
||||
setLayout(springLayout);
|
||||
//setOpaque(false);
|
||||
sub = new JPanel();
|
||||
springLayout.putConstraint(SpringLayout.NORTH, sub, 0, SpringLayout.NORTH, this);
|
||||
springLayout.putConstraint(SpringLayout.WEST, sub, 20, SpringLayout.WEST, this);
|
||||
springLayout.putConstraint(SpringLayout.SOUTH, sub, 0, SpringLayout.SOUTH, this);
|
||||
springLayout.putConstraint(SpringLayout.EAST, sub, -20, SpringLayout.EAST, this);
|
||||
sub.setOpaque(false);
|
||||
add(sub);
|
||||
sub.setLayout(new BorderLayout(5, 0));
|
||||
label = new JLabel(text);
|
||||
label.setFont(f);
|
||||
sub.add(label, BorderLayout.WEST);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.kne.cloud.klalb.uitool;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import java.awt.BorderLayout;
|
||||
import javax.swing.SwingConstants;
|
||||
import org.kne.cloud.network.klalb.ui.UIEnv;
|
||||
|
||||
public class TextAreaSettingItem extends SettingItem {
|
||||
protected JTextArea textarea;
|
||||
|
||||
|
||||
public JTextArea getTextArea() {
|
||||
return textarea;
|
||||
}
|
||||
public TextAreaSettingItem(String text,int w,int h) {
|
||||
this(text,UIEnv.getFont().deriveFont((float) 15.0),w,h);
|
||||
}
|
||||
/**
|
||||
* @wbp.parser.constructor
|
||||
*/
|
||||
public TextAreaSettingItem(String text, Font deriveFont,int w,int h) {
|
||||
super(text,deriveFont,w,h);
|
||||
textarea = new JTextArea();
|
||||
JScrollPane sp=new JScrollPane(textarea);
|
||||
sp.getViewport().setOpaque(false);
|
||||
sp.setOpaque(false);
|
||||
sp.setBackground(new Color(0,0,0,0));
|
||||
getPanel().add(sp, BorderLayout.CENTER);
|
||||
textarea.setBorder(null);
|
||||
textarea.setOpaque(false);
|
||||
textarea.setBackground(new Color(0,0,0,0));
|
||||
//textarea.setBackground(UIEnv.getDefaultcolor());
|
||||
label.setForeground(Color.GRAY);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.kne.cloud.klalb.uitool;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.font.TextAttribute;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JTextField;
|
||||
import java.awt.BorderLayout;
|
||||
import javax.swing.SwingConstants;
|
||||
import org.kne.cloud.network.klalb.ui.UIEnv;
|
||||
|
||||
public class TextButtonSettingItem extends SettingItem {
|
||||
protected JTextField textField;
|
||||
protected JButton button;
|
||||
|
||||
public JButton getButton() {
|
||||
return button;
|
||||
}
|
||||
public JTextField getTextField() {
|
||||
return textField;
|
||||
}
|
||||
public TextButtonSettingItem(String text,int w,int h) {
|
||||
this(text,UIEnv.getFont().deriveFont((float) 15.0),w,h);
|
||||
}
|
||||
/**
|
||||
* @wbp.parser.constructor
|
||||
*/
|
||||
public TextButtonSettingItem(String text, Font deriveFont,int w,int h) {
|
||||
super(text,deriveFont,w,h);
|
||||
BorderLayout borderLayout = (BorderLayout) getPanel().getLayout();
|
||||
textField = new JTextField();
|
||||
textField.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
getPanel().add(textField, BorderLayout.CENTER);
|
||||
textField.setColumns(10);
|
||||
textField.setBorder(null);
|
||||
textField.setOpaque(false);
|
||||
textField.setBackground(new Color(0,0,0,0));
|
||||
label.setForeground(Color.GRAY);
|
||||
|
||||
button = new JButton();
|
||||
getPanel().add(button, BorderLayout.EAST);
|
||||
button.setFont(button.getFont().deriveFont(Map.of(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON)));
|
||||
button.setBorder(null);
|
||||
button.setOpaque(false);
|
||||
button.setBackground(new Color(0,0,0,0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.kne.cloud.klalb.uitool;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import javax.swing.JTextField;
|
||||
import java.awt.BorderLayout;
|
||||
import javax.swing.SwingConstants;
|
||||
import org.kne.cloud.network.klalb.ui.UIEnv;
|
||||
|
||||
public class TextSettingItem extends SettingItem {
|
||||
protected JTextField textField;
|
||||
|
||||
|
||||
public JTextField getTextField() {
|
||||
return textField;
|
||||
}
|
||||
public TextSettingItem(String text,int w,int h) {
|
||||
this(text,UIEnv.getFont().deriveFont((float) 15.0),w,h);
|
||||
}
|
||||
/**
|
||||
* @wbp.parser.constructor
|
||||
*/
|
||||
public TextSettingItem(String text, Font deriveFont,int w,int h) {
|
||||
super(text,deriveFont,w,h);
|
||||
textField = new JTextField();
|
||||
textField.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
getPanel().add(textField, BorderLayout.CENTER);
|
||||
textField.setColumns(10);
|
||||
textField.setBorder(null);
|
||||
textField.setOpaque(false);
|
||||
textField.setBackground(new Color(0,0,0,0));
|
||||
label.setForeground(Color.GRAY);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.kne.cloud.klalb.uitool;
|
||||
|
||||
import javax.swing.ListModel;
|
||||
import javax.swing.event.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* The abstract definition for the data model that provides
|
||||
* a <code>List</code> with its contents.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is
|
||||
* appropriate for short term storage or RMI between applications running
|
||||
* the same version of Swing. As of 1.4, support for long term storage
|
||||
* of all JavaBeans
|
||||
* has been added to the <code>java.beans</code> package.
|
||||
* Please see {@link java.beans.XMLEncoder}.
|
||||
*
|
||||
* @param <E> the type of the elements of this model
|
||||
*
|
||||
* @author Hans Muller
|
||||
* @since 1.2
|
||||
*/
|
||||
@SuppressWarnings("serial") // Same-version serialization only
|
||||
public abstract class XAbstractListModel<E> implements ListModel<E>, Serializable
|
||||
{
|
||||
/**
|
||||
* The listener list.
|
||||
*/
|
||||
protected EventListenerList listenerList = new EventListenerList();
|
||||
|
||||
/**
|
||||
* Constructor for subclasses to call.
|
||||
*/
|
||||
protected XAbstractListModel() {}
|
||||
|
||||
/**
|
||||
* Adds a listener to the list that's notified each time a change
|
||||
* to the data model occurs.
|
||||
*
|
||||
* @param l the <code>ListDataListener</code> to be added
|
||||
*/
|
||||
public void addListDataListener(ListDataListener l) {
|
||||
listenerList.add(ListDataListener.class, l);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes a listener from the list that's notified each time a
|
||||
* change to the data model occurs.
|
||||
*
|
||||
* @param l the <code>ListDataListener</code> to be removed
|
||||
*/
|
||||
public void removeListDataListener(ListDataListener l) {
|
||||
listenerList.remove(ListDataListener.class, l);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of all the list data listeners
|
||||
* registered on this <code>AbstractListModel</code>.
|
||||
*
|
||||
* @return all of this model's <code>ListDataListener</code>s,
|
||||
* or an empty array if no list data listeners
|
||||
* are currently registered
|
||||
*
|
||||
* @see #addListDataListener
|
||||
* @see #removeListDataListener
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
public ListDataListener[] getListDataListeners() {
|
||||
return listenerList.getListeners(ListDataListener.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <code>AbstractListModel</code> subclasses must call this method
|
||||
* <b>after</b>
|
||||
* one or more elements of the list change. The changed elements
|
||||
* are specified by the closed interval index0, index1 -- the endpoints
|
||||
* are included. Note that
|
||||
* index0 need not be less than or equal to index1.
|
||||
*
|
||||
* @param source the <code>ListModel</code> that changed, typically "this"
|
||||
* @param index0 one end of the new interval
|
||||
* @param index1 the other end of the new interval
|
||||
* @see EventListenerList
|
||||
* @see XDefaultListModel
|
||||
*/
|
||||
protected void fireContentsChanged(Object source, int index0, int index1)
|
||||
{
|
||||
Object[] listeners = listenerList.getListenerList();
|
||||
ListDataEvent e = null;
|
||||
|
||||
for (int i = listeners.length - 2; i >= 0; i -= 2) {
|
||||
if (listeners[i] == ListDataListener.class) {
|
||||
if (e == null) {
|
||||
e = new ListDataEvent(source, ListDataEvent.CONTENTS_CHANGED, index0, index1);
|
||||
}
|
||||
((ListDataListener)listeners[i+1]).contentsChanged(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <code>AbstractListModel</code> subclasses must call this method
|
||||
* <b>after</b>
|
||||
* one or more elements are added to the model. The new elements
|
||||
* are specified by a closed interval index0, index1 -- the enpoints
|
||||
* are included. Note that
|
||||
* index0 need not be less than or equal to index1.
|
||||
*
|
||||
* @param source the <code>ListModel</code> that changed, typically "this"
|
||||
* @param index0 one end of the new interval
|
||||
* @param index1 the other end of the new interval
|
||||
* @see EventListenerList
|
||||
* @see XDefaultListModel
|
||||
*/
|
||||
protected void fireIntervalAdded(Object source, int index0, int index1)
|
||||
{
|
||||
Object[] listeners = listenerList.getListenerList();
|
||||
ListDataEvent e = null;
|
||||
|
||||
for (int i = listeners.length - 2; i >= 0; i -= 2) {
|
||||
if (listeners[i] == ListDataListener.class) {
|
||||
if (e == null) {
|
||||
e = new ListDataEvent(source, ListDataEvent.INTERVAL_ADDED, index0, index1);
|
||||
}
|
||||
((ListDataListener)listeners[i+1]).intervalAdded(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <code>AbstractListModel</code> subclasses must call this method
|
||||
* <b>after</b> one or more elements are removed from the model.
|
||||
* <code>index0</code> and <code>index1</code> are the end points
|
||||
* of the interval that's been removed. Note that <code>index0</code>
|
||||
* need not be less than or equal to <code>index1</code>.
|
||||
*
|
||||
* @param source the <code>ListModel</code> that changed, typically "this"
|
||||
* @param index0 one end of the removed interval,
|
||||
* including <code>index0</code>
|
||||
* @param index1 the other end of the removed interval,
|
||||
* including <code>index1</code>
|
||||
* @see EventListenerList
|
||||
* @see XDefaultListModel
|
||||
*/
|
||||
protected void fireIntervalRemoved(Object source, int index0, int index1)
|
||||
{
|
||||
Object[] listeners = listenerList.getListenerList();
|
||||
ListDataEvent e = null;
|
||||
|
||||
for (int i = listeners.length - 2; i >= 0; i -= 2) {
|
||||
if (listeners[i] == ListDataListener.class) {
|
||||
if (e == null) {
|
||||
e = new ListDataEvent(source, ListDataEvent.INTERVAL_REMOVED, index0, index1);
|
||||
}
|
||||
((ListDataListener)listeners[i+1]).intervalRemoved(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all the objects currently registered as
|
||||
* <code><em>Foo</em>Listener</code>s
|
||||
* upon this model.
|
||||
* <code><em>Foo</em>Listener</code>s
|
||||
* are registered using the <code>add<em>Foo</em>Listener</code> method.
|
||||
* <p>
|
||||
* You can specify the <code>listenerType</code> argument
|
||||
* with a class literal, such as <code><em>Foo</em>Listener.class</code>.
|
||||
* For example, you can query a list model
|
||||
* <code>m</code>
|
||||
* for its list data listeners
|
||||
* with the following code:
|
||||
*
|
||||
* <pre>ListDataListener[] ldls = (ListDataListener[])(m.getListeners(ListDataListener.class));</pre>
|
||||
*
|
||||
* If no such listeners exist,
|
||||
* this method returns an empty array.
|
||||
*
|
||||
* @param <T> the type of {@code EventListener} class being requested
|
||||
* @param listenerType the type of listeners requested;
|
||||
* this parameter should specify an interface
|
||||
* that descends from <code>java.util.EventListener</code>
|
||||
* @return an array of all objects registered as
|
||||
* <code><em>Foo</em>Listener</code>s
|
||||
* on this model,
|
||||
* or an empty array if no such
|
||||
* listeners have been added
|
||||
* @exception ClassCastException if <code>listenerType</code> doesn't
|
||||
* specify a class or interface that implements
|
||||
* <code>java.util.EventListener</code>
|
||||
*
|
||||
* @see #getListDataListeners
|
||||
*
|
||||
* @since 1.3
|
||||
*/
|
||||
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
|
||||
return listenerList.getListeners(listenerType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.kne.cloud.klalb.uitool;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JButton;
|
||||
|
||||
public class XButton extends JButton{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public XButton() {
|
||||
super();
|
||||
super.setContentAreaFilled(false);
|
||||
}
|
||||
|
||||
public XButton(Action a) {
|
||||
super(a);
|
||||
super.setContentAreaFilled(false);
|
||||
}
|
||||
|
||||
public XButton(Icon icon) {
|
||||
super(icon);
|
||||
super.setContentAreaFilled(false);
|
||||
}
|
||||
|
||||
public XButton(String text, Icon icon) {
|
||||
super(text, icon);
|
||||
super.setContentAreaFilled(false);
|
||||
}
|
||||
|
||||
public XButton(String text) {
|
||||
super(text);
|
||||
super.setContentAreaFilled(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
g.setColor(getBackground());
|
||||
g.fillRoundRect(0, 0, getWidth()-1, getHeight()-1, 20, 20);
|
||||
super.paint(g);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,584 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package org.kne.cloud.klalb.uitool;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.io.Externalizable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
|
||||
|
||||
/**
|
||||
* This class loosely implements the {@code java.util.Vector}
|
||||
* API, in that it implements the 1.1.x version of
|
||||
* {@code java.util.Vector}, has no collection class support,
|
||||
* and notifies the {@code ListDataListener}s when changes occur.
|
||||
* Presently it delegates to a {@code Vector},
|
||||
* in a future release it will be a real Collection implementation.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is
|
||||
* appropriate for short term storage or RMI between applications running
|
||||
* the same version of Swing. As of 1.4, support for long term storage
|
||||
* of all JavaBeans
|
||||
* has been added to the {@code java.beans} package.
|
||||
* Please see {@link java.beans.XMLEncoder}.
|
||||
*
|
||||
* @param <E> the type of the elements of this model
|
||||
*
|
||||
* @author Hans Muller
|
||||
* @since 1.2
|
||||
*/
|
||||
@SuppressWarnings("serial") // Same-version serialization only
|
||||
public class XDefaultListModel<E> extends XAbstractListModel<E> implements Externalizable
|
||||
{
|
||||
private Vector<E> delegate = new Vector<E>();
|
||||
|
||||
/**
|
||||
* Constructs a {@code DefaultListModel}.
|
||||
*/
|
||||
public XDefaultListModel() {}
|
||||
|
||||
/**
|
||||
* Returns the number of components in this list.
|
||||
* <p>
|
||||
* This method is identical to {@code size}, which implements the
|
||||
* {@code List} interface defined in the 1.2 Collections framework.
|
||||
* This method exists in conjunction with {@code setSize} so that
|
||||
* {@code size} is identifiable as a JavaBean property.
|
||||
*
|
||||
* @return the number of components in this list
|
||||
* @see #size()
|
||||
*/
|
||||
public int getSize() {
|
||||
return delegate.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the component at the specified index.
|
||||
* <blockquote>
|
||||
* <b>Note:</b> Although this method is not deprecated, the preferred
|
||||
* method to use is {@code get(int)}, which implements the {@code List}
|
||||
* interface defined in the 1.2 Collections framework.
|
||||
* </blockquote>
|
||||
* @param index an index into this list
|
||||
* @return the component at the specified index
|
||||
* @throws ArrayIndexOutOfBoundsException if the {@code index}
|
||||
* is negative or greater than the current size of this
|
||||
* list
|
||||
* @see #get(int)
|
||||
*/
|
||||
public E getElementAt(int index) {
|
||||
return delegate.elementAt(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the components of this list into the specified array.
|
||||
* The array must be big enough to hold all the objects in this list,
|
||||
* else an {@code IndexOutOfBoundsException} is thrown.
|
||||
*
|
||||
* @param anArray the array into which the components get copied
|
||||
* @see Vector#copyInto(Object[])
|
||||
*/
|
||||
public void copyInto(Object[] anArray) {
|
||||
delegate.copyInto(anArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trims the capacity of this list to be the list's current size.
|
||||
*
|
||||
* @see Vector#trimToSize()
|
||||
*/
|
||||
public void trimToSize() {
|
||||
delegate.trimToSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases the capacity of this list, if necessary, to ensure
|
||||
* that it can hold at least the number of components specified by
|
||||
* the minimum capacity argument.
|
||||
*
|
||||
* @param minCapacity the desired minimum capacity
|
||||
* @see Vector#ensureCapacity(int)
|
||||
*/
|
||||
public void ensureCapacity(int minCapacity) {
|
||||
delegate.ensureCapacity(minCapacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the size of this list.
|
||||
*
|
||||
* @param newSize the new size of this list
|
||||
* @see Vector#setSize(int)
|
||||
*/
|
||||
public void setSize(int newSize) {
|
||||
int oldSize = delegate.size();
|
||||
delegate.setSize(newSize);
|
||||
if (oldSize > newSize) {
|
||||
fireIntervalRemoved(this, newSize, oldSize-1);
|
||||
}
|
||||
else if (oldSize < newSize) {
|
||||
fireIntervalAdded(this, oldSize, newSize-1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current capacity of this list.
|
||||
*
|
||||
* @return the current capacity
|
||||
* @see Vector#capacity()
|
||||
*/
|
||||
public int capacity() {
|
||||
return delegate.capacity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of components in this list.
|
||||
*
|
||||
* @return the number of components in this list
|
||||
* @see Vector#size()
|
||||
*/
|
||||
public int size() {
|
||||
return delegate.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether this list has any components.
|
||||
*
|
||||
* @return {@code true} if and only if this list has
|
||||
* no components, that is, its size is zero;
|
||||
* {@code false} otherwise
|
||||
* @see Vector#isEmpty()
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return delegate.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an enumeration of the components of this list.
|
||||
*
|
||||
* @return an enumeration of the components of this list
|
||||
* @see Vector#elements()
|
||||
*/
|
||||
public Enumeration<E> elements() {
|
||||
return delegate.elements();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the specified object is a component in this list.
|
||||
*
|
||||
* @param elem an object
|
||||
* @return {@code true} if the specified object
|
||||
* is the same as a component in this list
|
||||
* @see Vector#contains(Object)
|
||||
*/
|
||||
public boolean contains(Object elem) {
|
||||
return delegate.contains(elem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for the first occurrence of {@code elem}.
|
||||
*
|
||||
* @param elem an object
|
||||
* @return the index of the first occurrence of the argument in this
|
||||
* list; returns {@code -1} if the object is not found
|
||||
* @see Vector#indexOf(Object)
|
||||
*/
|
||||
public int indexOf(Object elem) {
|
||||
return delegate.indexOf(elem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for the first occurrence of {@code elem}, beginning
|
||||
* the search at {@code index}.
|
||||
*
|
||||
* @param elem the desired component
|
||||
* @param index the index from which to begin searching
|
||||
* @return the index where the first occurrence of {@code elem}
|
||||
* is found after {@code index}; returns {@code -1}
|
||||
* if the {@code elem} is not found in the list
|
||||
* @see Vector#indexOf(Object,int)
|
||||
*/
|
||||
public int indexOf(Object elem, int index) {
|
||||
return delegate.indexOf(elem, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of {@code elem}.
|
||||
*
|
||||
* @param elem the desired component
|
||||
* @return the index of the last occurrence of {@code elem}
|
||||
* in the list; returns {@code elem} if the object is not found
|
||||
* @see Vector#lastIndexOf(Object)
|
||||
*/
|
||||
public int lastIndexOf(Object elem) {
|
||||
return delegate.lastIndexOf(elem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches backwards for {@code elem}, starting from the
|
||||
* specified index, and returns an index to it.
|
||||
*
|
||||
* @param elem the desired component
|
||||
* @param index the index to start searching from
|
||||
* @return the index of the last occurrence of the {@code elem}
|
||||
* in this list at position less than {@code index};
|
||||
* returns {@code -1} if the object is not found
|
||||
* @see Vector#lastIndexOf(Object,int)
|
||||
*/
|
||||
public int lastIndexOf(Object elem, int index) {
|
||||
return delegate.lastIndexOf(elem, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the component at the specified index.
|
||||
* <blockquote>
|
||||
* <b>Note:</b> Although this method is not deprecated, the preferred
|
||||
* method to use is {@code get(int)}, which implements the
|
||||
* {@code List} interface defined in the 1.2 Collections framework.
|
||||
* </blockquote>
|
||||
*
|
||||
* @param index an index into this list
|
||||
* @return the component at the specified index
|
||||
* @throws ArrayIndexOutOfBoundsException if the index
|
||||
* is negative or not less than the size of the list
|
||||
* @see #get(int)
|
||||
* @see Vector#elementAt(int)
|
||||
*/
|
||||
public E elementAt(int index) {
|
||||
return delegate.elementAt(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first component of this list.
|
||||
* @return the first component of this list
|
||||
* @see Vector#firstElement()
|
||||
* @throws java.util.NoSuchElementException if this
|
||||
* vector has no components
|
||||
*/
|
||||
public E firstElement() {
|
||||
return delegate.firstElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last component of the list.
|
||||
*
|
||||
* @return the last component of the list
|
||||
* @see Vector#lastElement()
|
||||
* @throws java.util.NoSuchElementException if this vector
|
||||
* has no components
|
||||
*/
|
||||
public E lastElement() {
|
||||
return delegate.lastElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the component at the specified {@code index} of this
|
||||
* list to be the specified element. The previous component at that
|
||||
* position is discarded.
|
||||
* <blockquote>
|
||||
* <b>Note:</b> Although this method is not deprecated, the preferred
|
||||
* method to use is {@code set(int,Object)}, which implements the
|
||||
* {@code List} interface defined in the 1.2 Collections framework.
|
||||
* </blockquote>
|
||||
*
|
||||
* @param element what the component is to be set to
|
||||
* @param index the specified index
|
||||
* @throws ArrayIndexOutOfBoundsException if the index is invalid
|
||||
* @see #set(int,Object)
|
||||
* @see Vector#setElementAt(Object,int)
|
||||
*/
|
||||
public void setElementAt(E element, int index) {
|
||||
delegate.setElementAt(element, index);
|
||||
fireContentsChanged(this, index, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the component at the specified index.
|
||||
* <blockquote>
|
||||
* <b>Note:</b> Although this method is not deprecated, the preferred
|
||||
* method to use is {@code remove(int)}, which implements the
|
||||
* {@code List} interface defined in the 1.2 Collections framework.
|
||||
* </blockquote>
|
||||
*
|
||||
* @param index the index of the object to remove
|
||||
* @see #remove(int)
|
||||
* @see Vector#removeElementAt(int)
|
||||
* @throws ArrayIndexOutOfBoundsException if the index is invalid
|
||||
*/
|
||||
public void removeElementAt(int index) {
|
||||
delegate.removeElementAt(index);
|
||||
fireIntervalRemoved(this, index, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts the specified element as a component in this list at the
|
||||
* specified <code>index</code>.
|
||||
* <blockquote>
|
||||
* <b>Note:</b> Although this method is not deprecated, the preferred
|
||||
* method to use is {@code add(int,Object)}, which implements the
|
||||
* {@code List} interface defined in the 1.2 Collections framework.
|
||||
* </blockquote>
|
||||
*
|
||||
* @param element the component to insert
|
||||
* @param index where to insert the new component
|
||||
* @exception ArrayIndexOutOfBoundsException if the index was invalid
|
||||
* @see #add(int,Object)
|
||||
* @see Vector#insertElementAt(Object,int)
|
||||
*/
|
||||
public void insertElementAt(E element, int index) {
|
||||
delegate.insertElementAt(element, index);
|
||||
fireIntervalAdded(this, index, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified component to the end of this list.
|
||||
*
|
||||
* @param element the component to be added
|
||||
* @see Vector#addElement(Object)
|
||||
*/
|
||||
public void addElement(E element) {
|
||||
int index = delegate.size();
|
||||
delegate.addElement(element);
|
||||
fireIntervalAdded(this, index, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the first (lowest-indexed) occurrence of the argument
|
||||
* from this list.
|
||||
*
|
||||
* @param obj the component to be removed
|
||||
* @return {@code true} if the argument was a component of this
|
||||
* list; {@code false} otherwise
|
||||
* @see Vector#removeElement(Object)
|
||||
*/
|
||||
public boolean removeElement(Object obj) {
|
||||
int index = indexOf(obj);
|
||||
boolean rv = delegate.removeElement(obj);
|
||||
if (index >= 0) {
|
||||
fireIntervalRemoved(this, index, index);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes all components from this list and sets its size to zero.
|
||||
* <blockquote>
|
||||
* <b>Note:</b> Although this method is not deprecated, the preferred
|
||||
* method to use is {@code clear}, which implements the
|
||||
* {@code List} interface defined in the 1.2 Collections framework.
|
||||
* </blockquote>
|
||||
*
|
||||
* @see #clear()
|
||||
* @see Vector#removeAllElements()
|
||||
*/
|
||||
public void removeAllElements() {
|
||||
int index1 = delegate.size()-1;
|
||||
delegate.removeAllElements();
|
||||
if (index1 >= 0) {
|
||||
fireIntervalRemoved(this, 0, index1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a string that displays and identifies this
|
||||
* object's properties.
|
||||
*
|
||||
* @return a String representation of this object
|
||||
*/
|
||||
public String toString() {
|
||||
return delegate.toString();
|
||||
}
|
||||
|
||||
|
||||
/* The remaining methods are included for compatibility with the
|
||||
* Java 2 platform Vector class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns an array containing all of the elements in this list in the
|
||||
* correct order.
|
||||
*
|
||||
* @return an array containing the elements of the list
|
||||
* @see Vector#toArray()
|
||||
*/
|
||||
public Object[] toArray() {
|
||||
Object[] rv = new Object[delegate.size()];
|
||||
delegate.copyInto(rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the element at the specified position in this list.
|
||||
*
|
||||
* @param index index of element to return
|
||||
* @return the element at the specified position in this list
|
||||
* @throws ArrayIndexOutOfBoundsException if the index is out of range
|
||||
* ({@code index < 0 || index >= size()})
|
||||
*/
|
||||
public E get(int index) {
|
||||
return delegate.elementAt(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the element at the specified position in this list with the
|
||||
* specified element.
|
||||
*
|
||||
* @param index index of element to replace
|
||||
* @param element element to be stored at the specified position
|
||||
* @return the element previously at the specified position
|
||||
* @throws ArrayIndexOutOfBoundsException if the index is out of range
|
||||
* ({@code index < 0 || index >= size()})
|
||||
*/
|
||||
public E set(int index, E element) {
|
||||
E rv = delegate.elementAt(index);
|
||||
delegate.setElementAt(element, index);
|
||||
fireContentsChanged(this, index, index);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts the specified element at the specified position in this list.
|
||||
*
|
||||
* @param index index at which the specified element is to be inserted
|
||||
* @param element element to be inserted
|
||||
* @throws ArrayIndexOutOfBoundsException if the index is out of range
|
||||
* ({@code index < 0 || index > size()})
|
||||
*/
|
||||
public void add(int index, E element) {
|
||||
delegate.insertElementAt(element, index);
|
||||
fireIntervalAdded(this, index, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the element at the specified position in this list.
|
||||
* Returns the element that was removed from the list
|
||||
*
|
||||
* @param index the index of the element to removed
|
||||
* @return the element previously at the specified position
|
||||
* @throws ArrayIndexOutOfBoundsException if the index is out of range
|
||||
* ({@code index < 0 || index >= size()})
|
||||
*/
|
||||
public E remove(int index) {
|
||||
E rv = delegate.elementAt(index);
|
||||
delegate.removeElementAt(index);
|
||||
fireIntervalRemoved(this, index, index);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all of the elements from this list. The list will
|
||||
* be empty after this call returns (unless it throws an exception).
|
||||
*/
|
||||
public void clear() {
|
||||
int index1 = delegate.size()-1;
|
||||
delegate.removeAllElements();
|
||||
if (index1 >= 0) {
|
||||
fireIntervalRemoved(this, 0, index1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the components at the specified range of indexes.
|
||||
* The removal is inclusive, so specifying a range of (1,5)
|
||||
* removes the component at index 1 and the component at index 5,
|
||||
* as well as all components in between.
|
||||
*
|
||||
* @param fromIndex the index of the lower end of the range
|
||||
* @param toIndex the index of the upper end of the range
|
||||
* @throws ArrayIndexOutOfBoundsException if the index was invalid
|
||||
* @throws IllegalArgumentException if {@code fromIndex > toIndex}
|
||||
* @see #remove(int)
|
||||
*/
|
||||
public void removeRange(int fromIndex, int toIndex) {
|
||||
if (fromIndex > toIndex) {
|
||||
throw new IllegalArgumentException("fromIndex must be <= toIndex");
|
||||
}
|
||||
for(int i = toIndex; i >= fromIndex; i--) {
|
||||
delegate.removeElementAt(i);
|
||||
}
|
||||
fireIntervalRemoved(this, fromIndex, toIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all of the elements present in the collection to the list.
|
||||
*
|
||||
* @param c the collection which contains the elements to add
|
||||
* @throws NullPointerException if {@code c} is null
|
||||
*/
|
||||
public void addAll(Collection<? extends E> c) {
|
||||
if (c.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int startIndex = getSize();
|
||||
|
||||
delegate.addAll(c);
|
||||
fireIntervalAdded(this, startIndex, getSize() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all of the elements present in the collection, starting
|
||||
* from the specified index.
|
||||
*
|
||||
* @param index index at which to insert the first element from the
|
||||
* specified collection
|
||||
* @param c the collection which contains the elements to add
|
||||
* @throws ArrayIndexOutOfBoundsException if {@code index} does not
|
||||
* fall within the range of number of elements currently held
|
||||
* @throws NullPointerException if {@code c} is null
|
||||
*/
|
||||
public void addAll(int index, Collection<? extends E> c) {
|
||||
if (index < 0 || index > getSize()) {
|
||||
throw new ArrayIndexOutOfBoundsException("index out of range: " +
|
||||
index);
|
||||
}
|
||||
|
||||
if (c.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
delegate.addAll(index, c);
|
||||
fireIntervalAdded(this, index, index + c.size() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(ObjectOutput out) throws IOException {
|
||||
out.writeObject(delegate);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
|
||||
delegate=(Vector<E>) in.readObject();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user