1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
package IHM;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.event.KeyEvent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.SwingConstants;
import javax.swing.border.LineBorder;
import EVENT.Changes;
import EVENT.Final;
import EVENT.Windows;
import TABBED.TabHDMT;
import TABBED.TabNEMO;
/**
* IHM of Converter application
*
* @author t0163126
*/
public class IhmConverter extends JFrame {
private static final long serialVersionUID = 1L;
private static ToolBar toolBar;
private JPanel panCustomer;
private JPanel panTab;
private JPanel panLog;
private JTextArea txtaLog;
private JSplitPane split;
private JScrollPane ascenseur;
private static JTabbedPane tabs;
private static TabHDMT HDMT;
private static TabNEMO NEMO;
// ============================================================
/**
* Ihm constructorr
*/
private IhmConverter() {
initIhmConverter();
}
/**
* Method initialization
*/
private void initIhmConverter() {
// window event
this.addWindowListener(new Windows());
panTab = new JPanel();
HDMT = new TabHDMT();
NEMO = new TabNEMO();
tabs = new JTabbedPane(SwingConstants.NORTH);
// Add tabs
tabs.add("HDMT", HDMT);
tabs.add("NEMO", NEMO);
tabs.setOpaque(true);
//Active the first tab with color
tabs.setSelectedIndex(0);
tabs.setForegroundAt(0,Final.getSelectionColor());
//Tab shortcut key
tabs.setMnemonicAt(0, KeyEvent.VK_H); //ALT+H
tabs.setMnemonicAt(1, KeyEvent.VK_N); //ALT+N
tabs.addChangeListener(new Changes(tabs));
panTab.setLayout(new BorderLayout());
panTab.add(tabs, BorderLayout.CENTER);
txtaLog = new JTextArea();
txtaLog.setFont(Final.getFont());
txtaLog.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
txtaLog.setEditable(true);
txtaLog.setCursor(new Cursor(Cursor.TEXT_CURSOR));
txtaLog.setDisabledTextColor(Color.black);
txtaLog.setBackground(Color.lightGray);
//Return to automatically line
txtaLog.setLineWrap(true);
ascenseur = new JScrollPane(txtaLog,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
Dimension size = new Dimension(0,50);
ascenseur.setPreferredSize(size);
ascenseur.setMinimumSize(size);
ascenseur.getViewport().setBackground(Color.WHITE);
panLog = new JPanel();
panLog.setLayout(new BorderLayout());
panLog.setBackground(Color.lightGray);
panLog.add(ascenseur, BorderLayout.CENTER);
// Customer area
panCustomer = (JPanel) this.getContentPane();
panCustomer.setLayout(new BorderLayout());
//Separator between panTabs and tabLog
split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panTab, panLog);
split.setOneTouchExpandable(true);
//add to customer pane
panCustomer.add(split, BorderLayout.CENTER);
// Add toolBar
toolBar = new ToolBar();
this.add(toolBar, BorderLayout.NORTH);
}
// ============================================================
// instantiation
private static IhmConverter hdmt;
public static IhmConverter getInstance() {
if (hdmt == null) {
hdmt = new IhmConverter();
}
return hdmt;
}
// ============================================================
// Getter and setter
public static JTabbedPane getTabs() {
return IhmConverter.tabs;
}
public static TabHDMT getHDMT() {
return IhmConverter.HDMT;
}
public static TabNEMO getNEMO() {
return IhmConverter.NEMO;
}
public static ToolBar getToolBar() {
return IhmConverter.toolBar;
}
public JTextArea getTxtaLog() {
return this.txtaLog;
}
} |
Partager