本文整理汇总了Java中javax.swing.JPanel.setSize方法的典型用法代码示例。如果您正苦于以下问题:Java JPanel.setSize方法的具体用法?Java JPanel.setSize怎么用?Java JPanel.setSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JPanel
的用法示例。
在下文中一共展示了JPanel.setSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: print
import javax.swing.JPanel; //导入方法依赖的package包/类
@Override
public void print(Graphics pg) {
JPanel printPanel = new JPanel() {
private static final long serialVersionUID = 7315234075649335574L;
@Override
public void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
plotEngine.getChartPanel().print(g2);
}
};
Insets insets = plotEngine.getChartPanel().getInsets();
int w = plotEngine.getChartPanel().getWidth() - insets.left - insets.right;
int h = plotEngine.getChartPanel().getHeight() - insets.top - insets.bottom;
printPanel.setSize(new Dimension(w, h));
printPanel.print(pg);
}
示例2: createPanel
import javax.swing.JPanel; //导入方法依赖的package包/类
private static JPanel createPanel(Point location, boolean enabled) {
final JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setEnabled(enabled);
panel.setSize(new Dimension(200, 200));
panel.setLocation(location);
panel.setBorder(BorderFactory.createTitledBorder(
enabled ? "Enabled" : "Disabled"));
panel.setCursor(Cursor.getPredefinedCursor(
enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
return panel;
}
示例3: TurnAnalyzer
import javax.swing.JPanel; //导入方法依赖的package包/类
@SuppressWarnings("serial")
public TurnAnalyzer(JFrame frame) {
super(frame,"Turn analysis");
menuPainter = new JPanel() {
public void paint(Graphics g) {
if (refImg == null) {
return;
}
Graphics2D g2 = (Graphics2D) g;
g2.scale(2, 2);
g2.drawImage(refImg, 0, 0, null);
}
};
menuPainter.setPreferredSize(MENU_SIZE_X2);
menuPainter.setMinimumSize(MENU_SIZE_X2);
menuPainter.setSize(MENU_SIZE_X2);
initialize();
}
示例4: erzeugeAusleihButton
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* Erzeugt den Ausleih-Button.
*/
private void erzeugeAusleihButton()
{
JPanel _buttonPanel = new JPanel();
_ausleihePanel.add(_buttonPanel, BorderLayout.SOUTH);
_buttonPanel.setPreferredSize(new Dimension(-1, 110));
_buttonPanel.setSize(-1, -1);
_buttonPanel.setBackground(UIConstants.BACKGROUND_COLOR);
_ausleihButton = new JButton();
_buttonPanel.add(_ausleihButton);
_ausleihButton.setText("ausleihen");
_ausleihButton.setPreferredSize(new Dimension(140, 100));
_ausleihButton.setSize(-1, -1);
_ausleihButton.setFont(UIConstants.BUTTON_FONT);
_ausleihButton.setEnabled(false);
}
示例5: erzeugeAusleihButton
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* Erzeugt den Ausleih-Button.
*/
private void erzeugeAusleihButton()
{
JPanel _buttonPanel = new JPanel();
_ausleihePanel.add(_buttonPanel, BorderLayout.SOUTH);
_buttonPanel.setPreferredSize(new Dimension(-1, 110));
_buttonPanel.setSize(-1, -1);
_buttonPanel.setBackground(UIConstants.BACKGROUND_COLOR);
_vormerkenButton = new JButton();
_buttonPanel.add(_vormerkenButton);
_vormerkenButton.setText("vormerken");
_vormerkenButton.setPreferredSize(new Dimension(140, 100));
_vormerkenButton.setSize(-1, -1);
_vormerkenButton.setFont(UIConstants.BUTTON_FONT);
_vormerkenButton.setEnabled(false);
}
示例6: erzeugeVerleihkartenauflister
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* Erzeuge das Tabellen-Panel, in dem die Verleihkarten angezeigt werden.
*/
private void erzeugeVerleihkartenauflister()
{
JPanel verleihkartenAuflisterPanel = new JPanel();
_hauptPanel.add(verleihkartenAuflisterPanel, BorderLayout.CENTER);
verleihkartenAuflisterPanel.setLayout(new BorderLayout());
verleihkartenAuflisterPanel
.setPreferredSize(new java.awt.Dimension(-1, -1));
verleihkartenAuflisterPanel.setSize(-1, -1);
verleihkartenAuflisterPanel.setBackground(UIConstants.BACKGROUND_COLOR);
JScrollPane verleihkartenAuflisterScrollPane = new JScrollPane();
verleihkartenAuflisterPanel.add(verleihkartenAuflisterScrollPane,
BorderLayout.CENTER);
verleihkartenAuflisterScrollPane
.setPreferredSize(new java.awt.Dimension(-1, -1));
verleihkartenAuflisterScrollPane.setSize(-1, -1);
verleihkartenAuflisterScrollPane.setBorder(BorderFactory
.createTitledBorder(null, "Verleihkarten", TitledBorder.LEADING,
TitledBorder.DEFAULT_POSITION, UIConstants.HEADER_FONT));
verleihkartenAuflisterScrollPane
.setBackground(UIConstants.BACKGROUND_COLOR);
verleihkartenAuflisterScrollPane.getVerticalScrollBar()
.setBackground(UIConstants.BACKGROUND_COLOR);
verleihkartenAuflisterScrollPane.getHorizontalScrollBar()
.setBackground(UIConstants.BACKGROUND_COLOR);
_verleihkartenAuflisterTableModel = new VerleihkartenTableModel();
_verleihkartenAuflisterTable = new JTable();
verleihkartenAuflisterScrollPane
.setViewportView(_verleihkartenAuflisterTable);
_verleihkartenAuflisterTable
.setModel(_verleihkartenAuflisterTableModel);
JTableHeader tableHeader = _verleihkartenAuflisterTable
.getTableHeader();
tableHeader.setFont(UIConstants.HEADER_FONT);
tableHeader.setReorderingAllowed(false);
tableHeader.setResizingAllowed(false);
_verleihkartenAuflisterTable.setFont(UIConstants.TEXT_FONT);
}
示例7: erzeugeRuecknahmeButton
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* Erzeuge den Rücknahme-Button.
*/
private void erzeugeRuecknahmeButton()
{
JPanel buttonPanel = new JPanel();
_ruecknahmePanel.add(buttonPanel, BorderLayout.SOUTH);
buttonPanel.setPreferredSize(new java.awt.Dimension(-1, 110));
buttonPanel.setSize(-1, -1);
buttonPanel.setBackground(UIConstants.BACKGROUND_COLOR);
_ruecknahmeButton = new JButton();
buttonPanel.add(_ruecknahmeButton);
_ruecknahmeButton.setText("zurücknehmen");
_ruecknahmeButton.setPreferredSize(new java.awt.Dimension(140, 100));
_ruecknahmeButton.setSize(-1, -1);
_ruecknahmeButton.setEnabled(false);
_ruecknahmeButton.setFont(UIConstants.BUTTON_FONT);
}
示例8: createIDEEditorPanel
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* Constructs an IDE editor panel, whose code is set with a parameter, with which the user can edit the file's code
* @param initialCode the code that the the file is set to and shows up initially on the editor pane
* @param d the dimension of the editor panel
* @return the IDE editor panel
* @throws IOException if file fails to save, rendering the initial compilation a failure
* @throws MalformedURLException if the class fails to load into the ArJClassEditor (leaving it unable to run the compiled class)
*/
public JPanel createIDEEditorPanel(String initialCode, Dimension d) throws MalformedURLException, IOException
{
JScrollPane editorScrollPane = createEditorScrollPane(initialCode);
editorScrollPane.setPreferredSize(new Dimension((int) d.getWidth(), (int) (2/3 * d.getHeight())));
consolePane.getViewport().setPreferredSize(new Dimension((int) d.getWidth(), (int) (1/3 * d.getHeight())));
JPanel editorPanel = new JPanel();
editorPanel.setLayout(new BoxLayout(editorPanel, BoxLayout.PAGE_AXIS));
editorPanel.setSize(d);
editorPanel.add(editorScrollPane);
editorPanel.add(consolePane);
compile();
return editorPanel;
}
示例9: MigFrame
import javax.swing.JPanel; //导入方法依赖的package包/类
public MigFrame(World world, EventManager event, int[] rules)
{
super("MigScape 3.0"); // creates frame, the constructor uses a string argument for the frame title
JPanel mainPanel = new JPanel(new GridLayout(5, 5));
grid = new Grid(world, false);
gridF = new Grid(world, true);
ui = new UserControls(grid, event, rules);
para = new Parameters(event, rules);
mainPanel.add(grid, BorderLayout.CENTER);
mainPanel.add(ui, BorderLayout.NORTH);
mainPanel.add(para, BorderLayout.SOUTH);
mainPanel.setSize(world.getSizeX()*10, world.getSizeY()*10);
grid.setSize(new Dimension(world.getSizeX()*10, world.getSizeY()*10));
gridF.setSize(new Dimension(world.getSizeX()*10, world.getSizeY()*10));
ui.setSize(new Dimension(world.getSizeY()*10, 50));
para.setSize(new Dimension(world.getSizeY()*10, 50));
this.add(grid, BorderLayout.CENTER);
this.add(gridF, BorderLayout.EAST);
this.add(ui, BorderLayout.NORTH);
this.add(para, BorderLayout.SOUTH);
this.validate();
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); // specifies what happens when user closes the frame. exit_on_close means the program will stop
grid.setBackground(Color.WHITE);
gridF.setBackground(Color.WHITE);
ui.setBackground(Color.WHITE);
para.setBackground(Color.WHITE);
}
示例10: Controls
import javax.swing.JPanel; //导入方法依赖的package包/类
public Controls() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
setBorder(new EmptyBorder(1, 1, 1, 1));
setBackground(Color.blue);
JPanel t = new JPanel();
t.setBorder(new EmptyBorder(5, 5, 5, 5));
label = new JLabel();
label.setLayout(new BorderLayout());
t.add(label);
t.setSize(1185, 50);
add(t);
JPanel p = new JPanel();
start = new JButton("Start");
start.addActionListener(this);
p.add(start);
processVoting = new JButton("ProcessVoting");
processVoting.addActionListener(this);
p.add(processVoting);
add(p);
textArea = new JPanel();
screen = new JTextArea(17, 100);
screen.setLineWrap(true);
screen.setForeground(Color.blue);// set color for font
screen.setBackground(Color.WHITE);// set background color
// screen.setText("\n" + "Results from encryption and decryption");
JScrollPane scrollingArea = new JScrollPane(screen);
scrollingArea.setSize(15, 100);
textArea.add(scrollingArea, BorderLayout.CENTER);
add(textArea);
}
示例11: ThemeReaderCrashTest
import javax.swing.JPanel; //导入方法依赖的package包/类
ThemeReaderCrashTest() {
JPanel panel = new JPanel();
JScrollPane pane =
new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
panel.setSize(300, 200);
panel.add(pane);
}
示例12: erzeugeAusleihePanel
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* Erzeugt das Ausleih-Panel, in dem die Zusammenfassung und der
* Ausleih-Button angezeigt werden.
*/
private void erzeugeAusleihePanel()
{
_ausleihePanel = new JPanel();
BorderLayout ausleiheDetailsPanelLayout = new BorderLayout();
_hauptPanel.add(_ausleihePanel, BorderLayout.EAST);
_ausleihePanel.setLayout(ausleiheDetailsPanelLayout);
_ausleihePanel.setPreferredSize(new Dimension(240, -1));
_ausleihePanel.setSize(240, -1);
_ausleihePanel.setBackground(UIConstants.BACKGROUND_COLOR);
erzeugeAnzeigerPanel();
erzeugeAusleihButton();
}
示例13: erzeugeHauptPanel
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* Erzeugt das Hauptpanel, in dem sich Verleihkartenauflister,
* Verleihkartenanzeiger und Rücknahme-Button befinden.
*/
private void erzeugeHauptPanel()
{
_hauptPanel = new JPanel();
_hauptPanel.setLayout(new BorderLayout());
_hauptPanel.setPreferredSize(new java.awt.Dimension(-1, -1));
_hauptPanel.setSize(-1, -1);
_hauptPanel.setAutoscrolls(true);
_hauptPanel.setBackground(UIConstants.BACKGROUND_COLOR);
}
示例14: erzeugeRuecknahme
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* Erzeuge das Rücknahme-Panel, in dem der Verleihkartenanzeiger und der
* Rüchnahme-Button liegen.
*/
private void erzeugeRuecknahme()
{
_ruecknahmePanel = new JPanel();
BorderLayout ausleiheDetailsPanelLayout = new BorderLayout();
_hauptPanel.add(_ruecknahmePanel, BorderLayout.EAST);
_ruecknahmePanel.setLayout(ausleiheDetailsPanelLayout);
_ruecknahmePanel.setPreferredSize(new java.awt.Dimension(240, -1));
_ruecknahmePanel.setSize(240, -1);
_ruecknahmePanel.setBackground(UIConstants.BACKGROUND_COLOR);
erzeugeVerleihkartenAnzeiger();
erzeugeRuecknahmeButton();
}
示例15: createImportFailedPane
import javax.swing.JPanel; //导入方法依赖的package包/类
private JComponent createImportFailedPane( Exception cause ) {
JLabel infoLabel = new JLabel( NbBundle.getMessage( ProgressTrackingPanel.class, "ProgressTrackingPanel.importFailedMessage" ));
infoLabel.setHorizontalAlignment(JLabel.CENTER );
infoLabel.setBackground(Color.red);
infoLabel.setOpaque(true);
infoLabel.setBorder( BorderFactory.createLineBorder(Color.red, 3) );
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
PrintWriter printWriter = new PrintWriter( arrayOutputStream );
cause.printStackTrace( printWriter );
printWriter.flush();
String stackTraceText = arrayOutputStream.toString();
JTextArea stackTraceTextArea = new JTextArea( stackTraceText );
stackTraceTextArea.setEditable(false);
JScrollPane scrollPane = new JScrollPane( stackTraceTextArea );
JButton copyToClipboardButton = new JButton( NbBundle.getMessage( ProgressTrackingPanel.class, "ProgressTrackingPanel.copyToClipboard" ));
copyToClipboardButton.addActionListener( (a) -> {
Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
defaultToolkit.getSystemClipboard().setContents( new StringSelection(stackTraceText), null );
});
JPanel p1 = new JPanel( new FlowLayout(FlowLayout.TRAILING) );
p1.add( copyToClipboardButton );
JPanel p2 = new JPanel( new BorderLayout(0, 10) );
p2.add( infoLabel, BorderLayout.NORTH );
p2.add( scrollPane, BorderLayout.CENTER );
p2.add( p1, BorderLayout.SOUTH );
p2.setSize( new Dimension(600,400) );
p2.setMinimumSize( p2.getSize() );
p2.setPreferredSize( p2.getSize() );
return p2;
}