?? desktop.java
字號:
package connex.session.desktop;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import connex.app.loginUI.LoginDialog;
import org.jdesktop.swingx.border.DropShadowBorder;
import org.jdesktop.swingx.JXPanel;
import org.jdesktop.swingx.painter.CompoundPainter;
import org.jdesktop.swingx.painter.GlossPainter;
import org.jdesktop.swingx.painter.PinstripePainter;
import org.jdesktop.swingx.painter.Painter;
import org.jdesktop.swingx.painter.gradient.BasicGradientPainter;
import org.jdesktop.swingx.painter.BackgroundPainter;
import java.awt.geom.Point2D;
import org.jdesktop.swingx.painter.ImagePainter;
import connex.app.utils.ToolBar;
public class Desktop extends JFrame {
private JFileChooser fc;
private BuddyListPanel buddypanel = null;
private JPanel contentPane;
private JPanel jPanel1 = new JPanel();
private JXPanel rightPanel = new JXPanel();
private JPanel leftPanel = new JPanel();
private JXPanel jPanel3 = new JXPanel();
private JXPanel jPanel4 = new JXPanel();
private JMenuBar jMenuBar1 = new JMenuBar();
private JMenu jMenuFile = new JMenu();
private JMenu jMenuEdit = new JMenu();
private JMenuItem jMenuFileExit = new JMenuItem();
private JMenuItem jMenuProfile = new JMenuItem();
private ToolBar jToolBar = new ToolBar(UIManager.getColor(
"Panel.background"),Color.lightGray);
private ImageIcon back = new ImageIcon(
"resources" + File.separator + "images" + File.separator +
"ConneXLogo_alpha5.png");
public JLabel statusBar = new JLabel();
private JProgressBar prog = new JProgressBar(0, 30);
private JTabbedPane jTabbedPane1 = new JTabbedPane();
private BorderLayout borderLayout1 = new BorderLayout();
private BorderLayout borderLayout3 = new BorderLayout();
private BorderLayout borderLayout6 = new BorderLayout();
private DropShadowBorder border5 = new DropShadowBorder(Color.black, 1, 7,
.7f, 12, false, true, true, true);
LoginDialog log = null;
public Desktop() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
// setDefaultCloseOperation(EXIT_ON_CLOSE);
contentPane = (JPanel) getContentPane();
contentPane.setLayout(borderLayout1);
borderLayout1.setVgap(5);
setSize(new Dimension(800, 600));
prog.setIndeterminate(true);
statusBar.setBorder(BorderFactory.createEtchedBorder());
statusBar.setText(" ");
jMenuFile.setText("File");
jMenuEdit.setText("Edit");
jMenuFileExit.setText("Exit");
jMenuProfile.setText("My Profile");
jMenuProfile.addActionListener(new Desktop_jMenuProfile_ActionAdapter(this));
jMenuFileExit.addActionListener(new Desktop_jMenuFileExit_ActionAdapter(this));
rightPanel.setLayout(new BorderLayout());
rightPanel.add(jPanel4, java.awt.BorderLayout.NORTH);
jPanel4.add(new JLabel("Tools Panel"));
ImagePainter ip = new ImagePainter(back.getImage(),
ImagePainter.Style.CSS_POSITIONED);
Point2D d = new Point(1, 1);
ip.setImagePosition(d);
rightPanel.setBackgroundPainter(ip);
/***********************/
Color blue = new Color(0x417DDD);
Color translucent = new Color(blue.getRed(), blue.getGreen(),
blue.getBlue(), 0);
jPanel4.setBackground(blue);
jPanel4.setForeground(Color.LIGHT_GRAY);
jPanel3.setBackground(blue);
jPanel3.setForeground(Color.LIGHT_GRAY);
GradientPaint blueToTranslucent = new GradientPaint(
new Point2D.Double(.4, 0),
blue,
new Point2D.Double(1, 0),
translucent);
GlossPainter gp = new GlossPainter();
gp.setPaint(new Color(1.0f, 1.0f, 1.0f, 0.2f));
gp.setPosition(GlossPainter.GlossPosition.TOP);
Painter veil = new BasicGradientPainter(blueToTranslucent);
Painter pinstripes = new PinstripePainter(45);
Painter backgroundPainter = new BackgroundPainter();
Painter p = new CompoundPainter(backgroundPainter, pinstripes, veil, gp);
jPanel4.setBackgroundPainter(p);
/****************/
rightPanel.setBorder(border5);
jTabbedPane1.setTabPlacement(JTabbedPane.BOTTOM);
jTabbedPane1.setOpaque(false);
rightPanel.add(jTabbedPane1, java.awt.BorderLayout.CENTER);
jToolBar.setBorder(border5);
leftPanel.setLayout(borderLayout6);
jPanel1.setLayout(borderLayout3);
borderLayout3.setHgap(10);
jMenuBar1.add(jMenuFile);
jMenuBar1.add(jMenuEdit);
jMenuFile.add(jMenuFileExit);
jMenuEdit.add(jMenuProfile);
setJMenuBar(jMenuBar1);
jPanel1.add(rightPanel, java.awt.BorderLayout.CENTER);
jPanel1.add(leftPanel, java.awt.BorderLayout.WEST);
leftPanel.add(jPanel3, java.awt.BorderLayout.NORTH);
leftPanel.setBorder(border5);
leftPanel.setPreferredSize(new Dimension(200, 1));
jPanel3.add(new JLabel("Members:"));
jPanel3.setBackgroundPainter(p);
contentPane.add(jToolBar, java.awt.BorderLayout.NORTH);
contentPane.add(statusBar, BorderLayout.SOUTH);
contentPane.add(jPanel1, java.awt.BorderLayout.CENTER);
//centerFrame();
}
public void showDesktop() {
// Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = this.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
this.setLocation((screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
this.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
this.setVisible(true);
}
public void setBuddyList(BuddyList buddyList) {
buddypanel = new BuddyListPanel(buddyList);
leftPanel.add(buddypanel, java.awt.BorderLayout.CENTER);
}
public BuddyListPanel getBuddyPanel(){
return buddypanel;
}
public ToolBar getPluginContainer() {
return this.jToolBar;
}
public JTabbedPane getPluginHolder(){
return jTabbedPane1;
}
/**
* File | Exit action performed.
*
* @param actionEvent ActionEvent
*/
void jMenuFileExit_actionPerformed(ActionEvent actionEvent) {
// System.exit(0);
this.dispose();
}
void jMenuProfile_actionPerformed(ActionEvent e) {
log = new LoginDialog(this, true);
log.dispose();
}
public static void main(String [] arg){
try {
UIManager.setLookAndFeel(UIManager.
getSystemLookAndFeelClassName());
} catch (Exception exception) {
exception.printStackTrace();
}
Desktop d= new Desktop();
}
/**
* entery_actionperformened
*
* @param e ActionEvent
*/
protected void entery_actionperformened(ActionEvent e) {
System.err.println("ActionCommand: " + e.getActionCommand());
}
public void testBtn_actionPerformed(ActionEvent e) {
if (fc == null) {
fc = new JFileChooser();
}
fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
int returnVal = fc.showOpenDialog(this);
//Process the results.
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
//loadPlugins(file.getPath() );
//Reset the file chooser for the next time it's shown.
}
}
}
class Desktop_jMenuFileExit_ActionAdapter implements ActionListener {
Desktop adaptee;
Desktop_jMenuFileExit_ActionAdapter(Desktop adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent) {
adaptee.jMenuFileExit_actionPerformed(actionEvent);
}
}
class Desktop_jMenuProfile_ActionAdapter implements ActionListener {
Desktop adaptee;
Desktop_jMenuProfile_ActionAdapter(Desktop adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent) {
adaptee.jMenuProfile_actionPerformed(actionEvent);
}
}
class Desktop_testBtn_actionAdapter implements ActionListener {
private Desktop adaptee;
Desktop_testBtn_actionAdapter(Desktop adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.testBtn_actionPerformed(e);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -