MCPcopy Index your code
hub / github.com/adolfintel/NoteBot / Note

Method Note

StickyNotes/src/com/dosse/stickynotes/Note.java:229–560  ·  view source on GitHub ↗

Creates new form Note. A note is initialized empty, with a yellow background and at current mouse coordinates.

()

Source from the content-addressed store, hash-verified

227 * mouse coordinates.
228 */
229 public Note() {
230 setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); //if alt+f4 is pressed, this will cause the windowClosing event to be fired
231 addWindowListener(new WindowAdapter() {
232 @Override
233 public void windowClosing(WindowEvent e) {
234 //if alt+f4 is pressed, save the current state and terminate the app
235 Main.saveState();
236 System.exit(0);
237 }
238 });
239 addWindowFocusListener(new WindowAdapter() {
240 @Override
241 public void windowLostFocus(WindowEvent e) {
242 //if focus is lost, save the current state
243 Main.saveState();
244 }
245
246 @Override
247 public void windowGainedFocus(WindowEvent e) {
248 Main.bringToFront(Note.this);
249 text.requestFocusInWindow();
250 }
251 });
252 setTitle(getLocString("APPNAME")); //set window title
253 setIconImage(loadImage("/com/dosse/stickynotes/icon.png")); //set window icon
254 setUndecorated(true); //removes system window border
255
256 //now we will create and initialize all the elements inside the note
257 wrapper1 = new JPanel();
258 wrapper2 = new JPanel();
259 newNote = new JButton();
260 deleteNote = new JButton();
261 jScrollPane1 = new JScrollPane();
262 //create the text area
263 text = new JTextArea() {
264 @Override
265 public boolean getScrollableTracksViewportWidth() {//configures the textarea to resize properly horizontaly (workaround for swing bug)
266 return true;
267 }
268 };
269 //enable line wrap
270 text.setLineWrap(true);
271 text.setWrapStyleWord(true);
272 //allow undo/redo
273 Document doc = text.getDocument();
274 doc.addUndoableEditListener(new UndoableEditListener() {
275 @Override
276 public void undoableEditHappened(UndoableEditEvent e) {
277 undo.addEdit(e.getEdit());
278 }
279 });
280
281 jScrollPane1.setBorder(null);
282 jScrollPane1.setViewportView(text); //add text area to scrollpane
283
284 //events used for dragging the note
285 wrapper2.addMouseListener(new MouseAdapter() {
286 @Override

Callers

nothing calls this directly

Calls 8

getLocStringMethod · 0.95
loadImageMethod · 0.95
registerComponentMethod · 0.95
setSnapSizeMethod · 0.95
setMinimumSizeMethod · 0.95
setLocationMethod · 0.95
setColorSchemeMethod · 0.95
setTextMethod · 0.80

Tested by

no test coverage detected