私はモデルブラウザを作ろうとしていますが、この1つのエラーは一見良いコード行から出てきています。add(TextField)に適切なメソッドが見つかりませんか?
import java.awt.Container;
import java.awt.Font;
import java.awt.Insets;
import javafx.scene.control.TextField;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author PC
*/
public class Browser extends JFrame{
private TextField field = new TextField();
private JEditorPane display = new JEditorPane();
private JScrollPane scroller = new JScrollPane(display);
public static void main(String args[]){
Browser file = new Browser();
file.framelander();
}
public void framelander() {
setTitle("Browser");
setSize(1200, 800);
setResizable(false);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(null);
setLocationRelativeTo(null);
addComponentsToFrame(getContentPane());
}
public void addComponentsToFrame(Container pane) {
Insets insets = getInsets();
pane.add(field);
pane.add(scroller);
Font font = new Font("Menlo", Font.PLAIN, 11);
field.setFont(font);
}
}
エラーは、pane.add(フィールド)にエラーがあります。
no suitable method found for add(TextField)
method Component.add(PopupMenu) is not applicable
(argument mismatch; TextField cannot be converted to PopupMenu)
method Container.add(Component) is not applicable
(argument mismatch; TextField cannot be converted to Component)
----
(Alt-Enter shows hints)
私はまた、「互換性のない型:持つjava.awt.fontはjavafx.scene.text.Fontに変換することができません」を取得しています
field.setFont(フォント)の太字部分に、しかし私はそれが初期のエラーのためだと仮定しています。私はここにそれを掲示するつもりです。
何かすべての助けがありがとうございます。前もって感謝します。
ヒントはパッケージ名とともに「変換できません」... javafxクラスとawtクラスは完全に互換性があります –