Methode cut() anwenden

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Methode cut() anwenden

    Hallo zusammen,

    habe folgenden code, krieg nur die Methode cut nicht darein. (ganz unten)
    if(e.getSource() == btnausschneiden)
    {
    textfeld.cut();
    }

    Krieg immer die Meldung cannot resolve - method cut()
    Muss ich da vllt. was importieren, weil ich ja SimpleGui nutze und das ne Metode aus JTextArea.Components ist ?
    Vorschläge immer willkommen !

    Gruß

    Quellcode

    1. import simpleGui.*;
    2. import java.awt.Font;
    3. public class Texteditor extends SFrame
    4. {
    5. String pfad = "";
    6. STextArea textfeld = new STextArea (0, 100, 1000, 400, "", this);
    7. SButton btnoeffnen = new SButton (2, 2, 40, 30, "open.png","öffnen", this);
    8. SButton btnspeichern = new SButton (45, 2, 40, 30, "speichern.jpg","speichern", this);
    9. SButton btnspeichernunter= new SButton (87, 2, 40, 30, "speichernUnter.jpg","speichern unter", this);
    10. SButton btnneuesDokument = new SButton (132, 2, 40, 30, "neuesDokument.jpg","neues Dokument", this);
    11. SButton btnkopieren = new SButton (500, 2, 40, 30, "kopieren.jpg","kopieren", this);
    12. SButton btneinfuegen = new SButton (545, 2, 40, 30, "einfuegen.jpg","einfügen", this);
    13. SButton btnausschneiden = new SButton (586, 2, 40, 30, "ausschneiden.jpg","ausschneiden", this);
    14. SButton btnfett = new SButton (2, 60, 40, 30, "bold.jpg","fett", this);
    15. SButton btnkursiv = new SButton (45, 60, 40, 30, "kursiv.jpg","kursiv", this);
    16. SButton btnunterstrichen = new SButton (88, 60, 40, 30, "unterstrichen.jpg","unterstreichen", this);
    17. SButton btnvergroeßern= new SButton (400, 60, 40, 30, "lupePlus.png","vergrößern", this);
    18. SButton btnverkleinern = new SButton (443, 60, 40, 30, "lupeMinus.png","verkleinern", this);
    19. SButton btnvorschau = new SButton (586, 60, 40, 30, "vorschau.jpg","Vorschau", this);
    20. SChoice auswahlSchrift = new SChoice (170, 60, 80, 25, new String[] {"Arial","Andy MT","Courier","Monotype Sorts", "Luxi Sans","Simpsons","Thorndale AMT","URW Chancery L"}, this);
    21. SChoice auswahlGroeße = new SChoice ( 255, 60, 120, 25, new String[] {"6","8","10","12","13","14","15","16","17","18","19","20","30","40", "50","60","70","80","90","100"}, this);
    22. SFileChooser oeffnen = new SFileChooser (45, 60, 40, 30, "öffnen", this);
    23. SFileChooser speichern = new SFileChooser (45, 60, 40, 30, "speichern", this);
    24. public Texteditor()
    25. {
    26. super(645, 500, "Texteditor");
    27. this.setBounds(0,0,645,500);
    28. this.setVisible(true);
    29. this.getContentPane().setBackground(new java.awt.Color(238, 216, 174));
    30. textfeld.textArea.setBackground(new java.awt.Color(255, 231, 186));
    31. textfeld.textArea.setLineWrap(true);
    32. }
    33. public void actionPerformed(java.awt.event.ActionEvent e)
    34. {
    35. if(e.getSource() == btnoeffnen)
    36. {
    37. if(textfeld.hasChanged())
    38. {
    39. int dialog = SDialog.showYesNoCancelDialog("speichern ?", "Wollen Sie ohen zu speichern ein neues Dokument öffnen",this);
    40. if(dialog == SDialog.YES_OPTION)
    41. {
    42. this.pfad=oeffnen.openDialog();
    43. textfeld.setText(SFile.readText(this.pfad));
    44. }
    45. }
    46. else
    47. {
    48. this.pfad=oeffnen.openDialog();
    49. textfeld.setText(SFile.readText(this.pfad));
    50. }
    51. }
    52. if(e.getSource() == btnspeichern)
    53. {
    54. SFile.saveText(this.pfad, textfeld.getText());
    55. }
    56. if(e.getSource() == btnspeichernunter)
    57. {
    58. this.pfad=speichern.saveDialog();
    59. SFile.saveText(this.pfad, textfeld.getText());
    60. }
    61. if(e.getSource() == btnneuesDokument)
    62. {
    63. int dialog = SDialog.showYesNoCancelDialog("speichern ?", "Wollen Sie ohne zu speichern ein neues Dokument öffnen", this);
    64. if(dialog == SDialog.YES_OPTION)
    65. {
    66. textfeld.setText("");
    67. pfad="";
    68. }
    69. if(dialog == SDialog.NO_OPTION)
    70. {
    71. this.pfad = speichern.saveDialog();
    72. SFile.saveText(this.pfad, textfeld.getText());
    73. }
    74. }
    75. if(e.getSource() == btnfett)
    76. {
    77. textfeld.insert("dd");
    78. }
    79. if(e.getSource() == btnkopieren)
    80. {
    81. SClipboard.setText(textfeld.getSelectedText());
    82. }
    83. if(e.getSource() == btneinfuegen)
    84. {
    85. textfeld.insert(SClipboard.getText());
    86. }
    87. if(e.getSource() == btnausschneiden)
    88. {
    89. }
    90. }
    91. }
    Alles anzeigen
  • STextArea ist von JTextarea abgeleitet, dort gibt es keine cut(), weder implementiert noch geerbt. Also ist der Fehler absolut logisch. StextArea hat die Methode auch nicht selber, also musst du diese entweder noch dareinschreiben, oder du leitest von STextArea ab in eine neue Klasse, in der du dann cut() implementierst.
    ~ mfg SeBa

    Ich beantworte keine PMs zu Computer-/Programmierproblemen. Bitte wendet euch an das entsprechende Forum.

    [Blockierte Grafik: http://i.creativecommons.org/l/by-sa/3.0/80x15.png]